Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FUCoin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
leonsixt
FUCoin
Commits
ef6818ee
Commit
ef6818ee
authored
7 years ago
by
sinur
Browse files
Options
Downloads
Patches
Plain Diff
Added some delays to broadcast when starting a snapshot
parent
bf18ee3f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/fucoin/AbstractNode.java
+12
-1
12 additions, 1 deletion
src/main/java/fucoin/AbstractNode.java
src/main/java/fucoin/configurations/GGBWalletConfiguration.java
+12
-3
12 additions, 3 deletions
...in/java/fucoin/configurations/GGBWalletConfiguration.java
with
24 additions
and
4 deletions
src/main/java/fucoin/AbstractNode.java
+
12
−
1
View file @
ef6818ee
...
@@ -12,6 +12,7 @@ import scala.concurrent.Promise;
...
@@ -12,6 +12,7 @@ import scala.concurrent.Promise;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
org.openide.util.Exceptions
;
public
abstract
class
AbstractNode
extends
UntypedActor
implements
Serializable
{
public
abstract
class
AbstractNode
extends
UntypedActor
implements
Serializable
{
protected
SnapshotToken
currentSnapshotToken
;
protected
SnapshotToken
currentSnapshotToken
;
...
@@ -90,7 +91,7 @@ public abstract class AbstractNode extends UntypedActor implements Serializable
...
@@ -90,7 +91,7 @@ public abstract class AbstractNode extends UntypedActor implements Serializable
}
}
public
Promise
<
Snapshot
>
makeSnapshot
()
{
public
Promise
<
Snapshot
>
makeSnapshot
()
throws
InterruptedException
{
String
prefix
=
""
;
String
prefix
=
""
;
if
(
this
instanceof
SuperVisorImpl
)
{
if
(
this
instanceof
SuperVisorImpl
)
{
prefix
=
"supervisor"
;
prefix
=
"supervisor"
;
...
@@ -105,8 +106,18 @@ public abstract class AbstractNode extends UntypedActor implements Serializable
...
@@ -105,8 +106,18 @@ public abstract class AbstractNode extends UntypedActor implements Serializable
AbstractWallet
wallet
=
(
AbstractWallet
)
this
;
AbstractWallet
wallet
=
(
AbstractWallet
)
this
;
this
.
snapshot
.
addState
(
wallet
.
getName
(),
wallet
.
getAmount
());
this
.
snapshot
.
addState
(
wallet
.
getName
(),
wallet
.
getAmount
());
}
}
//Broadcast
int
i
=
0
;
for
(
ActorRef
act
:
getKnownNeighbors
().
values
())
{
for
(
ActorRef
act
:
getKnownNeighbors
().
values
())
{
act
.
tell
(
new
SnapShotBegin
(
this
.
currentSnapshotToken
),
self
());
act
.
tell
(
new
SnapShotBegin
(
this
.
currentSnapshotToken
),
self
());
if
(
i
%
3
==
0
){
try
{
//Add a little delay now and then
Thread
.
sleep
(
3000
);
}
catch
(
InterruptedException
ex
)
{
Exceptions
.
printStackTrace
(
ex
);
}
}
}
}
return
this
.
snapshot
.
promise
();
return
this
.
snapshot
.
promise
();
}
}
...
...
This diff is collapsed.
Click to expand it.
src/main/java/fucoin/configurations/GGBWalletConfiguration.java
+
12
−
3
View file @
ef6818ee
...
@@ -26,6 +26,7 @@ import java.util.List;
...
@@ -26,6 +26,7 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
import
java.util.stream.Stream
;
import
org.openide.util.Exceptions
;
/**
/**
* This configuration spawns 200 wallets to demonstrate the spawning of many headless wallets
* This configuration spawns 200 wallets to demonstrate the spawning of many headless wallets
...
@@ -185,7 +186,11 @@ public class GGBWalletConfiguration extends AbstractConfiguration {
...
@@ -185,7 +186,11 @@ public class GGBWalletConfiguration extends AbstractConfiguration {
BALANCED_MIN
,
BALANCED_MAX
,
BALANCED_ADAPTION
));
BALANCED_MIN
,
BALANCED_MAX
,
BALANCED_ADAPTION
));
}
}
start
=
System
.
currentTimeMillis
()
/
1000
.;
start
=
System
.
currentTimeMillis
()
/
1000
.;
this
.
nextTransaction
();
try
{
this
.
nextTransaction
();
}
catch
(
InterruptedException
ex
)
{
Exceptions
.
printStackTrace
(
ex
);
}
simulationFinished
.
future
().
onSuccess
(
new
OnSuccess
<
Void
>()
{
simulationFinished
.
future
().
onSuccess
(
new
OnSuccess
<
Void
>()
{
@Override
@Override
public
void
onSuccess
(
Void
result
)
{
public
void
onSuccess
(
Void
result
)
{
...
@@ -195,7 +200,7 @@ public class GGBWalletConfiguration extends AbstractConfiguration {
...
@@ -195,7 +200,7 @@ public class GGBWalletConfiguration extends AbstractConfiguration {
}
}
},
context
().
dispatcher
());
},
context
().
dispatcher
());
}
}
private
void
nextTransaction
()
{
private
void
nextTransaction
()
throws
InterruptedException
{
for
(;
currentStep
<
n_steps
;
currentStep
++)
{
for
(;
currentStep
<
n_steps
;
currentStep
++)
{
for
(
WalletSimulation
currentWallet
:
simulations
.
values
())
{
for
(
WalletSimulation
currentWallet
:
simulations
.
values
())
{
if
(
currentWallet
.
willSend
()){
if
(
currentWallet
.
willSend
()){
...
@@ -269,7 +274,11 @@ public class GGBWalletConfiguration extends AbstractConfiguration {
...
@@ -269,7 +274,11 @@ public class GGBWalletConfiguration extends AbstractConfiguration {
notification
.
source
.
path
().
name
()
+
" to "
+
notification
.
target
.
path
().
name
());
notification
.
source
.
path
().
name
()
+
" to "
+
notification
.
target
.
path
().
name
());
if
(
currentStep
<
n_steps
)
{
if
(
currentStep
<
n_steps
)
{
nextTransaction
();
try
{
nextTransaction
();
}
catch
(
InterruptedException
ex
)
{
Exceptions
.
printStackTrace
(
ex
);
}
}
else
{
}
else
{
if
(
simulationFinished
!=
null
)
{
if
(
simulationFinished
!=
null
)
{
simulationFinished
.
success
(
null
);
simulationFinished
.
success
(
null
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment