|
|
|
@ -196,9 +196,13 @@ func (p *peer) MarkTransaction(hash common.Hash) { |
|
|
|
|
// SendTransactions sends transactions to the peer and includes the hashes
|
|
|
|
|
// in its transaction hash set for future reference.
|
|
|
|
|
func (p *peer) SendTransactions(txs types.Transactions) error { |
|
|
|
|
// Mark all the transactions as known, but ensure we don't overflow our limits
|
|
|
|
|
for _, tx := range txs { |
|
|
|
|
p.knownTxs.Add(tx.Hash()) |
|
|
|
|
} |
|
|
|
|
for p.knownTxs.Cardinality() >= maxKnownTxs { |
|
|
|
|
p.knownTxs.Pop() |
|
|
|
|
} |
|
|
|
|
return p2p.Send(p.rw, TxMsg, txs) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -207,9 +211,13 @@ func (p *peer) SendTransactions(txs types.Transactions) error { |
|
|
|
|
func (p *peer) AsyncSendTransactions(txs []*types.Transaction) { |
|
|
|
|
select { |
|
|
|
|
case p.queuedTxs <- txs: |
|
|
|
|
// Mark all the transactions as known, but ensure we don't overflow our limits
|
|
|
|
|
for _, tx := range txs { |
|
|
|
|
p.knownTxs.Add(tx.Hash()) |
|
|
|
|
} |
|
|
|
|
for p.knownTxs.Cardinality() >= maxKnownTxs { |
|
|
|
|
p.knownTxs.Pop() |
|
|
|
|
} |
|
|
|
|
default: |
|
|
|
|
p.Log().Debug("Dropping transaction propagation", "count", len(txs)) |
|
|
|
|
} |
|
|
|
@ -218,9 +226,13 @@ func (p *peer) AsyncSendTransactions(txs []*types.Transaction) { |
|
|
|
|
// SendNewBlockHashes announces the availability of a number of blocks through
|
|
|
|
|
// a hash notification.
|
|
|
|
|
func (p *peer) SendNewBlockHashes(hashes []common.Hash, numbers []uint64) error { |
|
|
|
|
// Mark all the block hashes as known, but ensure we don't overflow our limits
|
|
|
|
|
for _, hash := range hashes { |
|
|
|
|
p.knownBlocks.Add(hash) |
|
|
|
|
} |
|
|
|
|
for p.knownBlocks.Cardinality() >= maxKnownBlocks { |
|
|
|
|
p.knownBlocks.Pop() |
|
|
|
|
} |
|
|
|
|
request := make(newBlockHashesData, len(hashes)) |
|
|
|
|
for i := 0; i < len(hashes); i++ { |
|
|
|
|
request[i].Hash = hashes[i] |
|
|
|
@ -235,7 +247,11 @@ func (p *peer) SendNewBlockHashes(hashes []common.Hash, numbers []uint64) error |
|
|
|
|
func (p *peer) AsyncSendNewBlockHash(block *types.Block) { |
|
|
|
|
select { |
|
|
|
|
case p.queuedAnns <- block: |
|
|
|
|
// Mark all the block hash as known, but ensure we don't overflow our limits
|
|
|
|
|
p.knownBlocks.Add(block.Hash()) |
|
|
|
|
for p.knownBlocks.Cardinality() >= maxKnownBlocks { |
|
|
|
|
p.knownBlocks.Pop() |
|
|
|
|
} |
|
|
|
|
default: |
|
|
|
|
p.Log().Debug("Dropping block announcement", "number", block.NumberU64(), "hash", block.Hash()) |
|
|
|
|
} |
|
|
|
@ -243,7 +259,11 @@ func (p *peer) AsyncSendNewBlockHash(block *types.Block) { |
|
|
|
|
|
|
|
|
|
// SendNewBlock propagates an entire block to a remote peer.
|
|
|
|
|
func (p *peer) SendNewBlock(block *types.Block, td *big.Int) error { |
|
|
|
|
// Mark all the block hash as known, but ensure we don't overflow our limits
|
|
|
|
|
p.knownBlocks.Add(block.Hash()) |
|
|
|
|
for p.knownBlocks.Cardinality() >= maxKnownBlocks { |
|
|
|
|
p.knownBlocks.Pop() |
|
|
|
|
} |
|
|
|
|
return p2p.Send(p.rw, NewBlockMsg, []interface{}{block, td}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -252,7 +272,11 @@ func (p *peer) SendNewBlock(block *types.Block, td *big.Int) error { |
|
|
|
|
func (p *peer) AsyncSendNewBlock(block *types.Block, td *big.Int) { |
|
|
|
|
select { |
|
|
|
|
case p.queuedProps <- &propEvent{block: block, td: td}: |
|
|
|
|
// Mark all the block hash as known, but ensure we don't overflow our limits
|
|
|
|
|
p.knownBlocks.Add(block.Hash()) |
|
|
|
|
for p.knownBlocks.Cardinality() >= maxKnownBlocks { |
|
|
|
|
p.knownBlocks.Pop() |
|
|
|
|
} |
|
|
|
|
default: |
|
|
|
|
p.Log().Debug("Dropping block propagation", "number", block.NumberU64(), "hash", block.Hash()) |
|
|
|
|
} |
|
|
|
|