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

@ -229,8 +229,10 @@ func (self *TxPool) queueTx(tx *types.Transaction) {
func (pool *TxPool) addTx(tx *types.Transaction) {
if _, ok := pool.txs[tx.Hash()]; !ok {
pool.txs[tx.Hash()] = tx
// Notify the subscribers
pool.eventMux.Post(TxPreEvent{tx})
// Notify the subscribers. This event is posted in a goroutine
// because it's possible that somewhere during the post "Remove transaction"
// gets called which will then wait for the global tx pool lock and deadlock.
go pool.eventMux.Post(TxPreEvent{tx})
}
}