diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-02-22 20:10:07 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-02-23 18:16:44 +0800 |
commit | d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851 (patch) | |
tree | 17c93170551d3eeabe2935de1765f157007f0dc2 /whisper/whisperv2 | |
parent | 47af53f9aaf9aa7b12cd976eb150ccf3d64da6fd (diff) | |
download | dexon-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/whisperv2')
-rw-r--r-- | whisper/whisperv2/message.go | 6 | ||||
-rw-r--r-- | whisper/whisperv2/peer.go | 11 | ||||
-rw-r--r-- | whisper/whisperv2/whisper.go | 16 |
3 files changed, 16 insertions, 17 deletions
diff --git a/whisper/whisperv2/message.go b/whisper/whisperv2/message.go index e55544ffc..66648c3be 100644 --- a/whisper/whisperv2/message.go +++ b/whisper/whisperv2/message.go @@ -22,14 +22,14 @@ package whisperv2 import ( "crypto/ecdsa" crand "crypto/rand" + "fmt" "math/rand" "time" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto/ecies" - "github.com/ethereum/go-ethereum/logger" - "github.com/ethereum/go-ethereum/logger/glog" + "github.com/ethereum/go-ethereum/log" ) // Message represents an end-user data packet to transmit through the Whisper @@ -125,7 +125,7 @@ func (self *Message) Recover() *ecdsa.PublicKey { // Otherwise try and recover the signature pub, err := crypto.SigToPub(self.hash(), self.Signature) if err != nil { - glog.V(logger.Error).Infof("Could not get public key from signature: %v", err) + log.Error(fmt.Sprintf("Could not get public key from signature: %v", err)) return nil } return pub diff --git a/whisper/whisperv2/peer.go b/whisper/whisperv2/peer.go index f09ce3523..71798408b 100644 --- a/whisper/whisperv2/peer.go +++ b/whisper/whisperv2/peer.go @@ -21,8 +21,7 @@ import ( "time" "github.com/ethereum/go-ethereum/common" - "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/rlp" "gopkg.in/fatih/set.v0" @@ -54,13 +53,13 @@ func newPeer(host *Whisper, remote *p2p.Peer, rw p2p.MsgReadWriter) *peer { // into the network. func (self *peer) start() { go self.update() - glog.V(logger.Debug).Infof("%v: whisper started", self.peer) + log.Debug(fmt.Sprintf("%v: whisper started", self.peer)) } // stop terminates the peer updater, stopping message forwarding to it. func (self *peer) stop() { close(self.quit) - glog.V(logger.Debug).Infof("%v: whisper stopped", self.peer) + log.Debug(fmt.Sprintf("%v: whisper stopped", self.peer)) } // handshake sends the protocol initiation status message to the remote peer and @@ -112,7 +111,7 @@ func (self *peer) update() { case <-transmit.C: if err := self.broadcast(); err != nil { - glog.V(logger.Info).Infof("%v: broadcast failed: %v", self.peer, err) + log.Info(fmt.Sprintf("%v: broadcast failed: %v", self.peer, err)) return } @@ -170,6 +169,6 @@ func (self *peer) broadcast() error { if err := p2p.Send(self.ws, messagesCode, transmit); err != nil { return err } - glog.V(logger.Detail).Infoln(self.peer, "broadcasted", len(transmit), "message(s)") + log.Trace(fmt.Sprint(self.peer, "broadcasted", len(transmit), "message(s)")) return nil } diff --git a/whisper/whisperv2/whisper.go b/whisper/whisperv2/whisper.go index d9054959e..1d7c21bd1 100644 --- a/whisper/whisperv2/whisper.go +++ b/whisper/whisperv2/whisper.go @@ -18,6 +18,7 @@ package whisperv2 import ( "crypto/ecdsa" + "fmt" "sync" "time" @@ -25,8 +26,7 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto/ecies" "github.com/ethereum/go-ethereum/event/filter" - "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" @@ -173,7 +173,7 @@ func (self *Whisper) Send(envelope *Envelope) error { // Start implements node.Service, starting the background data propagation thread // of the Whisper protocol. func (self *Whisper) Start(*p2p.Server) error { - glog.V(logger.Info).Infoln("Whisper started") + log.Info(fmt.Sprint("Whisper started")) go self.update() return nil } @@ -182,7 +182,7 @@ func (self *Whisper) Start(*p2p.Server) error { // of the Whisper protocol. func (self *Whisper) Stop() error { close(self.quit) - glog.V(logger.Info).Infoln("Whisper stopped") + log.Info(fmt.Sprint("Whisper stopped")) return nil } @@ -233,14 +233,14 @@ func (self *Whisper) handlePeer(peer *p2p.Peer, rw p2p.MsgReadWriter) error { } var envelopes []*Envelope if err := packet.Decode(&envelopes); err != nil { - glog.V(logger.Info).Infof("%v: failed to decode envelope: %v", peer, err) + log.Info(fmt.Sprintf("%v: failed to decode envelope: %v", peer, err)) continue } // Inject all envelopes into the internal pool for _, envelope := range envelopes { if err := self.add(envelope); err != nil { // TODO Punish peer here. Invalid envelope. - glog.V(logger.Debug).Infof("%v: failed to pool envelope: %v", peer, err) + log.Debug(fmt.Sprintf("%v: failed to pool envelope: %v", peer, err)) } whisperPeer.mark(envelope) } @@ -262,7 +262,7 @@ func (self *Whisper) add(envelope *Envelope) error { // Insert the message into the tracked pool hash := envelope.Hash() if _, ok := self.messages[hash]; ok { - glog.V(logger.Detail).Infof("whisper envelope already cached: %x\n", envelope) + log.Trace(fmt.Sprintf("whisper envelope already cached: %x\n", envelope)) return nil } self.messages[hash] = envelope @@ -277,7 +277,7 @@ func (self *Whisper) add(envelope *Envelope) error { // Notify the local node of a message arrival go self.postEvent(envelope) } - glog.V(logger.Detail).Infof("cached whisper envelope %x\n", envelope) + log.Trace(fmt.Sprintf("cached whisper envelope %x\n", envelope)) return nil } |