Skip to content

Commit 8767179

Browse files
committed
reduce logging output
1 parent 63cae9b commit 8767179

3 files changed

Lines changed: 22 additions & 25 deletions

File tree

‎blockpool/blockpool_util_test.go‎

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func newTestBlockPool(t *testing.T) (hashPool *test.TestHashPool, blockPool *Blo
6161
}
6262

6363
func (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 {
136135
func (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

190189
func (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
296295
func (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

303302
func (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)
320319
func (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

326325
func (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
338337
func (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
348347
func (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
361360
func (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
}

‎blockpool/status_test.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package blockpool
22

33
import (
4-
"fmt"
4+
// "fmt"
55
"testing"
66
"time"
77

@@ -53,7 +53,7 @@ func checkStatus(t *testing.T, bp *BlockPool, syncing bool, expected []int) (err
5353
continue //hack
5454
}
5555
err = test.CheckInt(statusFields[i], got[i], v, t)
56-
fmt.Printf("%v: %v (%v)\n", statusFields[i], got[i], v)
56+
// fmt.Printf("%v: %v (%v)\n", statusFields[i], got[i], v)
5757
if err != nil {
5858
return err
5959
}

‎blockpool/test/logger.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func TestFunc(t *testing.T) {
1919
*/
2020
func LogInit() {
2121
once.Do(func() {
22-
var logsys = logger.NewStdLogSystem(os.Stdout, log.LstdFlags, logger.LogLevel(logger.DebugDetailLevel))
22+
var logsys = logger.NewStdLogSystem(os.Stdout, log.LstdFlags, logger.LogLevel(logger.WarnLevel))
2323
logger.AddLogSystem(logsys)
2424
})
2525
}

0 commit comments

Comments
 (0)