mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 01:43:47 +00:00
swarm/pss: WIP outbox
This commit is contained in:
parent
f6d48fe564
commit
580d116704
1 changed files with 20 additions and 0 deletions
|
|
@ -687,6 +687,12 @@ func (self *Pss) forward(msg *PssMsg) {
|
|||
to := make([]byte, addressLength)
|
||||
copy(to[:len(msg.To)], msg.To)
|
||||
|
||||
// message hash
|
||||
digest, err := self.storeMsg(msg)
|
||||
if err != nil {
|
||||
log.Warn(fmt.Sprintf("could not store message %v to cache: %v", msg, err))
|
||||
}
|
||||
|
||||
// send with kademlia
|
||||
// find the closest peer to the recipient and attempt to send
|
||||
sent := 0
|
||||
|
|
@ -822,3 +828,17 @@ func (self *Pss) isMsgExpired(msg *PssMsg) bool {
|
|||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *Pss) isMsgExpired(msg *PssMsg) bool {
|
||||
msgexp := time.Unix(int64(msg.Expire), 0)
|
||||
// if msgexp.Before(time.Now()) {
|
||||
// log.Trace("pss expired :/ ... dropping")
|
||||
// return nil
|
||||
// } else if msgexp.After(time.Now().Add(self.msgTTL)) {
|
||||
// return errors.New("Invalid TTL")
|
||||
// }
|
||||
if msgexp.Before(time.Now()) || msgexp.After(time.Now().Add(self.msgTTL)) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue