diff options
author | Felföldi Zsolt <zsfelfoldi@gmail.com> | 2017-06-21 18:27:38 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2017-06-21 18:27:38 +0800 |
commit | a5d08c893d61f66d60d8a91216aee5347b78f93e (patch) | |
tree | 500f3a788ecd4f299692ce1d1069f2efdc79d73d /les/distributor_test.go | |
parent | 60e27b51bc5643bc6a76151020a9e1a245340b70 (diff) | |
download | dexon-a5d08c893d61f66d60d8a91216aee5347b78f93e.tar.gz dexon-a5d08c893d61f66d60d8a91216aee5347b78f93e.tar.zst dexon-a5d08c893d61f66d60d8a91216aee5347b78f93e.zip |
les: code refactoring (#14416)
This commit does various code refactorings:
- generalizes and moves the request retrieval/timeout/resend logic out of LesOdr
(will be used by a subsequent PR)
- reworks the peer management logic so that all services can register with
peerSet to get notified about added/dropped peers (also gets rid of the ugly
getAllPeers callback in requestDistributor)
- moves peerSet, LesOdr, requestDistributor and retrieveManager initialization
out of ProtocolManager because I believe they do not really belong there and the
whole init process was ugly and ad-hoc
Diffstat (limited to 'les/distributor_test.go')
-rw-r--r-- | les/distributor_test.go | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/les/distributor_test.go b/les/distributor_test.go index ae184b21b..4e7f8bd29 100644 --- a/les/distributor_test.go +++ b/les/distributor_test.go @@ -122,20 +122,14 @@ func testRequestDistributor(t *testing.T, resend bool) { stop := make(chan struct{}) defer close(stop) + dist := newRequestDistributor(nil, stop) var peers [testDistPeerCount]*testDistPeer for i, _ := range peers { peers[i] = &testDistPeer{} go peers[i].worker(t, !resend, stop) + dist.registerTestPeer(peers[i]) } - dist := newRequestDistributor(func() map[distPeer]struct{} { - m := make(map[distPeer]struct{}) - for _, peer := range peers { - m[peer] = struct{}{} - } - return m - }, stop) - var wg sync.WaitGroup for i := 1; i <= testDistReqCount; i++ { |