2019-12-09 10:06:04 +00:00
|
|
|
package whisper
|
2018-09-25 07:05:38 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
2018-11-14 07:03:58 +00:00
|
|
|
"github.com/ethereum/go-ethereum/p2p/enode"
|
2018-09-25 07:05:38 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// EventType used to define known envelope events.
|
|
|
|
type EventType string
|
|
|
|
|
|
|
|
const (
|
|
|
|
// EventEnvelopeSent fires when envelope was sent to a peer.
|
|
|
|
EventEnvelopeSent EventType = "envelope.sent"
|
|
|
|
// EventEnvelopeExpired fires when envelop expired
|
|
|
|
EventEnvelopeExpired EventType = "envelope.expired"
|
2019-02-20 17:10:59 +00:00
|
|
|
// EventEnvelopeReceived is sent once envelope was received from a peer.
|
|
|
|
// EventEnvelopeReceived must be sent to the feed even if envelope was previously in the cache.
|
|
|
|
// And event, ideally, should contain information about peer that sent envelope to us.
|
|
|
|
EventEnvelopeReceived EventType = "envelope.received"
|
2018-11-27 06:30:15 +00:00
|
|
|
// EventBatchAcknowledged is sent when batch of envelopes was acknowleged by a peer.
|
|
|
|
EventBatchAcknowledged EventType = "batch.acknowleged"
|
2018-09-25 07:05:38 +00:00
|
|
|
// EventEnvelopeAvailable fires when envelop is available for filters
|
|
|
|
EventEnvelopeAvailable EventType = "envelope.available"
|
2018-12-05 13:57:05 +00:00
|
|
|
// EventMailServerRequestSent fires when such request is sent.
|
|
|
|
EventMailServerRequestSent EventType = "mailserver.request.sent"
|
2018-09-25 07:05:38 +00:00
|
|
|
// EventMailServerRequestCompleted fires after mailserver sends all the requested messages
|
|
|
|
EventMailServerRequestCompleted EventType = "mailserver.request.completed"
|
2018-12-05 13:57:05 +00:00
|
|
|
// EventMailServerRequestExpired fires after mailserver the request TTL ends.
|
|
|
|
// This event is independent and concurrent to EventMailServerRequestCompleted.
|
|
|
|
// Request should be considered as expired only if expiry event was received first.
|
2018-09-25 07:05:38 +00:00
|
|
|
EventMailServerRequestExpired EventType = "mailserver.request.expired"
|
|
|
|
// EventMailServerEnvelopeArchived fires after an envelope has been archived
|
|
|
|
EventMailServerEnvelopeArchived EventType = "mailserver.envelope.archived"
|
2018-12-14 11:21:34 +00:00
|
|
|
// EventMailServerSyncFinished fires when the sync of messages is finished.
|
|
|
|
EventMailServerSyncFinished EventType = "mailserver.sync.finished"
|
2018-09-25 07:05:38 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// EnvelopeEvent used for envelopes events.
|
|
|
|
type EnvelopeEvent struct {
|
|
|
|
Event EventType
|
2019-12-20 09:40:50 +00:00
|
|
|
Topic TopicType
|
2018-09-25 07:05:38 +00:00
|
|
|
Hash common.Hash
|
2018-11-27 06:30:15 +00:00
|
|
|
Batch common.Hash
|
2018-11-14 07:03:58 +00:00
|
|
|
Peer enode.ID
|
2018-09-25 07:05:38 +00:00
|
|
|
Data interface{}
|
|
|
|
}
|
2018-12-14 11:21:34 +00:00
|
|
|
|
|
|
|
// SyncEventResponse is a response from the Mail Server
|
|
|
|
// form which the peer received envelopes.
|
|
|
|
type SyncEventResponse struct {
|
|
|
|
Cursor []byte
|
|
|
|
Error string
|
|
|
|
}
|