eth: moved mined, tx events to protocol-hnd and improved tx propagation

Transactions are now propagated to peers from which we have not yet
received the transaction. This will significantly reduce the chatter on
the network.

Moved new mined block handler to the protocol handler and moved
transaction handling to protocol handler.
This commit is contained in:
obscuren
2015-04-22 17:56:06 +02:00
parent 888ece0cb2
commit d3be1a2719
4 changed files with 82 additions and 30 deletions

View File

@ -86,6 +86,12 @@ func (p *peer) sendNewBlock(block *types.Block) error {
return p2p.Send(p.rw, NewBlockMsg, []interface{}{block, block.Td})
}
func (p *peer) sendTransaction(tx *types.Transaction) error {
p.txHashes.Add(tx.Hash())
return p2p.Send(p.rw, TxMsg, []*types.Transaction{tx})
}
func (p *peer) requestHashes(from common.Hash) error {
glog.V(logger.Debug).Infof("[%s] fetching hashes (%d) %x...\n", p.id, maxHashes, from[:4])
return p2p.Send(p.rw, GetBlockHashesMsg, getBlockHashesMsgData{from, maxHashes})