@@ -61,7 +61,7 @@ func newTestBlockPool(t *testing.T) (hashPool *test.TestHashPool, blockPool *Blo
6161}
6262
6363func (self * blockPoolTester ) Errorf (format string , params ... interface {}) {
64- fmt .Printf (format + "\n " , params ... )
64+ // fmt.Printf(format+"\n", params...)
6565 self .t .Errorf (format , params ... )
6666}
6767
@@ -73,7 +73,7 @@ func (self *blockPoolTester) hasBlock(block common.Hash) (ok bool) {
7373 indexes := self .hashPool .HashesToIndexes ([]common.Hash {block })
7474 i := indexes [0 ]
7575 _ , ok = self .blockChain [i ]
76- fmt .Printf ("has block %v (%x...): %v\n " , i , block [0 :4 ], ok )
76+ // fmt.Printf("has block %v (%x...): %v\n", i, block[0:4], ok)
7777 return
7878}
7979
@@ -95,7 +95,7 @@ func (self *blockPoolTester) insertChain(blocks types.Blocks) error {
9595 block .Td = big .NewInt (int64 (td ))
9696 _ , ok = self .blockChain [child ]
9797 if ok {
98- fmt .Printf ("block %v already in blockchain\n " , child )
98+ // fmt.Printf("block %v already in blockchain\n", child)
9999 continue // already in chain
100100 }
101101 parent = self .hashPool .HashesToIndexes ([]common.Hash {block .ParentHeaderHash })[0 ]
@@ -120,7 +120,6 @@ func (self *blockPoolTester) insertChain(blocks types.Blocks) error {
120120 }
121121 if ok {
122122 // accept any blocks if parent not in refBlockChain
123- fmt .Errorf ("blockchain insert %v -> %v\n " , parent , child )
124123 self .blockChain [parent ] = append (children , child )
125124 self .blockChain [child ] = nil
126125 }
@@ -136,12 +135,12 @@ func (self *blockPoolTester) verifyPoW(pblock pow.Block) bool {
136135func (self * blockPoolTester ) checkBlockChain (blockChain map [int ][]int ) {
137136 self .lock .RLock ()
138137 defer self .lock .RUnlock ()
139- for k , v := range self .blockChain {
140- fmt .Printf ("got: %v -> %v\n " , k , v )
141- }
142- for k , v := range blockChain {
143- fmt .Printf ("expected: %v -> %v\n " , k , v )
144- }
138+ // for k, v := range self.blockChain {
139+ // fmt.Printf("got: %v -> %v\n", k, v)
140+ // }
141+ // for k, v := range blockChain {
142+ // fmt.Printf("expected: %v -> %v\n", k, v)
143+ // }
145144 if len (blockChain ) != len (self .blockChain ) {
146145 self .Errorf ("blockchain incorrect (zlength differ)" )
147146 }
@@ -188,7 +187,7 @@ func (self *blockPoolTester) newPeer(id string, td int, cb int) *peerTester {
188187}
189188
190189func (self * peerTester ) Errorf (format string , params ... interface {}) {
191- fmt .Printf (format + "\n " , params ... )
190+ // fmt.Printf(format+"\n", params...)
192191 self .t .Errorf (format , params ... )
193192}
194193
@@ -232,7 +231,7 @@ func (self *peerTester) waitBlocksRequests(blocksRequest ...int) {
232231 for {
233232 self .lock .RLock ()
234233 r := self .blocksRequestsMap
235- fmt .Printf ("[%s] blocks request check %v (%v)\n " , self .id , rr , r )
234+ // fmt.Printf("[%s] blocks request check %v (%v)\n", self.id, rr, r)
236235 i := 0
237236 for i = 0 ; i < len (rr ); i ++ {
238237 _ , ok := r [rr [i ]]
@@ -263,7 +262,7 @@ func (self *peerTester) waitBlockHashesRequests(blocksHashesRequest int) {
263262 self .lock .RLock ()
264263 r := self .blockHashesRequests
265264 self .lock .RUnlock ()
266- fmt .Printf ("[%s] block hash request check %v (%v)\n " , self .id , rr , r )
265+ // fmt.Printf("[%s] block hash request check %v (%v)\n", self.id, rr, r)
267266 for ; i < len (r ); i ++ {
268267 if rr == r [i ] {
269268 return
@@ -294,14 +293,14 @@ func (self *peerTester) AddPeer() (best bool) {
294293
295294// peer sends blockhashes if and when gets a request
296295func (self * peerTester ) serveBlockHashes (indexes ... int ) {
297- fmt .Printf ("ready to serve block hashes %v\n " , indexes )
296+ // fmt.Printf("ready to serve block hashes %v\n", indexes)
298297
299298 self .waitBlockHashesRequests (indexes [0 ])
300299 self .sendBlockHashes (indexes ... )
301300}
302301
303302func (self * peerTester ) sendBlockHashes (indexes ... int ) {
304- fmt .Printf ("adding block hashes %v\n " , indexes )
303+ // fmt.Printf("adding block hashes %v\n", indexes)
305304 hashes := self .hashPool .IndexesToHashes (indexes )
306305 i := 1
307306 next := func () (hash common.Hash , ok bool ) {
@@ -318,16 +317,16 @@ func (self *peerTester) sendBlockHashes(indexes ...int) {
318317// peer sends blocks if and when there is a request
319318// (in the shared request store, not necessarily to a person)
320319func (self * peerTester ) serveBlocks (indexes ... int ) {
321- fmt .Printf ("ready to serve blocks %v\n " , indexes [1 :])
320+ // fmt.Printf("ready to serve blocks %v\n", indexes[1:])
322321 self .waitBlocksRequests (indexes [1 :]... )
323322 self .sendBlocks (indexes ... )
324323}
325324
326325func (self * peerTester ) sendBlocks (indexes ... int ) {
327- fmt .Printf ("adding blocks %v \n " , indexes )
326+ // fmt.Printf("adding blocks %v \n", indexes)
328327 hashes := self .hashPool .IndexesToHashes (indexes )
329328 for i := 1 ; i < len (hashes ); i ++ {
330- fmt .Printf ("adding block %v %x\n " , indexes [i ], hashes [i ][:4 ])
329+ // fmt.Printf("adding block %v %x\n", indexes[i], hashes[i][:4])
331330 self .blockPool .AddBlock (& types.Block {HeaderHash : hashes [i ], ParentHeaderHash : hashes [i - 1 ]}, self .id )
332331 }
333332}
@@ -337,7 +336,7 @@ func (self *peerTester) sendBlocks(indexes ...int) {
337336// records block hashes requests by the blockPool
338337func (self * peerTester ) requestBlockHashes (hash common.Hash ) error {
339338 indexes := self .hashPool .HashesToIndexes ([]common.Hash {hash })
340- fmt .Printf ("[%s] block hash request %v %x\n " , self .id , indexes [0 ], hash [:4 ])
339+ // fmt.Printf("[%s] block hash request %v %x\n", self.id, indexes[0], hash[:4])
341340 self .lock .Lock ()
342341 defer self .lock .Unlock ()
343342 self .blockHashesRequests = append (self .blockHashesRequests , indexes [0 ])
@@ -347,7 +346,7 @@ func (self *peerTester) requestBlockHashes(hash common.Hash) error {
347346// records block requests by the blockPool
348347func (self * peerTester ) requestBlocks (hashes []common.Hash ) error {
349348 indexes := self .hashPool .HashesToIndexes (hashes )
350- fmt .Printf ("blocks request %v %x...\n " , indexes , hashes [0 ][:4 ])
349+ // fmt.Printf("blocks request %v %x...\n", indexes, hashes[0][:4])
351350 self .bt .reqlock .Lock ()
352351 defer self .bt .reqlock .Unlock ()
353352 self .blocksRequests = append (self .blocksRequests , indexes )
@@ -360,9 +359,7 @@ func (self *peerTester) requestBlocks(hashes []common.Hash) error {
360359// records the error codes of all the peerErrors found the blockPool
361360func (self * peerTester ) peerError (err * errs.Error ) {
362361 self .peerErrors = append (self .peerErrors , err .Code )
363- fmt .Printf ("Error %v on peer %v\n " , err , self .id )
364362 if err .Fatal () {
365- fmt .Printf ("Error %v is fatal, removing peer %v\n " , err , self .id )
366363 self .blockPool .RemovePeer (self .id )
367364 }
368365}
0 commit comments