Skip to content

Commit 6ef706d

Browse files
committed
Remove logs
1 parent c71cfba commit 6ef706d

4 files changed

Lines changed: 17 additions & 13 deletions

File tree

sqlchain/chain.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ func (c *Chain) produceBlock(now time.Time) (err error) {
408408
// Advise new block to the other peers
409409
req := &MuxAdviseNewBlockReq{
410410
Envelope: proto.Envelope{
411-
// TODO(leventeliu): Add
411+
// TODO(leventeliu): Add fields.
412412
},
413413
DatabaseID: c.rt.databaseID,
414414
AdviseNewBlockReq: AdviseNewBlockReq{
@@ -421,7 +421,8 @@ func (c *Chain) produceBlock(now time.Time) (err error) {
421421
for _, p := range c.rt.peers.Servers {
422422
if p.ID != c.rt.server.ID {
423423
if err = c.cl.CallNode(p.ID, method, req, resp); err != nil {
424-
log.Errorf("Failed to advise now block to node %s", string(p.ID))
424+
log.WithField("node", string(p.ID)).WithError(err).Errorln(
425+
"Failed to advise new block")
425426
}
426427
}
427428
}
@@ -438,7 +439,8 @@ func (c *Chain) runCurrentTurn(now time.Time) {
438439
}
439440

440441
if err := c.produceBlock(now); err != nil {
441-
log.Errorf("Failed to produce block: err = %v, now = %s", err, now.Format(time.RFC3339Nano))
442+
log.WithField("now", now.Format(time.RFC3339Nano)).WithError(err).Errorln(
443+
"Failed to produce block")
442444
}
443445
}
444446

@@ -493,7 +495,6 @@ func (c *Chain) Start() (err error) {
493495
// Stop stops the main process of the sql-chain.
494496
func (c *Chain) Stop() (err error) {
495497
// Stop main process
496-
log.Debugf("chain stopping: %p", c)
497498
c.rt.stop()
498499

499500
// Close database file

sqlchain/chain_test.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,14 @@ func TestMultiChain(t *testing.T) {
317317
t.Fatalf("Error occurred: %v", err)
318318
}
319319

320-
// Create some random clients to push new queries
320+
defer func(c *Chain) {
321+
// Stop chain main process
322+
c.Stop()
323+
}(chains[i])
324+
}
325+
326+
// Create some random clients to push new queries
327+
for i := range chains {
321328
sC := make(chan struct{})
322329
wg := &sync.WaitGroup{}
323330
wk := &nodeProfile{
@@ -326,7 +333,7 @@ func TestMultiChain(t *testing.T) {
326333
PublicKey: testPubKey,
327334
}
328335

329-
for x := 0; x < testClientNumberPerChain; x++ {
336+
for j := 0; j < testClientNumberPerChain; j++ {
330337
cli, err := newRandomNode()
331338

332339
if err != nil {
@@ -356,13 +363,11 @@ func TestMultiChain(t *testing.T) {
356363
}(chains[i], cli)
357364
}
358365

359-
defer func(c *Chain) {
366+
defer func() {
360367
// Quit client goroutines
361368
close(sC)
362369
wg.Wait()
363-
// Stop chain main process
364-
c.Stop()
365-
}(chains[i])
370+
}()
366371
}
367372

368373
time.Sleep(time.Duration(testPeriodNumber) * testPeriod)

sqlchain/errors.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,5 @@ var (
6969
ErrCorruptedIndex = errors.New("corrupted index item")
7070

7171
// ErrUnknownMuxRequest indicates that the a multiplexing request endpoint is not found.
72-
ErrUnknownMuxRequest = errors.New("known multiplexing request")
72+
ErrUnknownMuxRequest = errors.New("unknown multiplexing request")
7373
)

sqlchain/xxx_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,6 @@ func registerNodesWithPublicKey(pub *asymmetric.PublicKey, diff int, num int) (
310310
}()
311311
n := <-nCh
312312
nis[i] = n
313-
log.Debugf("Get new nonce: %+v", n)
314313
next = n.Nonce
315314
next.Inc()
316315

@@ -462,7 +461,6 @@ func createTestPeers(num int) (nis []cpuminer.NonceInfo, p *kayak.Peers, err err
462461
ID: proto.NodeID(nis[i].Hash.String()),
463462
PubKey: pub,
464463
}
465-
log.Debugf("Created new node: %+v", s[i])
466464
}
467465

468466
p = &kayak.Peers{

0 commit comments

Comments
 (0)