From 233f5200ef77ee77b4d33b5ff277d0e524b1fb4d Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 23 Jan 2014 22:32:50 +0100 Subject: [PATCH] Data send over the wire shouldn't be RLPed more then once --- ethereum.go | 5 +++-- peer.go | 15 +++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ethereum.go b/ethereum.go index b1b675c88..db66c3ce7 100644 --- a/ethereum.go +++ b/ethereum.go @@ -122,9 +122,10 @@ func (s *Ethereum) InboundPeers() []*Peer { return inboundPeers[:length] } -func (s *Ethereum) Broadcast(msgType ethwire.MsgType, data []byte) { +func (s *Ethereum) Broadcast(msgType ethwire.MsgType, data interface{}) { + msg := ethwire.NewMessage(msgType, data) eachPeer(s.peers, func(p *Peer, e *list.Element) { - p.QueueMessage(ethwire.NewMessage(msgType, data)) + p.QueueMessage(msg) }) } diff --git a/peer.go b/peer.go index d29481654..4f799e890 100644 --- a/peer.go +++ b/peer.go @@ -170,12 +170,15 @@ out: // Version message p.handleHandshake(msg) case ethwire.MsgBlockTy: - err := p.ethereum.BlockManager.ProcessBlock(ethchain.NewBlock(msg.Data)) - if err != nil { - log.Println(err) - } + /* + err := p.ethereum.BlockManager.ProcessBlock(ethchain.NewBlock(msg.Data)) + if err != nil { + log.Println(err) + } + */ case ethwire.MsgTxTy: - p.ethereum.TxPool.QueueTransaction(ethutil.NewTransactionFromData(msg.Data)) + //p.ethereum.TxPool.QueueTransaction(ethchain.NewTransactionFromData(msg.Data)) + p.ethereum.TxPool.QueueTransaction(ethchain.NewTransactionFromRlpValue(msg.Data.Get(0))) case ethwire.MsgInvTy: case ethwire.MsgGetPeersTy: p.requestedPeerList = true @@ -263,7 +266,7 @@ func (p *Peer) pushPeers() { } func (p *Peer) handleHandshake(msg *ethwire.Msg) { - c := ethutil.Conv(msg.Data) + c := msg.Data // [PROTOCOL_VERSION, NETWORK_ID, CLIENT_ID] if c.Get(2).AsUint() == p.ethereum.Nonce { //if msg.Nonce == p.ethereum.Nonce {