From 391e89d70a43b4a2153db8acac9a6af7a4f76adf Mon Sep 17 00:00:00 2001 From: zelig Date: Thu, 19 Mar 2015 22:53:15 +0000 Subject: use own total difficulty to limit best peer - update blockpool td by subscribing to ChainHeadEvent - if ahead of best peer, demote it - addPeer now take own td as current td - removePeer now take own td as current td - add relevant tests to peers_test - eth: backend now calls blockpool with eth.eventMux and chainManager.Td --- blockpool/blockpool_util_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'blockpool/blockpool_util_test.go') diff --git a/blockpool/blockpool_util_test.go b/blockpool/blockpool_util_test.go index 5ba92066c..a17bc584e 100644 --- a/blockpool/blockpool_util_test.go +++ b/blockpool/blockpool_util_test.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/errs" + "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/pow" ) @@ -38,6 +39,7 @@ type blockPoolTester struct { blockChain blockChain blockPool *BlockPool t *testing.T + chainEvents *event.TypeMux } func newTestBlockPool(t *testing.T) (hashPool *test.TestHashPool, blockPool *BlockPool, b *blockPoolTester) { @@ -48,8 +50,9 @@ func newTestBlockPool(t *testing.T) (hashPool *test.TestHashPool, blockPool *Blo blockChain: make(blockChain), refBlockChain: make(blockChain), blocksRequestsMap: make(map[int]bool), + chainEvents: &event.TypeMux{}, } - b.blockPool = New(b.hasBlock, b.insertChain, b.verifyPoW) + b.blockPool = New(b.hasBlock, b.insertChain, b.verifyPoW, b.chainEvents, common.Big0) blockPool = b.blockPool blockPool.Config.BlockHashesRequestInterval = testBlockHashesRequestInterval blockPool.Config.BlocksRequestInterval = testBlocksRequestInterval -- cgit v1.2.3