diff options
author | Sonic <sonic@dexon.org> | 2018-12-05 15:17:38 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 21:32:54 +0800 |
commit | 8a244e8fb95eac41e41ecb07e5652fedb6949d0e (patch) | |
tree | 3404cb5da63865d5045d910157e67fa66c717c3d /dex/helper_test.go | |
parent | 9e5b923db28f0776bd6e34dbe1c9eddef03ffea9 (diff) | |
download | dexon-8a244e8fb95eac41e41ecb07e5652fedb6949d0e.tar dexon-8a244e8fb95eac41e41ecb07e5652fedb6949d0e.tar.gz dexon-8a244e8fb95eac41e41ecb07e5652fedb6949d0e.tar.bz2 dexon-8a244e8fb95eac41e41ecb07e5652fedb6949d0e.tar.lz dexon-8a244e8fb95eac41e41ecb07e5652fedb6949d0e.tar.xz dexon-8a244e8fb95eac41e41ecb07e5652fedb6949d0e.tar.zst dexon-8a244e8fb95eac41e41ecb07e5652fedb6949d0e.zip |
core, dex: polish sync (#75)
- Broadcasting blocks at chain head event is not correct when the full
node is not running in block proposer mode. Introduce NewFinalizedBlockEvent,
this event is post by the full node which runs in block proposer mode when a
block is witnessed and resulting in some blocks are considered finalized.
- Non block proposer node will still broadcast blocks
at the following moment (same as ethereum):
1. a sync with a peer is terminated successfully
2. a block passes the fetcher's header check during inserting blocks
3. a block is successfully inserted by fetcher
- Don't trigger a sync when we are not behind other peers more than
acceptable distance. Fetcher is able to cover this.
Diffstat (limited to 'dex/helper_test.go')
-rw-r--r-- | dex/helper_test.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/dex/helper_test.go b/dex/helper_test.go index 62dd6c5f4..86a901cc2 100644 --- a/dex/helper_test.go +++ b/dex/helper_test.go @@ -98,6 +98,15 @@ func (s *testP2PServer) RemoveGroup(name string) { delete(s.group, name) } +type testApp struct { + finalizedBlockFeed event.Feed +} + +func (a *testApp) SubscribeNewFinalizedBlockEvent( + ch chan<- core.NewFinalizedBlockEvent) event.Subscription { + return a.finalizedBlockFeed.Subscribe(ch) +} + // newTestProtocolManager creates a new protocol manager for testing purposes, // with the given number of blocks already known, and potential notification // channels for different events. @@ -125,7 +134,7 @@ func newTestProtocolManager(mode downloader.SyncMode, blocks int, generator func notarySetFunc: func(uint64, uint32) (map[string]struct{}, error) { return nil, nil }, } - pm, err := NewProtocolManager(gspec.Config, mode, DefaultConfig.NetworkId, evmux, &testTxPool{added: newtx}, engine, blockchain, db, true, tgov) + pm, err := NewProtocolManager(gspec.Config, mode, DefaultConfig.NetworkId, evmux, &testTxPool{added: newtx}, engine, blockchain, db, true, tgov, &testApp{}) if err != nil { return nil, nil, err } |