diff options
author | obscuren <geffobscura@gmail.com> | 2015-02-05 09:28:54 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-02-05 09:28:54 +0800 |
commit | 1d519854e2bfe8d5f2e8674f4f04ccf9aeaabe84 (patch) | |
tree | e459f8b005415c2f14bb4796b2338c091181c67a /eth | |
parent | 292f7ada8ea4f709ef90b2c20888cdbfbf7b06c6 (diff) | |
download | go-tangerine-1d519854e2bfe8d5f2e8674f4f04ccf9aeaabe84.tar go-tangerine-1d519854e2bfe8d5f2e8674f4f04ccf9aeaabe84.tar.gz go-tangerine-1d519854e2bfe8d5f2e8674f4f04ccf9aeaabe84.tar.bz2 go-tangerine-1d519854e2bfe8d5f2e8674f4f04ccf9aeaabe84.tar.lz go-tangerine-1d519854e2bfe8d5f2e8674f4f04ccf9aeaabe84.tar.xz go-tangerine-1d519854e2bfe8d5f2e8674f4f04ccf9aeaabe84.tar.zst go-tangerine-1d519854e2bfe8d5f2e8674f4f04ccf9aeaabe84.zip |
Propagate known transactions to new peers on connect
Diffstat (limited to 'eth')
-rw-r--r-- | eth/protocol.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/eth/protocol.go b/eth/protocol.go index 68c52b7ce..d7a7fa910 100644 --- a/eth/protocol.go +++ b/eth/protocol.go @@ -46,6 +46,7 @@ type ethProtocol struct { // used as an argument to EthProtocol type txPool interface { AddTransactions([]*types.Transaction) + GetTransactions() types.Transactions } type chainManager interface { @@ -101,6 +102,7 @@ func runEthProtocol(txPool txPool, chainManager chainManager, blockPool blockPoo } err = self.handleStatus() if err == nil { + self.propagateTxs() for { err = self.handle() if err != nil { @@ -324,3 +326,13 @@ func (self *ethProtocol) protoErrorDisconnect(code int, format string, params .. } } + +func (self *ethProtocol) propagateTxs() { + transactions := self.txPool.GetTransactions() + iface := make([]interface{}, len(transactions)) + for i, transaction := range transactions { + iface[i] = transaction + } + + self.rw.WriteMsg(p2p.NewMsg(TxMsg, iface...)) +} |