continue cleanup

This commit is contained in:
William Banfield
2022-10-20 13:09:28 -04:00
parent 934bf233c9
commit 934594f231
3 changed files with 11 additions and 15 deletions

View File

@@ -467,11 +467,10 @@ func TestSwitchStopPeerForError(t *testing.T) {
// send messages to the peer from sw1
p := sw1.Peers().List()[0]
e := Envelope{
p.Send(Envelope{
ChannelID: 0x1,
Message: &p2p.Message{},
}
p.Send(e)
})
// stop sw2. this should cause the p to fail,
// which results in calling StopPeerForError internally

View File

@@ -132,7 +132,7 @@ func (r *Reactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) {
for _, snapshot := range snapshots {
r.Logger.Debug("Advertising snapshot", "height", snapshot.Height,
"format", snapshot.Format, "peer", src.ID())
e := p2p.Envelope{
src.Send(p2p.Envelope{
ChannelID: chID,
Message: mustWrapToProto(&ssproto.SnapshotsResponse{
Height: snapshot.Height,
@@ -141,8 +141,7 @@ func (r *Reactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) {
Hash: snapshot.Hash,
Metadata: snapshot.Metadata,
}),
}
src.Send(e)
})
}
case *ssproto.SnapshotsResponse:
@@ -188,7 +187,7 @@ func (r *Reactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) {
}
r.Logger.Debug("Sending chunk", "height", msg.Height, "format", msg.Format,
"chunk", msg.Index, "peer", src.ID())
e := p2p.Envelope{
src.Send(p2p.Envelope{
ChannelID: ChunkChannel,
Message: mustWrapToProto(&ssproto.ChunkResponse{
Height: msg.Height,
@@ -197,8 +196,7 @@ func (r *Reactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) {
Chunk: resp.Chunk,
Missing: resp.Chunk == nil,
}),
}
src.Send(e)
})
case *ssproto.ChunkResponse:
r.mtx.RLock()
@@ -279,11 +277,11 @@ func (r *Reactor) Sync(stateProvider StateProvider, discoveryTime time.Duration)
hook := func() {
r.Logger.Debug("Requesting snapshots from known peers")
// Request snapshots from all currently connected peers
e := p2p.Envelope{
r.Switch.NewBroadcast(p2p.Envelope{
ChannelID: SnapshotChannel,
Message: mustWrapToProto(&ssproto.SnapshotsRequest{}),
}
r.Switch.NewBroadcast(e)
})
}
hook()

View File

@@ -471,15 +471,14 @@ func (s *syncer) requestChunk(snapshot *snapshot, chunk uint32) {
}
s.logger.Debug("Requesting snapshot chunk", "height", snapshot.Height,
"format", snapshot.Format, "chunk", chunk, "peer", peer.ID())
e := p2p.Envelope{
peer.Send(p2p.Envelope{
ChannelID: ChunkChannel,
Message: mustWrapToProto(&ssproto.ChunkRequest{
Height: snapshot.Height,
Format: snapshot.Format,
Index: chunk,
}),
}
peer.Send(e)
})
}
// verifyApp verifies the sync, checking the app hash, last block height and app version