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
This commit is contained in:
committed by
Felix Lange
parent
60e27b51bc
commit
a5d08c893d
@ -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++ {
|
||||
|
Reference in New Issue
Block a user