diff options
author | obscuren <geffobscura@gmail.com> | 2014-09-15 21:42:12 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-09-15 21:42:12 +0800 |
commit | 33a0dec8a157b9687ca6038f4deb011f3f1f7bdc (patch) | |
tree | 197b792e06dc3952df93957a39fdf6e44582ac96 /peer.go | |
parent | 2f614900e82036e3e8f6f6a714efc43e09aca830 (diff) | |
download | dexon-33a0dec8a157b9687ca6038f4deb011f3f1f7bdc.tar dexon-33a0dec8a157b9687ca6038f4deb011f3f1f7bdc.tar.gz dexon-33a0dec8a157b9687ca6038f4deb011f3f1f7bdc.tar.bz2 dexon-33a0dec8a157b9687ca6038f4deb011f3f1f7bdc.tar.lz dexon-33a0dec8a157b9687ca6038f4deb011f3f1f7bdc.tar.xz dexon-33a0dec8a157b9687ca6038f4deb011f3f1f7bdc.tar.zst dexon-33a0dec8a157b9687ca6038f4deb011f3f1f7bdc.zip |
Improved catching up and refactored
Diffstat (limited to 'peer.go')
-rw-r--r-- | peer.go | 46 |
1 files changed, 20 insertions, 26 deletions
@@ -24,7 +24,7 @@ const ( // The size of the output buffer for writing messages outputBufferSize = 50 // Current protocol version - ProtocolVersion = 28 + ProtocolVersion = 32 // Current P2P version P2PVersion = 0 // Interval for ping/pong message @@ -276,13 +276,15 @@ func (p *Peer) writeMessage(msg *ethwire.Msg) { return } } else { - if !p.statusKnown { - switch msg.Type { - case ethwire.MsgStatusTy: // Ok - default: // Anything but ack is allowed - return + /* + if !p.statusKnown { + switch msg.Type { + case ethwire.MsgStatusTy: // Ok + default: // Anything but ack is allowed + return + } } - } + */ } peerlogger.DebugDetailf("(%v) <= %v %v\n", p.conn.RemoteAddr(), msg.Type, msg.Data) @@ -488,19 +490,25 @@ func (p *Peer) HandleInbound() { it := msg.Data.NewIterator() for it.Next() { block := ethchain.NewBlockFromRlpValue(it.Value()) + //fmt.Printf("%v %x - %x\n", block.Number, block.Hash()[0:4], block.PrevHash[0:4]) blockPool.SetBlock(block, p) p.lastBlockReceived = time.Now() } - linked := blockPool.CheckLinkAndProcess(func(block *ethchain.Block) { - p.ethereum.StateManager().Process(block, false) + blockPool.CheckLinkAndProcess(func(block *ethchain.Block) { + err := p.ethereum.StateManager().Process(block, false) + if err != nil { + peerlogger.Infoln(err) + } }) - if !linked { - p.FetchBlocks() - } + /* + if !linked { + p.FetchBlocks() + } + */ } } } @@ -596,20 +604,6 @@ func (p *Peer) Stop() { p.ethereum.RemovePeer(p) } -/* -func (p *Peer) pushHandshake() error { - pubkey := p.ethereum.KeyManager().PublicKey() - msg := ethwire.NewMessage(ethwire.MsgHandshakeTy, []interface{}{ - uint32(ProtocolVersion), uint32(0), []byte(p.version), byte(p.caps), p.port, pubkey[1:], - p.ethereum.BlockChain().TD.Uint64(), p.ethereum.BlockChain().CurrentBlock.Hash(), - }) - - p.QueueMessage(msg) - - return nil -} -*/ - func (p *Peer) peersMessage() *ethwire.Msg { outPeers := make([]interface{}, len(p.ethereum.InOutPeers())) // Serialise each peer |