diff options
author | Péter Szilágyi <peterke@gmail.com> | 2015-09-21 20:36:29 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2015-10-19 15:03:09 +0800 |
commit | c33cc382b3561ca91871111933f81653bfd8532f (patch) | |
tree | 0749dd4e4ebd66efe1272ee984e4dda06b4462be /eth | |
parent | 92f9a3e5fa29e0f05c81b348b87cab4f7a94f0c8 (diff) | |
download | go-tangerine-c33cc382b3561ca91871111933f81653bfd8532f.tar go-tangerine-c33cc382b3561ca91871111933f81653bfd8532f.tar.gz go-tangerine-c33cc382b3561ca91871111933f81653bfd8532f.tar.bz2 go-tangerine-c33cc382b3561ca91871111933f81653bfd8532f.tar.lz go-tangerine-c33cc382b3561ca91871111933f81653bfd8532f.tar.xz go-tangerine-c33cc382b3561ca91871111933f81653bfd8532f.tar.zst go-tangerine-c33cc382b3561ca91871111933f81653bfd8532f.zip |
core: support inserting pure header chains
Diffstat (limited to 'eth')
-rw-r--r-- | eth/backend.go | 2 | ||||
-rw-r--r-- | eth/handler.go | 18 | ||||
-rw-r--r-- | eth/sync.go | 3 |
3 files changed, 5 insertions, 18 deletions
diff --git a/eth/backend.go b/eth/backend.go index 04dd3767a..f4acc76cb 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -464,7 +464,7 @@ func (s *Ethereum) NodeInfo() *NodeInfo { DiscPort: int(node.UDP), TCPPort: int(node.TCP), ListenAddr: s.net.ListenAddr, - Td: s.BlockChain().Td().String(), + Td: s.BlockChain().GetTd(s.BlockChain().CurrentBlock().Hash()).String(), } } diff --git a/eth/handler.go b/eth/handler.go index 5716350af..021be1024 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -589,15 +589,6 @@ func (pm *ProtocolManager) handleMsg(p *peer) error { } request.Block.ReceivedAt = msg.ReceivedAt - // Mark the block's arrival for whatever reason - _, chainHead, _ := pm.blockchain.Status() - jsonlogger.LogJson(&logger.EthChainReceivedNewBlock{ - BlockHash: request.Block.Hash().Hex(), - BlockNumber: request.Block.Number(), - ChainHeadHash: chainHead.Hex(), - BlockPrevHash: request.Block.ParentHash().Hex(), - RemoteId: p.ID().String(), - }) // Mark the peer as owning the block and schedule it for import p.MarkBlock(request.Block.Hash()) p.SetHead(request.Block.Hash()) @@ -607,7 +598,8 @@ func (pm *ProtocolManager) handleMsg(p *peer) error { // Update the peers total difficulty if needed, schedule a download if gapped if request.TD.Cmp(p.Td()) > 0 { p.SetTd(request.TD) - if request.TD.Cmp(new(big.Int).Add(pm.blockchain.Td(), request.Block.Difficulty())) > 0 { + td := pm.blockchain.GetTd(pm.blockchain.CurrentBlock().Hash()) + if request.TD.Cmp(new(big.Int).Add(td, request.Block.Difficulty())) > 0 { go pm.synchronise(p) } } @@ -624,12 +616,6 @@ func (pm *ProtocolManager) handleMsg(p *peer) error { return errResp(ErrDecode, "transaction %d is nil", i) } p.MarkTransaction(tx.Hash()) - - // Log it's arrival for later analysis - jsonlogger.LogJson(&logger.EthTxReceived{ - TxHash: tx.Hash().Hex(), - RemoteId: p.ID().String(), - }) } pm.txpool.AddTransactions(txs) diff --git a/eth/sync.go b/eth/sync.go index 5a2031c68..6295083e2 100644 --- a/eth/sync.go +++ b/eth/sync.go @@ -160,7 +160,8 @@ func (pm *ProtocolManager) synchronise(peer *peer) { return } // Make sure the peer's TD is higher than our own. If not drop. - if peer.Td().Cmp(pm.blockchain.Td()) <= 0 { + td := pm.blockchain.GetTd(pm.blockchain.CurrentBlock().Hash()) + if peer.Td().Cmp(td) <= 0 { return } // Otherwise try to sync with the downloader |