whisper: refactored parameters

This commit is contained in:
Vlad 2016-12-19 13:47:44 +01:00
parent 8e720f2123
commit b64ca3ea89
2 changed files with 10 additions and 9 deletions

View file

@ -21,6 +21,7 @@ import (
"sync" "sync"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog" "github.com/ethereum/go-ethereum/logger/glog"
) )
@ -81,7 +82,7 @@ func (fs *Filters) NotifyWatchers(env *Envelope, p2pMessage bool) {
var msg *ReceivedMessage var msg *ReceivedMessage
for j, watcher := range fs.watchers { for j, watcher := range fs.watchers {
if p2pMessage && !watcher.AcceptP2P { if p2pMessage && !watcher.AcceptP2P {
glog.V(9).Infof("msg [%x], filter [%d]: p2p messages are not allowed \n", env.Hash(), j) glog.V(logger.Detail).Infof("msg [%x], filter [%d]: p2p messages are not allowed \n", env.Hash(), j)
continue continue
} }
@ -93,10 +94,10 @@ func (fs *Filters) NotifyWatchers(env *Envelope, p2pMessage bool) {
if match { if match {
msg = env.Open(watcher) msg = env.Open(watcher)
if msg == nil { if msg == nil {
glog.V(9).Infof("msg [%x], filter [%d]: failed to open \n", env.Hash(), j) glog.V(logger.Detail).Infof("msg [%x], filter [%d]: failed to open \n", env.Hash(), j)
} }
} else { } else {
glog.V(9).Infof("msg [%x], filter [%d]: does not match \n", env.Hash(), j) glog.V(logger.Detail).Infof("msg [%x], filter [%d]: does not match \n", env.Hash(), j)
} }
} }

View file

@ -363,7 +363,7 @@ func (wh *Whisper) runMessageLoop(p *Peer, rw p2p.MsgReadWriter) error {
return fmt.Errorf("garbage received (directMessage)") return fmt.Errorf("garbage received (directMessage)")
} }
for _, envelope := range envelopes { for _, envelope := range envelopes {
wh.postEvent(envelope, p2pCode) wh.postEvent(envelope, true)
} }
} }
case p2pRequestCode: case p2pRequestCode:
@ -453,22 +453,22 @@ func (wh *Whisper) add(envelope *Envelope) error {
glog.V(logger.Detail).Infof("whisper envelope already cached [%x]\n", envelope.Hash()) glog.V(logger.Detail).Infof("whisper envelope already cached [%x]\n", envelope.Hash())
} else { } else {
glog.V(logger.Detail).Infof("cached whisper envelope [%x]: %v\n", envelope.Hash(), envelope) glog.V(logger.Detail).Infof("cached whisper envelope [%x]: %v\n", envelope.Hash(), envelope)
wh.postEvent(envelope, messagesCode) // notify the local node about the new message wh.postEvent(envelope, false) // notify the local node about the new message
} }
return nil return nil
} }
// postEvent queues the message for further processing. // postEvent queues the message for further processing.
func (w *Whisper) postEvent(envelope *Envelope, messageCode uint64) { func (w *Whisper) postEvent(envelope *Envelope, isP2P bool) {
// if the version of incoming message is higher than // if the version of incoming message is higher than
// currently supported version, we can not decrypt it, // currently supported version, we can not decrypt it,
// and therefore just ignore this message // and therefore just ignore this message
if envelope.Ver() <= EnvelopeVersion { if envelope.Ver() <= EnvelopeVersion {
if messagesCode == messageCode { if isP2P {
w.p2pMsgQueue <- envelope
} else {
w.checkOverflow() w.checkOverflow()
w.messageQueue <- envelope w.messageQueue <- envelope
} else {
w.p2pMsgQueue <- envelope
} }
} }
} }