Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
Breeze
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DeStream-public
Breeze
Commits
867f0193
Commit
867f0193
authored
Jun 14, 2017
by
Jeremy Bokobza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added bunch of properties to the tumbling state
parent
0e05b59e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
7 deletions
+37
-7
TumbleBitManager.cs
Breeze/src/Breeze.TumbleBit.Client/TumbleBitManager.cs
+4
-1
TumblingState.cs
Breeze/src/Breeze.TumbleBit.Client/TumblingState.cs
+33
-6
No files found.
Breeze/src/Breeze.TumbleBit.Client/TumbleBitManager.cs
View file @
867f0193
...
...
@@ -34,7 +34,7 @@ namespace Breeze.TumbleBit.Client
this
.
network
=
network
;
this
.
logger
=
loggerFactory
.
CreateLogger
(
this
.
GetType
().
FullName
);
this
.
tumblingState
=
new
TumblingState
(
loggerFactory
);
this
.
tumblingState
=
new
TumblingState
(
loggerFactory
,
this
.
chain
,
this
.
walletManager
,
this
.
network
);
}
/// <inheritdoc />
...
...
@@ -54,6 +54,7 @@ namespace Breeze.TumbleBit.Client
// update and save the state
this
.
tumblingState
.
TumblerUri
=
serverAddress
;
this
.
tumblingState
.
TumblerParameters
=
this
.
TumblerParameters
;
this
.
tumblingState
.
SetClients
(
this
.
tumblerService
);
this
.
tumblingState
.
Save
();
return
this
.
TumblerParameters
;
...
...
@@ -87,7 +88,9 @@ namespace Breeze.TumbleBit.Client
}
// update the state and save
this
.
tumblingState
.
DestinationWallet
=
destinationWallet
;
this
.
tumblingState
.
DestinationWalletName
=
destinationWalletName
;
this
.
tumblingState
.
OriginWallet
=
originWallet
;
this
.
tumblingState
.
OriginWalletName
=
originWalletName
;
this
.
tumblingState
.
Save
();
...
...
Breeze/src/Breeze.TumbleBit.Client/TumblingState.cs
View file @
867f0193
...
...
@@ -15,10 +15,13 @@ namespace Breeze.TumbleBit.Client
{
public
class
TumblingState
:
IStateMachine
{
private
readonly
ILogger
logger
;
private
const
string
StateFileName
=
"tumblebit_state.json"
;
private
readonly
ILogger
logger
;
private
readonly
ConcurrentChain
chain
;
private
readonly
IWalletManager
walletManager
;
private
readonly
CoinType
coinType
;
[
JsonProperty
(
"tumblerParameters"
)]
public
ClassicTumblerParameters
TumblerParameters
{
get
;
set
;
}
...
...
@@ -37,14 +40,38 @@ namespace Breeze.TumbleBit.Client
[
JsonProperty
(
"sessions"
,
NullValueHandling
=
NullValueHandling
.
Ignore
)]
public
IList
<
Session
>
Sessions
{
get
;
set
;
}
[
JsonIgnore
]
public
Wallet
OriginWallet
{
get
;
set
;
}
[
JsonIgnore
]
public
Wallet
DestinationWallet
{
get
;
set
;
}
[
JsonIgnore
]
public
ITumblerService
AliceClient
{
get
;
set
;
}
[
JsonIgnore
]
public
ITumblerService
BobClient
{
get
;
set
;
}
[
JsonConstructor
]
public
TumblingState
()
{
}
public
TumblingState
(
ILoggerFactory
loggerFactory
)
public
TumblingState
(
ILoggerFactory
loggerFactory
,
ConcurrentChain
chain
,
IWalletManager
walletManager
,
Network
network
)
{
this
.
logger
=
loggerFactory
.
CreateLogger
(
this
.
GetType
().
FullName
);
this
.
chain
=
chain
;
this
.
walletManager
=
walletManager
;
this
.
coinType
=
(
CoinType
)
network
.
Consensus
.
CoinType
;
}
public
void
SetClients
(
ITumblerService
tumblerService
)
{
this
.
AliceClient
=
tumblerService
;
this
.
BobClient
=
tumblerService
;
}
/// <inheritdoc />
...
...
@@ -70,7 +97,7 @@ namespace Breeze.TumbleBit.Client
this
.
DestinationWalletName
=
savedState
.
DestinationWalletName
;
this
.
LastBlockReceivedHeight
=
savedState
.
LastBlockReceivedHeight
;
this
.
TumblerParameters
=
savedState
.
TumblerParameters
;
this
.
TumblerUri
=
savedState
.
TumblerUri
;
this
.
TumblerUri
=
savedState
.
TumblerUri
;
}
/// <inheritdoc />
...
...
@@ -110,7 +137,7 @@ namespace Breeze.TumbleBit.Client
var
cycles
=
this
.
TumblerParameters
.
CycleGenerator
.
GetCycles
(
this
.
LastBlockReceivedHeight
);
var
existingSessions
=
cycles
.
SelectMany
(
c
=>
this
.
Sessions
.
Where
(
s
=>
s
.
StartCycle
==
c
.
Start
)).
ToList
();
foreach
(
var
existingSession
in
existingSessions
)
{
{
// create a new session to be updated
var
session
=
new
Session
();
if
(
existingSession
.
NegotiationClientState
!=
null
)
...
...
@@ -133,7 +160,7 @@ namespace Breeze.TumbleBit.Client
this
.
Sessions
[
index
]
=
session
;
}
this
.
Save
();
this
.
Save
();
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment