Documentation ¶
Index ¶
- Variables
- type EnvelopeEventsHandler
- type EnvelopeSignalHandler
- func (h EnvelopeSignalHandler) BundleAdded(identity string, installationID string)
- func (h EnvelopeSignalHandler) DecryptMessageFailed(pubKey string)
- func (h EnvelopeSignalHandler) EnvelopeExpired(hash common.Hash, err error)
- func (h EnvelopeSignalHandler) EnvelopeSent(hash common.Hash)
- func (h EnvelopeSignalHandler) MailServerRequestCompleted(requestID common.Hash, lastEnvelopeHash common.Hash, cursor []byte, err error)
- func (h EnvelopeSignalHandler) MailServerRequestExpired(hash common.Hash)
- type EnvelopeState
- type EnvelopesMonitor
- type MailRequestMonitor
- type MessagesRequest
- type MessagesResponse
- type PublicAPI
- func (api *PublicAPI) ConfirmMessagesProcessed(messages []*whisper.Message) error
- func (api *PublicAPI) ConfirmMessagesProcessedByID(messageIDs [][]byte) error
- func (api *PublicAPI) GetNewFilterMessages(filterID string) ([]dedup.DeduplicateMessage, error)
- func (api *PublicAPI) Post(ctx context.Context, req whisper.NewMessage) (hexutil.Bytes, error)
- func (api *PublicAPI) RequestMessages(_ context.Context, r MessagesRequest) (hexutil.Bytes, error)
- func (api *PublicAPI) RequestMessagesSync(conf RetryConfig, r MessagesRequest) (MessagesResponse, error)
- func (api *PublicAPI) SendDirectMessage(ctx context.Context, msg chat.SendDirectMessageRPC) (hexutil.Bytes, error)
- func (api *PublicAPI) SendPairingMessage(ctx context.Context, msg chat.SendDirectMessageRPC) ([]hexutil.Bytes, error)
- func (api *PublicAPI) SendPublicMessage(ctx context.Context, msg chat.SendPublicMessageRPC) (hexutil.Bytes, error)
- func (api *PublicAPI) SyncMessages(ctx context.Context, r SyncMessagesRequest) (SyncMessagesResponse, error)
- type RequestsRegistry
- type RetryConfig
- type Service
- func (s *Service) APIs() []rpc.API
- func (s *Service) DisableInstallation(myIdentityKey *ecdsa.PublicKey, installationID string) error
- func (s *Service) EnableInstallation(myIdentityKey *ecdsa.PublicKey, installationID string) error
- func (s *Service) GetBundle(myIdentityKey *ecdsa.PrivateKey) (*chat.Bundle, error)
- func (s *Service) GetPublicBundle(identityKey *ecdsa.PublicKey) (*chat.Bundle, error)
- func (s *Service) InitProtocolWithEncyptionKey(address string, encKey string) error
- func (s *Service) InitProtocolWithPassword(address string, password string) error
- func (s *Service) ProcessPublicBundle(myIdentityKey *ecdsa.PrivateKey, bundle *chat.Bundle) ([]chat.IdentityAndIDPair, error)
- func (s *Service) Protocols() []p2p.Protocol
- func (s *Service) Start(server *p2p.Server) error
- func (s *Service) Stop() error
- func (s *Service) UpdateMailservers(nodes []*enode.Node) error
- type SyncMessagesRequest
- type SyncMessagesResponse
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidMailServerPeer is returned when it fails to parse enode from params. ErrInvalidMailServerPeer = errors.New("invalid mailServerPeer value") // ErrInvalidSymKeyID is returned when it fails to get a symmetric key. ErrInvalidSymKeyID = errors.New("invalid symKeyID value") // ErrInvalidPublicKey is returned when public key can't be extracted // from MailServer's nodeID. ErrInvalidPublicKey = errors.New("can't extract public key") // ErrPFSNotEnabled is returned when an endpoint PFS only is called but // PFS is disabled ErrPFSNotEnabled = errors.New("pfs not enabled") )
Functions ¶
This section is empty.
Types ¶
type EnvelopeEventsHandler ¶
type EnvelopeEventsHandler interface { EnvelopeSent(common.Hash) EnvelopeExpired(common.Hash, error) MailServerRequestCompleted(common.Hash, common.Hash, []byte, error) MailServerRequestExpired(common.Hash) }
EnvelopeEventsHandler used for two different event types.
type EnvelopeSignalHandler ¶
type EnvelopeSignalHandler struct{}
EnvelopeSignalHandler sends signals when envelope is sent or expired.
func (EnvelopeSignalHandler) BundleAdded ¶ added in v0.16.4
func (h EnvelopeSignalHandler) BundleAdded(identity string, installationID string)
func (EnvelopeSignalHandler) DecryptMessageFailed ¶ added in v0.15.1
func (h EnvelopeSignalHandler) DecryptMessageFailed(pubKey string)
func (EnvelopeSignalHandler) EnvelopeExpired ¶
func (h EnvelopeSignalHandler) EnvelopeExpired(hash common.Hash, err error)
EnvelopeExpired triggered when envelope is expired but wasn't delivered to any peer.
func (EnvelopeSignalHandler) EnvelopeSent ¶
func (h EnvelopeSignalHandler) EnvelopeSent(hash common.Hash)
EnvelopeSent triggered when envelope delivered atleast to 1 peer.
func (EnvelopeSignalHandler) MailServerRequestCompleted ¶
func (h EnvelopeSignalHandler) MailServerRequestCompleted(requestID common.Hash, lastEnvelopeHash common.Hash, cursor []byte, err error)
MailServerRequestCompleted triggered when the mailserver sends a message to notify that the request has been completed
func (EnvelopeSignalHandler) MailServerRequestExpired ¶
func (h EnvelopeSignalHandler) MailServerRequestExpired(hash common.Hash)
MailServerRequestExpired triggered when the mailserver request expires
type EnvelopeState ¶
type EnvelopeState int
EnvelopeState in local tracker
const ( // NotRegistered returned if asked hash wasn't registered in the tracker. NotRegistered EnvelopeState = -1 // EnvelopePosted is set when envelope was added to a local whisper queue. EnvelopePosted EnvelopeState = iota // EnvelopeSent is set when envelope is sent to atleast one peer. EnvelopeSent // MailServerRequestSent is set when p2p request is sent to the mailserver MailServerRequestSent )
type EnvelopesMonitor ¶
type EnvelopesMonitor struct {
// contains filtered or unexported fields
}
EnvelopesMonitor is responsible for monitoring whisper envelopes state.
func NewEnvelopesMonitor ¶
func NewEnvelopesMonitor(w *whisper.Whisper, handler EnvelopeEventsHandler, mailServerConfirmation bool, mailPeers *mailservers.PeerStore, maxAttempts int) *EnvelopesMonitor
NewEnvelopesMonitor returns a pointer to an instance of the EnvelopesMonitor.
func (*EnvelopesMonitor) Add ¶
func (m *EnvelopesMonitor) Add(envelopeHash common.Hash, message whisper.NewMessage)
Add hash to a tracker.
func (*EnvelopesMonitor) GetMessageState ¶
func (m *EnvelopesMonitor) GetMessageState(mID common.Hash) EnvelopeState
func (*EnvelopesMonitor) GetState ¶
func (m *EnvelopesMonitor) GetState(hash common.Hash) EnvelopeState
type MailRequestMonitor ¶ added in v0.35.0
type MailRequestMonitor struct {
// contains filtered or unexported fields
}
MailRequestMonitor is responsible for monitoring history request to mailservers.
func (*MailRequestMonitor) GetState ¶ added in v0.35.0
func (m *MailRequestMonitor) GetState(hash common.Hash) EnvelopeState
func (*MailRequestMonitor) Start ¶ added in v0.35.0
func (m *MailRequestMonitor) Start()
Start processing events.
func (*MailRequestMonitor) Stop ¶ added in v0.35.0
func (m *MailRequestMonitor) Stop()
Stop process events.
type MessagesRequest ¶
type MessagesRequest struct { // MailServerPeer is MailServer's enode address. MailServerPeer string `json:"mailServerPeer"` // From is a lower bound of time range (optional). // Default is 24 hours back from now. From uint32 `json:"from"` // To is a upper bound of time range (optional). // Default is now. To uint32 `json:"to"` // Limit determines the number of messages sent by the mail server // for the current paginated request Limit uint32 `json:"limit"` // Cursor is used as starting point for paginated requests Cursor string `json:"cursor"` // Topic is a regular Whisper topic. // DEPRECATED Topic whisper.TopicType `json:"topic"` // Topics is a list of Whisper topics. Topics []whisper.TopicType `json:"topics"` // SymKeyID is an ID of a symmetric key to authenticate to MailServer. // It's derived from MailServer password. SymKeyID string `json:"symKeyID"` // Timeout is the time to live of the request specified in seconds. // Default is 10 seconds Timeout time.Duration `json:"timeout"` // Force ensures that requests will bypass enforced delay. Force bool `json:"force"` }
MessagesRequest is a RequestMessages() request payload.
type MessagesResponse ¶ added in v0.35.0
type MessagesResponse struct { // Cursor from the response can be used to retrieve more messages // for the previous request. Cursor string `json:"cursor"` // Error indicates that something wrong happened when sending messages // to the requester. Error error `json:"error"` }
MessagesResponse is a response for shhext_requestMessages2 method.
type PublicAPI ¶
type PublicAPI struct {
// contains filtered or unexported fields
}
PublicAPI extends whisper public API.
func NewPublicAPI ¶
NewPublicAPI returns instance of the public API.
func (*PublicAPI) ConfirmMessagesProcessed ¶
ConfirmMessagesProcessed is a method to confirm that messages was consumed by the client side.
func (*PublicAPI) ConfirmMessagesProcessedByID ¶ added in v0.35.0
ConfirmMessagesProcessedByID is a method to confirm that messages was consumed by the client side.
func (*PublicAPI) GetNewFilterMessages ¶
func (api *PublicAPI) GetNewFilterMessages(filterID string) ([]dedup.DeduplicateMessage, error)
GetNewFilterMessages is a prototype method with deduplication
func (*PublicAPI) RequestMessages ¶
RequestMessages sends a request for historic messages to a MailServer.
func (*PublicAPI) RequestMessagesSync ¶ added in v0.35.0
func (api *PublicAPI) RequestMessagesSync(conf RetryConfig, r MessagesRequest) (MessagesResponse, error)
RequestMessagesSync repeats MessagesRequest using configuration in retry conf.
func (*PublicAPI) SendDirectMessage ¶ added in v0.15.1
func (api *PublicAPI) SendDirectMessage(ctx context.Context, msg chat.SendDirectMessageRPC) (hexutil.Bytes, error)
SendDirectMessage sends a 1:1 chat message to the underlying transport
func (*PublicAPI) SendPairingMessage ¶ added in v0.16.4
func (api *PublicAPI) SendPairingMessage(ctx context.Context, msg chat.SendDirectMessageRPC) ([]hexutil.Bytes, error)
DEPRECATED: use SendDirectMessage with DH flag SendPairingMessage sends a 1:1 chat message to our own devices to initiate a pairing session
func (*PublicAPI) SendPublicMessage ¶ added in v0.15.1
func (api *PublicAPI) SendPublicMessage(ctx context.Context, msg chat.SendPublicMessageRPC) (hexutil.Bytes, error)
SendPublicMessage sends a public chat message to the underlying transport
func (*PublicAPI) SyncMessages ¶ added in v0.35.0
func (api *PublicAPI) SyncMessages(ctx context.Context, r SyncMessagesRequest) (SyncMessagesResponse, error)
SyncMessages sends a request to a given MailServerPeer to sync historic messages. MailServerPeers needs to be added as a trusted peer first.
type RequestsRegistry ¶ added in v0.35.0
type RequestsRegistry struct {
// contains filtered or unexported fields
}
RequestsRegistry keeps map for all requests with timestamp when they were made.
func NewRequestsRegistry ¶ added in v0.35.0
func NewRequestsRegistry(delay time.Duration) *RequestsRegistry
NewRequestsRegistry creates instance of the RequestsRegistry and returns pointer to it.
func (*RequestsRegistry) Clear ¶ added in v0.35.0
func (r *RequestsRegistry) Clear()
Clear recreates all structures used for caching requests.
func (*RequestsRegistry) Register ¶ added in v0.35.0
Register request with given topics. If request with same topics was made in less then configured delay then error will be returned.
func (*RequestsRegistry) Unregister ¶ added in v0.35.0
func (r *RequestsRegistry) Unregister(uid common.Hash)
Unregister removes request with given UID from registry.
type RetryConfig ¶ added in v0.35.0
type RetryConfig struct { BaseTimeout time.Duration // StepTimeout defines duration increase per each retry. StepTimeout time.Duration MaxRetries int }
RetryConfig specifies configuration for retries with timeout and max amount of retries.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is a service that provides some additional Whisper API.
func New ¶
func New(w *whisper.Whisper, handler EnvelopeEventsHandler, db *leveldb.DB, config params.ShhextConfig) *Service
New returns a new Service. dataDir is a folder path to a network-independent location
func (*Service) DisableInstallation ¶ added in v0.35.0
DisableInstallation disables an installation for multi-device sync.
func (*Service) EnableInstallation ¶ added in v0.35.0
EnableInstallation enables an installation for multi-device sync.
func (*Service) GetPublicBundle ¶
func (*Service) InitProtocolWithEncyptionKey ¶
InitProtocolWithEncyptionKey creates an instance of ProtocolService given an address and encryption key.
func (*Service) InitProtocolWithPassword ¶
InitProtocolWithPassword creates an instance of ProtocolService given an address and password used to generate an encryption key.
func (*Service) ProcessPublicBundle ¶ added in v0.15.1
func (s *Service) ProcessPublicBundle(myIdentityKey *ecdsa.PrivateKey, bundle *chat.Bundle) ([]chat.IdentityAndIDPair, error)
func (*Service) Start ¶
Start is run when a service is started. It does nothing in this case but is required by `node.Service` interface.
type SyncMessagesRequest ¶ added in v0.35.0
type SyncMessagesRequest struct { // MailServerPeer is MailServer's enode address. MailServerPeer string `json:"mailServerPeer"` // From is a lower bound of time range (optional). // Default is 24 hours back from now. From uint32 `json:"from"` // To is a upper bound of time range (optional). // Default is now. To uint32 `json:"to"` // Limit determines the number of messages sent by the mail server // for the current paginated request Limit uint32 `json:"limit"` // Cursor is used as starting point for paginated requests Cursor string `json:"cursor"` // Topics is a list of Whisper topics. // If empty, a full bloom filter will be used. Topics []whisper.TopicType `json:"topics"` }
SyncMessagesRequest is a SyncMessages() request payload.
type SyncMessagesResponse ¶ added in v0.35.0
type SyncMessagesResponse struct { // Cursor from the response can be used to retrieve more messages // for the previous request. Cursor string `json:"cursor"` // Error indicates that something wrong happened when sending messages // to the requester. Error string `json:"error"` }
SyncMessagesResponse is a response from the mail server to which SyncMessagesRequest was sent.