2018-04-11 15:41:51 +00:00
|
|
|
package shhext
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
|
|
"github.com/status-im/status-go/geth/signal"
|
|
|
|
)
|
|
|
|
|
2018-04-13 05:52:22 +00:00
|
|
|
// EnvelopeSignal includes hash of the envelope.
|
|
|
|
type EnvelopeSignal struct {
|
2018-04-11 15:41:51 +00:00
|
|
|
Hash common.Hash `json:"hash"`
|
|
|
|
}
|
|
|
|
|
2018-04-13 05:52:22 +00:00
|
|
|
// EnvelopeSignalHandler sends signals when envelope is sent or expired.
|
|
|
|
type EnvelopeSignalHandler struct{}
|
|
|
|
|
|
|
|
// EnvelopeSent triggered when envelope delivered atleast to 1 peer.
|
|
|
|
func (h EnvelopeSignalHandler) EnvelopeSent(hash common.Hash) {
|
|
|
|
signal.Send(signal.Envelope{
|
|
|
|
Type: signal.EventEnvelopeSent,
|
|
|
|
Event: EnvelopeSignal{Hash: hash},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// EnvelopeExpired triggered when envelope is expired but wasn't delivered to any peer.
|
|
|
|
func (h EnvelopeSignalHandler) EnvelopeExpired(hash common.Hash) {
|
2018-04-11 15:41:51 +00:00
|
|
|
signal.Send(signal.Envelope{
|
2018-04-13 05:52:22 +00:00
|
|
|
Type: signal.EventEnvelopeExpired,
|
|
|
|
Event: EnvelopeSignal{Hash: hash},
|
2018-04-11 15:41:51 +00:00
|
|
|
})
|
|
|
|
}
|