Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

netsync: ignore tx invs when we're not current #2270

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions netsync/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -1171,6 +1171,11 @@ func (sm *SyncManager) handleInvMsg(imsg *invMsg) {
peer.UpdateLastAnnouncedBlock(&invVects[lastBlock].Hash)
}

// Ignore inventory when we're in headers-first mode.
if sm.headersFirstMode {
return
}

// Ignore invs from peers that aren't the sync if we are not current.
// Helps prevent fetching a mass of orphans.
if peer != sm.syncPeer && !sm.current() {
Expand Down Expand Up @@ -1201,15 +1206,20 @@ func (sm *SyncManager) handleInvMsg(imsg *invMsg) {
continue
}

// Ignore txs when we're not current as we can't verify them
// and they'll just go in the orphan pool.
if iv.Type == wire.InvTypeWitnessTx ||
iv.Type == wire.InvTypeTx {

if !sm.current() {
continue
}
}

// Add the inventory to the cache of known inventory
// for the peer.
peer.AddKnownInventory(iv)

// Ignore inventory when we're in headers-first mode.
if sm.headersFirstMode {
continue
}

// Request the inventory if we don't already have it.
haveInv, err := sm.haveInventory(iv)
if err != nil {
Expand Down