mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 09:53:48 +00:00
swarm/pss: Move rawtopic test before decryption attempt
This commit is contained in:
parent
538c31101f
commit
3e10f30bca
1 changed files with 8 additions and 17 deletions
|
|
@ -361,6 +361,10 @@ func (self *Pss) process(pssmsg *PssMsg) bool {
|
||||||
|
|
||||||
envelope := pssmsg.Payload
|
envelope := pssmsg.Payload
|
||||||
psstopic := Topic(envelope.Topic)
|
psstopic := Topic(envelope.Topic)
|
||||||
|
if self.allowRaw && psstopic == rawTopic {
|
||||||
|
self.executeHandlers(rawTopic, envelope.Data, nil, false, "")
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
if len(envelope.AESNonce) > 0 { // detect symkey msg according to whisperv5/envelope.go:OpenSymmetric
|
if len(envelope.AESNonce) > 0 { // detect symkey msg according to whisperv5/envelope.go:OpenSymmetric
|
||||||
keyFunc = self.processSym
|
keyFunc = self.processSym
|
||||||
|
|
@ -370,9 +374,6 @@ func (self *Pss) process(pssmsg *PssMsg) bool {
|
||||||
}
|
}
|
||||||
recvmsg, keyid, from, err = keyFunc(envelope)
|
recvmsg, keyid, from, err = keyFunc(envelope)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if self.allowRaw {
|
|
||||||
self.executeHandlers(rawTopic, envelope.Data, nil, false, "")
|
|
||||||
}
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -382,9 +383,6 @@ func (self *Pss) process(pssmsg *PssMsg) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if psstopic == rawTopic {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
self.executeHandlers(psstopic, recvmsg.Payload, from, asymmetric, keyid)
|
self.executeHandlers(psstopic, recvmsg.Payload, from, asymmetric, keyid)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
@ -609,13 +607,11 @@ func (self *Pss) cleanKeys() (count int) {
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
func (self *Pss) enqueue(msg *PssMsg) bool {
|
func (self *Pss) enqueue(msg *PssMsg) bool {
|
||||||
self.fwdPoolMu.Lock()
|
select {
|
||||||
defer self.fwdPoolMu.Unlock()
|
case self.outbox <- msg:
|
||||||
if self.outboxCounter == self.outboxCapacity {
|
return true
|
||||||
return false
|
default:
|
||||||
}
|
}
|
||||||
self.outboxCounter++
|
|
||||||
self.outbox <- msg
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -810,11 +806,6 @@ func (self *Pss) forward(msg *PssMsg) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove from queue
|
|
||||||
self.fwdPoolMu.Lock()
|
|
||||||
self.outboxCounter--
|
|
||||||
self.fwdPoolMu.Unlock()
|
|
||||||
|
|
||||||
// cache the message
|
// cache the message
|
||||||
self.addFwdCache(msg)
|
self.addFwdCache(msg)
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue