@@ -52,6 +52,8 @@ func copyBlock(block *types.Block) *types.Block {
52
52
return createBlock (int (block .Number ().Int64 ()), block .ParentHeaderHash , block .HeaderHash )
53
53
}
54
54
55
+ // createBlocksFromHashes assembles a collection of blocks, each having a correct
56
+ // place in the given hash chain.
55
57
func createBlocksFromHashes (hashes []common.Hash ) map [common.Hash ]* types.Block {
56
58
blocks := make (map [common.Hash ]* types.Block )
57
59
for i := 0 ; i < len (hashes ); i ++ {
@@ -64,6 +66,7 @@ func createBlocksFromHashes(hashes []common.Hash) map[common.Hash]*types.Block {
64
66
return blocks
65
67
}
66
68
69
+ // downloadTester is a test simulator for mocking out local block chain.
67
70
type downloadTester struct {
68
71
downloader * Downloader
69
72
@@ -75,16 +78,15 @@ type downloadTester struct {
75
78
maxHashFetch int // Overrides the maximum number of retrieved hashes
76
79
}
77
80
81
+ // newTester creates a new downloader test mocker.
78
82
func newTester () * downloadTester {
79
83
tester := & downloadTester {
80
84
ownHashes : []common.Hash {knownHash },
81
85
ownBlocks : map [common.Hash ]* types.Block {knownHash : genesis },
82
86
peerHashes : make (map [string ][]common.Hash ),
83
87
peerBlocks : make (map [string ]map [common.Hash ]* types.Block ),
84
88
}
85
- var mux event.TypeMux
86
- downloader := New (& mux , tester .hasBlock , tester .getBlock , tester .insertChain , tester .dropPeer )
87
- tester .downloader = downloader
89
+ tester .downloader = New (new (event.TypeMux ), tester .hasBlock , tester .getBlock , tester .insertChain , tester .dropPeer )
88
90
89
91
return tester
90
92
}
0 commit comments