From c852eda00f781abafaab2b41d2c1a85fe9d3177f Mon Sep 17 00:00:00 2001 From: Mission Liao Date: Wed, 20 Mar 2019 17:29:22 +0800 Subject: core: reset DKG (#502) * Allow utils.NodeSetCache to purge by rounds. * Purge utils.NodeSetCache when DKG reset. * Add a utils.RoundEvent handler to abort all previous running DKG * Fix test.App hangs in BlockDelivered when utils.RoundEvent is attached. ValidateNextRound is a blocking call and would block test.App.BlockDelivered. --- core/test/network.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'core/test/network.go') diff --git a/core/test/network.go b/core/test/network.go index 0bbb12e..443a26c 100644 --- a/core/test/network.go +++ b/core/test/network.go @@ -498,14 +498,19 @@ func (n *Network) addStateModule(s *State) { n.stateModule = s } -// AddNodeSetCache attaches an utils.NodeSetCache to this module. Once attached +// AttachNodeSetCache attaches an utils.NodeSetCache to this module. Once attached // The behavior of Broadcast-X methods would be switched to broadcast to correct // set of peers, instead of all peers. -func (n *Network) AddNodeSetCache(cache *utils.NodeSetCache) { +func (n *Network) AttachNodeSetCache(cache *utils.NodeSetCache) { // This variable should be attached before run, no lock to protect it. n.cache = cache } +// PurgeNodeSetCache purges cache of some round in attached utils.NodeSetCache. +func (n *Network) PurgeNodeSetCache(round uint64) { + n.cache.Purge(round) +} + func (n *Network) pullBlocksAsync(hashes common.Hashes) { // Setup notification channels for each block hash. notYetReceived := make(map[common.Hash]struct{}) -- cgit