aboutsummaryrefslogtreecommitdiffstats
path: root/whisper/whisperv5/whisper.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-02-22 20:10:07 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-02-23 18:16:44 +0800
commitd4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851 (patch)
tree17c93170551d3eeabe2935de1765f157007f0dc2 /whisper/whisperv5/whisper.go
parent47af53f9aaf9aa7b12cd976eb150ccf3d64da6fd (diff)
downloaddexon-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar
dexon-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar.gz
dexon-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar.bz2
dexon-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar.lz
dexon-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar.xz
dexon-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar.zst
dexon-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.zip
all: blidly swap out glog to our log15, logs need rework
Diffstat (limited to 'whisper/whisperv5/whisper.go')
-rw-r--r--whisper/whisperv5/whisper.go27
1 files changed, 13 insertions, 14 deletions
diff --git a/whisper/whisperv5/whisper.go b/whisper/whisperv5/whisper.go
index 2a6ff5f40..558e2909f 100644
--- a/whisper/whisperv5/whisper.go
+++ b/whisper/whisperv5/whisper.go
@@ -28,8 +28,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/logger"
- "github.com/ethereum/go-ethereum/logger/glog"
+ "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/rpc"
"golang.org/x/crypto/pbkdf2"
@@ -294,7 +293,7 @@ func (w *Whisper) Send(envelope *Envelope) error {
// Start implements node.Service, starting the background data propagation thread
// of the Whisper protocol.
func (w *Whisper) Start(*p2p.Server) error {
- glog.V(logger.Info).Infoln("Whisper started")
+ log.Info(fmt.Sprint("Whisper started"))
go w.update()
numCPU := runtime.NumCPU()
@@ -309,7 +308,7 @@ func (w *Whisper) Start(*p2p.Server) error {
// of the Whisper protocol.
func (w *Whisper) Stop() error {
close(w.quit)
- glog.V(logger.Info).Infoln("Whisper stopped")
+ log.Info(fmt.Sprint("Whisper stopped"))
return nil
}
@@ -351,18 +350,18 @@ func (wh *Whisper) runMessageLoop(p *Peer, rw p2p.MsgReadWriter) error {
switch packet.Code {
case statusCode:
// this should not happen, but no need to panic; just ignore this message.
- glog.V(logger.Warn).Infof("%v: unxepected status message received", p.peer)
+ log.Warn(fmt.Sprintf("%v: unxepected status message received", p.peer))
case messagesCode:
// decode the contained envelopes
var envelopes []*Envelope
if err := packet.Decode(&envelopes); err != nil {
- glog.V(logger.Warn).Infof("%v: failed to decode envelope: [%v], peer will be disconnected", p.peer, err)
+ log.Warn(fmt.Sprintf("%v: failed to decode envelope: [%v], peer will be disconnected", p.peer, err))
return fmt.Errorf("garbage received")
}
// inject all envelopes into the internal pool
for _, envelope := range envelopes {
if err := wh.add(envelope); err != nil {
- glog.V(logger.Warn).Infof("%v: bad envelope received: [%v], peer will be disconnected", p.peer, err)
+ log.Warn(fmt.Sprintf("%v: bad envelope received: [%v], peer will be disconnected", p.peer, err))
return fmt.Errorf("invalid envelope")
}
p.mark(envelope)
@@ -375,7 +374,7 @@ func (wh *Whisper) runMessageLoop(p *Peer, rw p2p.MsgReadWriter) error {
if p.trusted {
var envelope Envelope
if err := packet.Decode(&envelope); err != nil {
- glog.V(logger.Warn).Infof("%v: failed to decode direct message: [%v], peer will be disconnected", p.peer, err)
+ log.Warn(fmt.Sprintf("%v: failed to decode direct message: [%v], peer will be disconnected", p.peer, err))
return fmt.Errorf("garbage received (directMessage)")
}
wh.postEvent(&envelope, true)
@@ -385,7 +384,7 @@ func (wh *Whisper) runMessageLoop(p *Peer, rw p2p.MsgReadWriter) error {
if wh.mailServer != nil {
var request Envelope
if err := packet.Decode(&request); err != nil {
- glog.V(logger.Warn).Infof("%v: failed to decode p2p request message: [%v], peer will be disconnected", p.peer, err)
+ log.Warn(fmt.Sprintf("%v: failed to decode p2p request message: [%v], peer will be disconnected", p.peer, err))
return fmt.Errorf("garbage received (p2p request)")
}
wh.mailServer.DeliverMail(p, &request)
@@ -419,7 +418,7 @@ func (wh *Whisper) add(envelope *Envelope) error {
if envelope.Expiry+SynchAllowance*2 < now {
return fmt.Errorf("very old message")
} else {
- glog.V(logger.Debug).Infof("expired envelope dropped [%x]", envelope.Hash())
+ log.Debug(fmt.Sprintf("expired envelope dropped [%x]", envelope.Hash()))
return nil // drop envelope without error
}
}
@@ -443,7 +442,7 @@ func (wh *Whisper) add(envelope *Envelope) error {
}
if envelope.PoW() < MinimumPoW && !wh.test {
- glog.V(logger.Debug).Infof("envelope with low PoW dropped: %f [%x]", envelope.PoW(), envelope.Hash())
+ log.Debug(fmt.Sprintf("envelope with low PoW dropped: %f [%x]", envelope.PoW(), envelope.Hash()))
return nil // drop envelope without error
}
@@ -463,9 +462,9 @@ func (wh *Whisper) add(envelope *Envelope) error {
wh.poolMu.Unlock()
if alreadyCached {
- glog.V(logger.Detail).Infof("whisper envelope already cached [%x]\n", envelope.Hash())
+ log.Trace(fmt.Sprintf("whisper envelope already cached [%x]\n", envelope.Hash()))
} else {
- glog.V(logger.Detail).Infof("cached whisper envelope [%x]: %v\n", envelope.Hash(), envelope)
+ log.Trace(fmt.Sprintf("cached whisper envelope [%x]: %v\n", envelope.Hash(), envelope))
wh.postEvent(envelope, false) // notify the local node about the new message
if wh.mailServer != nil {
wh.mailServer.Archive(envelope)
@@ -496,7 +495,7 @@ func (w *Whisper) checkOverflow() {
if queueSize == messageQueueLimit {
if !w.overflow {
w.overflow = true
- glog.V(logger.Warn).Infoln("message queue overflow")
+ log.Warn(fmt.Sprint("message queue overflow"))
}
} else if queueSize <= messageQueueLimit/2 {
if w.overflow {