From a1b6a9ac29d0aa8d29a2c0535bafdb5fe4d4830b Mon Sep 17 00:00:00 2001 From: obscuren <geffobscura@gmail.com> Date: Tue, 18 Nov 2014 16:58:22 +0100 Subject: Begin of moving objects to types package * Block(s) * Transaction(s) --- peer.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'peer.go') diff --git a/peer.go b/peer.go index b54978854..fa73da21a 100644 --- a/peer.go +++ b/peer.go @@ -11,8 +11,7 @@ import ( "strings" "sync/atomic" "time" - - "github.com/ethereum/go-ethereum/chain" + "github.com/ethereum/go-ethereum/chain/types" "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/wire" @@ -155,7 +154,7 @@ type Peer struct { pingTime time.Duration pingStartTime time.Time - lastRequestedBlock *chain.Block + lastRequestedBlock *types.Block protocolCaps *ethutil.Value } @@ -429,7 +428,7 @@ 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++ { - tx := chain.NewTransactionFromValue(msg.Data.Get(i)) + tx := types.NewTransactionFromValue(msg.Data.Get(i)) p.ethereum.TxPool().QueueTransaction(tx) } case wire.MsgGetPeersTy: @@ -535,7 +534,7 @@ func (p *Peer) HandleInbound() { it := msg.Data.NewIterator() for it.Next() { - block := chain.NewBlockFromRlpValue(it.Value()) + block := types.NewBlockFromRlpValue(it.Value()) blockPool.Add(block, p) p.lastBlockReceived = time.Now() @@ -543,7 +542,7 @@ func (p *Peer) HandleInbound() { case wire.MsgNewBlockTy: var ( blockPool = p.ethereum.blockPool - block = chain.NewBlockFromRlpValue(msg.Data.Get(0)) + block = types.NewBlockFromRlpValue(msg.Data.Get(0)) td = msg.Data.Get(1).BigInt() ) -- cgit v1.2.3 From f8d0cd9906a1ec4a4a1e95868a279312363f8b49 Mon Sep 17 00:00:00 2001 From: obscuren <geffobscura@gmail.com> Date: Tue, 18 Nov 2014 19:44:17 +0100 Subject: Added a callback mechanism to chain adding. Not sure if this is the right approach. Why? BlockChain shouldn't need the "Ethereum" object. BlockChain shouldn't need to worry about notifying listeners or message propagation. --- peer.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'peer.go') diff --git a/peer.go b/peer.go index fa73da21a..ff3593604 100644 --- a/peer.go +++ b/peer.go @@ -11,6 +11,7 @@ import ( "strings" "sync/atomic" "time" + "github.com/ethereum/go-ethereum/chain/types" "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/logger" @@ -23,7 +24,7 @@ const ( // The size of the output buffer for writing messages outputBufferSize = 50 // Current protocol version - ProtocolVersion = 42 + ProtocolVersion = 43 // Current P2P version P2PVersion = 2 // Ethereum network version -- cgit v1.2.3