Browse Source

blockchain/v2: correctly set block store base in status responses (#4971)

See: https://github.com/tendermint/tendermint/pull/4969#pullrequestreview-425298225
pull/4976/head
Erik Grinaker 5 years ago
committed by GitHub
parent
commit
b76b270a23
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 6 deletions
  1. +1
    -0
      CHANGELOG_PENDING.md
  2. +3
    -3
      blockchain/v2/io.go
  3. +2
    -2
      blockchain/v2/reactor.go
  4. +1
    -1
      blockchain/v2/reactor_test.go

+ 1
- 0
CHANGELOG_PENDING.md View File

@ -83,3 +83,4 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi
### BUG FIXES:
- [consensus] [\#4895](https://github.com/tendermint/tendermint/pull/4895) Cache the address of the validator to reduce querying a remote KMS (@joe-bowman)
- [blockchain/v2] Correctly set block store base in status responses (@erikgrinaker)

+ 3
- 3
blockchain/v2/io.go View File

@ -12,7 +12,7 @@ type iIO interface {
sendBlockRequest(peerID p2p.ID, height int64) error
sendBlockToPeer(block *types.Block, peerID p2p.ID) error
sendBlockNotFound(height int64, peerID p2p.ID) error
sendStatusResponse(height int64, peerID p2p.ID) error
sendStatusResponse(base int64, height int64, peerID p2p.ID) error
broadcastStatusRequest(base int64, height int64)
@ -54,12 +54,12 @@ func (sio *switchIO) sendBlockRequest(peerID p2p.ID, height int64) error {
return nil
}
func (sio *switchIO) sendStatusResponse(height int64, peerID p2p.ID) error {
func (sio *switchIO) sendStatusResponse(base int64, height int64, peerID p2p.ID) error {
peer := sio.sw.Peers().Get(peerID)
if peer == nil {
return fmt.Errorf("peer not found")
}
msgBytes := cdc.MustMarshalBinaryBare(&bcStatusResponseMessage{Height: height})
msgBytes := cdc.MustMarshalBinaryBare(&bcStatusResponseMessage{Base: base, Height: height})
if queued := peer.TrySend(BlockchainChannel, msgBytes); !queued {
return fmt.Errorf("peer queue full")


+ 2
- 2
blockchain/v2/reactor.go View File

@ -561,7 +561,7 @@ func (r *BlockchainReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) {
switch msg := msg.(type) {
case *bcStatusRequestMessage:
if err := r.io.sendStatusResponse(r.store.Height(), src.ID()); err != nil {
if err := r.io.sendStatusResponse(r.store.Base(), r.store.Height(), src.ID()); err != nil {
r.logger.Error("Could not send status message to peer", "src", src)
}
@ -609,7 +609,7 @@ func (r *BlockchainReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) {
// AddPeer implements Reactor interface
func (r *BlockchainReactor) AddPeer(peer p2p.Peer) {
err := r.io.sendStatusResponse(r.store.Height(), peer.ID())
err := r.io.sendStatusResponse(r.store.Base(), r.store.Height(), peer.ID())
if err != nil {
r.logger.Error("Could not send status message to peer new", "src", peer.ID, "height", r.SyncHeight())
}


+ 1
- 1
blockchain/v2/reactor_test.go View File

@ -96,7 +96,7 @@ func (sio *mockSwitchIo) sendBlockRequest(peerID p2p.ID, height int64) error {
return nil
}
func (sio *mockSwitchIo) sendStatusResponse(height int64, peerID p2p.ID) error {
func (sio *mockSwitchIo) sendStatusResponse(base int64, height int64, peerID p2p.ID) error {
sio.mtx.Lock()
defer sio.mtx.Unlock()
sio.numStatusResponse++


Loading…
Cancel
Save