diff options
author | Maran <maran.hidskes@gmail.com> | 2014-04-01 20:20:55 +0800 |
---|---|---|
committer | Maran <maran.hidskes@gmail.com> | 2014-04-01 20:20:55 +0800 |
commit | 0a8801082676d64f904cbb5b62c1159e0bbd7788 (patch) | |
tree | 05e9c4ea80d5e01cca53d583318f43606418a19e /peer.go | |
parent | 5f49a659c36dbfb8c330ddc3d4565c19a9a936b5 (diff) | |
parent | 7277c420479239fbea78417e42c43ee0162c2728 (diff) | |
download | go-tangerine-0a8801082676d64f904cbb5b62c1159e0bbd7788.tar.gz go-tangerine-0a8801082676d64f904cbb5b62c1159e0bbd7788.tar.zst go-tangerine-0a8801082676d64f904cbb5b62c1159e0bbd7788.zip |
Merge conflicts
Diffstat (limited to 'peer.go')
-rw-r--r-- | peer.go | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -396,7 +396,8 @@ func (p *Peer) HandleInbound() { // in the TxPool where it will undergo validation and // processing when a new block is found for i := 0; i < msg.Data.Len(); i++ { - p.ethereum.TxPool().QueueTransaction(ethchain.NewTransactionFromData(msg.Data.Get(i).Encode())) + tx := ethchain.NewTransactionFromValue(msg.Data.Get(i)) + p.ethereum.TxPool().QueueTransaction(tx) } case ethwire.MsgGetPeersTy: // Flag this peer as a 'requested of new peers' this to @@ -462,6 +463,16 @@ func (p *Peer) HandleInbound() { case ethwire.MsgNotInChainTy: ethutil.Config.Log.Infof("Not in chain %x\n", msg.Data) // TODO + case ethwire.MsgGetTxsTy: + // Get the current transactions of the pool + txs := p.ethereum.TxPool().CurrentTransactions() + // Get the RlpData values from the txs + txsInterface := make([]interface{}, len(txs)) + for i, tx := range txs { + txsInterface[i] = tx.RlpData() + } + // Broadcast it back to the peer + p.QueueMessage(ethwire.NewMessage(ethwire.MsgTxTy, txsInterface)) // Unofficial but fun nonetheless case ethwire.MsgTalkTy: @@ -649,7 +660,11 @@ func (p *Peer) CatchupWithPeer(blockHash []byte) { msg := ethwire.NewMessage(ethwire.MsgGetChainTy, []interface{}{blockHash, uint64(50)}) p.QueueMessage(msg) - ethutil.Config.Log.Debugf("Requesting blockchain %x...\n", blockHash[:4]) + ethutil.Config.Log.Debugf("Requesting blockchain %x...\n", p.ethereum.BlockChain().CurrentBlock.Hash()[:4]) + + msg = ethwire.NewMessage(ethwire.MsgGetTxsTy, []interface{}{}) + p.QueueMessage(msg) + ethutil.Config.Log.Debugln("Requested transactions") } } |