Skip to content

Commit

Permalink
btcd+netsync: support witness tx and block in notfound msg
Browse files Browse the repository at this point in the history
  • Loading branch information
yyforyongyu committed Sep 3, 2020
1 parent 23d149c commit 6163444
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions netsync/manager.go
Expand Up @@ -1031,11 +1031,16 @@ func (sm *SyncManager) handleNotFoundMsg(nfmsg *notFoundMsg) {
// verify the hash was actually announced by the peer
// before deleting from the global requested maps.
switch inv.Type {
case wire.InvTypeWitnessBlock:
fallthrough
case wire.InvTypeBlock:
if _, exists := state.requestedBlocks[inv.Hash]; exists {
delete(state.requestedBlocks, inv.Hash)
delete(sm.requestedBlocks, inv.Hash)
}

case wire.InvTypeWitnessTx:
fallthrough
case wire.InvTypeTx:
if _, exists := state.requestedTxns[inv.Hash]; exists {
delete(state.requestedTxns, inv.Hash)
Expand Down
4 changes: 4 additions & 0 deletions server.go
Expand Up @@ -1321,8 +1321,12 @@ func (sp *serverPeer) OnNotFound(p *peer.Peer, msg *wire.MsgNotFound) {
switch inv.Type {
case wire.InvTypeBlock:
numBlocks++
case wire.InvTypeWitnessBlock:
numBlocks++
case wire.InvTypeTx:
numTxns++
case wire.InvTypeWitnessTx:
numTxns++
default:
peerLog.Debugf("Invalid inv type '%d' in notfound message from %s",
inv.Type, sp)
Expand Down

0 comments on commit 6163444

Please sign in to comment.