Skip to content

Commit

Permalink
Use setimer on Network.discover
Browse files Browse the repository at this point in the history
These need to be replaced to use setTimer once TaskManager is fixed to use it.
  • Loading branch information
TrustHenry committed Jun 3, 2020
1 parent 7a2e4de commit b498e04
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 26 deletions.
25 changes: 4 additions & 21 deletions source/agora/node/FullNode.d
Original file line number Diff line number Diff line change
Expand Up @@ -153,30 +153,13 @@ public class FullNode : API
***************************************************************************/

public void start ()
{
this.startPeriodicDiscovery();
this.network.startPeriodicCatchup(this.ledger);
}

/***************************************************************************
Starts the periodic network discovery task.
***************************************************************************/

private void startPeriodicDiscovery ()
{
import core.time;

this.taskman.runTask(
()
{
while (1)
{
this.network.discover();
this.taskman.wait(5.seconds);
}
});
scope void discover () { this.network.discover(); }
discover(); // avoid delay
this.taskman.setTimer(5.seconds, &discover, Periodic.Yes);
this.network.startPeriodicCatchup(this.ledger);
}

/***************************************************************************
Expand Down
9 changes: 4 additions & 5 deletions source/agora/node/Validator.d
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import ocean.util.log.Logger;

import core.time;

import std.functional;
mixin AddLogger!();

/*******************************************************************************
Expand Down Expand Up @@ -100,11 +101,9 @@ public class Validator : FullNode, API
buildRequiredKeys(this.config.node.key_pair.address,
this.config.quorum, required_peer_keys);

while (1)
{
this.network.discover(required_peer_keys);
this.taskman.wait(5.seconds);
}
scope void discover () { this.network.discover(required_peer_keys); }
discover(); // avoid delay
this.taskman.setTimer(5.seconds, &discover, Periodic.Yes);
});
}

Expand Down

0 comments on commit b498e04

Please sign in to comment.