Documentation ¶
Index ¶
- Constants
- Variables
- func MakeMessagesRequestPayload(r MessagesRequest) ([]byte, error)
- func TopicsToBloom(topics ...types.TopicType) []byte
- func WaitForExpiredOrCompleted(requestID types.Hash, events chan types.EnvelopeEvent, timeout time.Duration) (*types.MailServerResponse, error)
- type ApplicationMessagesResponse
- type Author
- type Context
- type ContextKey
- type EnvelopeEventsHandler
- type EnvelopeSignalHandler
- func (h EnvelopeSignalHandler) EnvelopeExpired(identifiers [][]byte, err error)
- func (h EnvelopeSignalHandler) EnvelopeSent(identifiers [][]byte)
- func (h EnvelopeSignalHandler) MailServerRequestCompleted(requestID types.Hash, lastEnvelopeHash types.Hash, cursor []byte, err error)
- func (h EnvelopeSignalHandler) MailServerRequestExpired(hash types.Hash)
- type EnvelopeState
- type HandlerMock
- type JoinRPC
- type MailRequestMonitor
- type MessagesRequest
- type MessagesResponse
- type Metadata
- type PublicAPI
- func (api *PublicAPI) AcceptRequestAddressForTransaction(ctx context.Context, messageID, address string) (*protocol.MessengerResponse, error)
- func (api *PublicAPI) AcceptRequestTransaction(ctx context.Context, transactionHash, messageID string, ...) (*protocol.MessengerResponse, error)
- func (api *PublicAPI) AddAdminsToGroupChat(ctx Context, chatID string, members []string) (*protocol.MessengerResponse, error)
- func (api *PublicAPI) AddMembersToGroupChat(ctx Context, chatID string, members []string) (*protocol.MessengerResponse, error)
- func (api *PublicAPI) BlockContact(parent context.Context, contact *protocol.Contact) ([]*protocol.Chat, error)
- func (api *PublicAPI) ChatMessages(chatID, cursor string, limit int) (*ApplicationMessagesResponse, error)
- func (api *PublicAPI) Chats(parent context.Context) []*protocol.Chat
- func (api *PublicAPI) ConfirmJoiningGroup(ctx context.Context, chatID string) (*protocol.MessengerResponse, error)
- func (api *PublicAPI) ConfirmMessagesProcessedByID(messageConfirmations []*Metadata) error
- func (api *PublicAPI) Contacts(parent context.Context) []*protocol.Contact
- func (api *PublicAPI) CreateGroupChatWithMembers(ctx Context, name string, members []string) (*protocol.MessengerResponse, error)
- func (api *PublicAPI) DeclineRequestAddressForTransaction(ctx context.Context, messageID string) (*protocol.MessengerResponse, error)
- func (api *PublicAPI) DeclineRequestTransaction(ctx context.Context, messageID string) (*protocol.MessengerResponse, error)
- func (api *PublicAPI) DeleteChat(parent context.Context, chatID string) error
- func (api *PublicAPI) DeleteMessage(id string) error
- func (api *PublicAPI) DeleteMessagesByChatID(id string) error
- func (api *PublicAPI) DisableInstallation(installationID string) error
- func (api *PublicAPI) Echo(ctx context.Context, message string) (string, error)
- func (api *PublicAPI) EnableInstallation(installationID string) error
- func (api *PublicAPI) GetOurInstallations() []*multidevice.Installation
- func (api *PublicAPI) Join(chat protocol.Chat) error
- func (api *PublicAPI) Leave(chat protocol.Chat) error
- func (api *PublicAPI) LeaveGroupChat(ctx Context, chatID string) (*protocol.MessengerResponse, error)
- func (api *PublicAPI) LoadFilters(parent context.Context, chats []*transport.Filter) ([]*transport.Filter, error)
- func (api *PublicAPI) MarkMessagesSeen(chatID string, ids []string) error
- func (api *PublicAPI) ReSendChatMessage(ctx context.Context, messageID string) error
- func (api *PublicAPI) RemoveFilters(parent context.Context, chats []*transport.Filter) error
- func (api *PublicAPI) RemoveMemberFromGroupChat(ctx Context, chatID string, member string) (*protocol.MessengerResponse, error)
- func (api *PublicAPI) RequestAddressForTransaction(ctx context.Context, chatID, from, value, contract string) (*protocol.MessengerResponse, error)
- func (api *PublicAPI) RequestTransaction(ctx context.Context, chatID, value, contract, address string) (*protocol.MessengerResponse, error)
- func (api *PublicAPI) SaveChat(parent context.Context, chat *protocol.Chat) error
- func (api *PublicAPI) SaveContact(parent context.Context, contact *protocol.Contact) error
- func (api *PublicAPI) SendChatMessage(ctx context.Context, message *protocol.Message) (*protocol.MessengerResponse, error)
- func (api *PublicAPI) SendContactUpdate(ctx context.Context, contactID, name, picture string) (*protocol.MessengerResponse, error)
- func (api *PublicAPI) SendContactUpdates(ctx context.Context, name, picture string) error
- func (api *PublicAPI) SendDirectMessage(ctx context.Context, msg SendDirectMessageRPC) (types.HexBytes, error)
- func (api *PublicAPI) SendPairInstallation(ctx context.Context) (*protocol.MessengerResponse, error)
- func (api *PublicAPI) SendPublicMessage(ctx context.Context, msg SendPublicMessageRPC) (types.HexBytes, error)
- func (api *PublicAPI) SendTransaction(ctx context.Context, chatID, value, contract, transactionHash string, ...) (*protocol.MessengerResponse, error)
- func (api *PublicAPI) SetInstallationMetadata(installationID string, data *multidevice.InstallationMetadata) error
- func (api *PublicAPI) StartMessenger() error
- func (api *PublicAPI) SyncDevices(ctx context.Context, name, picture string) error
- func (api *PublicAPI) UpdateMessageOutgoingStatus(id, newOutgoingStatus string) error
- type PublisherSignalHandler
- func (h PublisherSignalHandler) BundleAdded(identity string, installationID string)
- func (h PublisherSignalHandler) DecryptMessageFailed(pubKey string)
- func (h PublisherSignalHandler) FilterAdded(filters []*signal.Filter)
- func (h PublisherSignalHandler) NewMessages(response *protocol.MessengerResponse)
- type RequestsRegistry
- type RetryConfig
- type SendDirectMessageRPC
- type SendPublicMessageRPC
- type Service
- func (s *Service) APIs() []rpc.API
- func (s *Service) ConfirmMessagesProcessed(messageIDs [][]byte) error
- func (s *Service) DisableInstallation(installationID string) error
- func (s *Service) EnableInstallation(installationID string) error
- func (s *Service) GetPeer(rawURL string) (*enode.Node, error)
- func (s *Service) InitProtocol(identity *ecdsa.PrivateKey, db *sql.DB) error
- func (s *Service) NodeID() *ecdsa.PrivateKey
- func (s *Service) Protocols() []p2p.Protocol
- func (s *Service) RequestsRegistry() *RequestsRegistry
- func (s *Service) Start(server *p2p.Server) error
- func (s *Service) StartMessenger() error
- func (s *Service) Stop() error
- func (s *Service) UpdateMailservers(nodes []*enode.Node) error
- type TestNodeWrapper
- func (w *TestNodeWrapper) AddPeer(url string) error
- func (w *TestNodeWrapper) GetWaku(_ interface{}) (types.Waku, error)
- func (w *TestNodeWrapper) GetWhisper(_ interface{}) (types.Whisper, error)
- func (w *TestNodeWrapper) NewENSVerifier(_ *zap.Logger) enstypes.ENSVerifier
- func (w *TestNodeWrapper) RemovePeer(url string) error
- type TimeSource
Constants ¶
const ( // DefaultRequestsDelay will be used in RequestsRegistry if no other was provided. DefaultRequestsDelay = 3 * time.Second )
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 ¶
func MakeMessagesRequestPayload ¶
func MakeMessagesRequestPayload(r MessagesRequest) ([]byte, error)
MakeMessagesRequestPayload makes a specific payload for MailServer to request historic messages. DEPRECATED
func TopicsToBloom ¶
TopicsToBloom squashes all topics into a single bloom filter.
func WaitForExpiredOrCompleted ¶
func WaitForExpiredOrCompleted(requestID types.Hash, events chan types.EnvelopeEvent, timeout time.Duration) (*types.MailServerResponse, error)
Types ¶
type Context ¶
Context provides access to request-scoped values.
func NewContext ¶
func NewContext(ctx context.Context, source TimeSource, registry *RequestsRegistry, storage db.Storage) Context
NewContext creates Context with all required fields.
func (Context) HistoryStore ¶
func (c Context) HistoryStore() db.HistoryStore
HistoryStore returns db.HistoryStore instance associated with this request.
func (Context) RequestRegistry ¶
func (c Context) RequestRegistry() *RequestsRegistry
RequestRegistry returns RequestRegistry that tracks each request life-span.
type ContextKey ¶
type ContextKey struct {
Name string
}
ContextKey is a type used for keys in ext Context.
func NewContextKey ¶
func NewContextKey(name string) ContextKey
NewContextKey returns new ContextKey instance.
type EnvelopeEventsHandler ¶
type EnvelopeEventsHandler interface { EnvelopeSent([][]byte) EnvelopeExpired([][]byte, error) MailServerRequestCompleted(types.Hash, types.Hash, []byte, error) MailServerRequestExpired(types.Hash) }
EnvelopeEventsHandler used for two different event types.
type EnvelopeSignalHandler ¶
type EnvelopeSignalHandler struct{}
EnvelopeSignalHandler sends signals when envelope is sent or expired.
func (EnvelopeSignalHandler) EnvelopeExpired ¶
func (h EnvelopeSignalHandler) EnvelopeExpired(identifiers [][]byte, err error)
EnvelopeExpired triggered when envelope is expired but wasn't delivered to any peer.
func (EnvelopeSignalHandler) EnvelopeSent ¶
func (h EnvelopeSignalHandler) EnvelopeSent(identifiers [][]byte)
EnvelopeSent triggered when envelope delivered atleast to 1 peer.
func (EnvelopeSignalHandler) MailServerRequestCompleted ¶
func (h EnvelopeSignalHandler) MailServerRequestCompleted(requestID types.Hash, lastEnvelopeHash types.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 types.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 // MailServerRequestSent is set when p2p request is sent to the mailserver MailServerRequestSent )
type HandlerMock ¶
type HandlerMock struct {
// contains filtered or unexported fields
}
func NewHandlerMock ¶
func NewHandlerMock(buf int) HandlerMock
func (HandlerMock) EnvelopeExpired ¶
func (t HandlerMock) EnvelopeExpired(ids [][]byte, err error)
func (HandlerMock) EnvelopeSent ¶
func (t HandlerMock) EnvelopeSent(ids [][]byte)
func (HandlerMock) MailServerRequestCompleted ¶
func (HandlerMock) MailServerRequestExpired ¶
func (t HandlerMock) MailServerRequestExpired(hash types.Hash)
type JoinRPC ¶
func (JoinRPC) PublicName ¶
type MailRequestMonitor ¶
type MailRequestMonitor struct {
// contains filtered or unexported fields
}
MailRequestMonitor is responsible for monitoring history request to mailservers.
func NewMailRequestMonitor ¶
func NewMailRequestMonitor(eventSub mailservers.EnvelopeEventSubscriber, h EnvelopeEventsHandler, reg *RequestsRegistry) *MailRequestMonitor
func (*MailRequestMonitor) GetState ¶
func (m *MailRequestMonitor) GetState(hash types.Hash) EnvelopeState
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 types.TopicType `json:"topic"` // Topics is a list of Whisper topics. Topics []types.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.
func (*MessagesRequest) SetDefaults ¶
func (r *MessagesRequest) SetDefaults(now time.Time)
type MessagesResponse ¶
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 requestMessages2 method.
type PublicAPI ¶
type PublicAPI struct {
// contains filtered or unexported fields
}
PublicAPI extends whisper public API.
func NewPublicAPI ¶
func NewPublicAPI(s *Service, eventSub mailservers.EnvelopeEventSubscriber) *PublicAPI
NewPublicAPI returns instance of the public API.
func (*PublicAPI) AcceptRequestAddressForTransaction ¶
func (*PublicAPI) AcceptRequestTransaction ¶
func (*PublicAPI) AddAdminsToGroupChat ¶
func (*PublicAPI) AddMembersToGroupChat ¶
func (*PublicAPI) BlockContact ¶
func (*PublicAPI) ChatMessages ¶
func (api *PublicAPI) ChatMessages(chatID, cursor string, limit int) (*ApplicationMessagesResponse, error)
func (*PublicAPI) ConfirmJoiningGroup ¶
func (*PublicAPI) ConfirmMessagesProcessedByID ¶
ConfirmMessagesProcessedByID is a method to confirm that messages was consumed by the client side. TODO: this is broken now as it requires dedup ID while a message hash should be used.
func (*PublicAPI) CreateGroupChatWithMembers ¶
func (*PublicAPI) DeclineRequestAddressForTransaction ¶
func (*PublicAPI) DeclineRequestTransaction ¶
func (*PublicAPI) DeleteChat ¶
func (*PublicAPI) DeleteMessage ¶
func (*PublicAPI) DeleteMessagesByChatID ¶
func (*PublicAPI) DisableInstallation ¶
DisableInstallation disables an installation for multi-device sync.
func (*PublicAPI) EnableInstallation ¶
EnableInstallation enables an installation for multi-device sync.
func (*PublicAPI) GetOurInstallations ¶
func (api *PublicAPI) GetOurInstallations() []*multidevice.Installation
GetOurInstallations returns all the installations available given an identity
func (*PublicAPI) LeaveGroupChat ¶
func (*PublicAPI) LoadFilters ¶
func (*PublicAPI) MarkMessagesSeen ¶
func (*PublicAPI) ReSendChatMessage ¶
func (*PublicAPI) RemoveFilters ¶
func (*PublicAPI) RemoveMemberFromGroupChat ¶
func (*PublicAPI) RequestAddressForTransaction ¶
func (*PublicAPI) RequestTransaction ¶
func (*PublicAPI) SaveContact ¶
func (*PublicAPI) SendChatMessage ¶
func (*PublicAPI) SendContactUpdate ¶
func (*PublicAPI) SendContactUpdates ¶
func (*PublicAPI) SendDirectMessage ¶
func (api *PublicAPI) SendDirectMessage(ctx context.Context, msg SendDirectMessageRPC) (types.HexBytes, error)
SendDirectMessage sends a 1:1 chat message to the underlying transport Message's payload is a transit encoded message. It's important to call PublicAPI.afterSend() so that the client receives a signal with confirmation that the message left the device.
func (*PublicAPI) SendPairInstallation ¶
func (*PublicAPI) SendPublicMessage ¶
func (api *PublicAPI) SendPublicMessage(ctx context.Context, msg SendPublicMessageRPC) (types.HexBytes, error)
SendPublicMessage sends a public chat message to the underlying transport. Message's payload is a transit encoded message. It's important to call PublicAPI.afterSend() so that the client receives a signal with confirmation that the message left the device.
func (*PublicAPI) SendTransaction ¶
func (*PublicAPI) SetInstallationMetadata ¶
func (api *PublicAPI) SetInstallationMetadata(installationID string, data *multidevice.InstallationMetadata) error
SetInstallationMetadata sets the metadata for our own installation
func (*PublicAPI) StartMessenger ¶ added in v0.41.0
func (*PublicAPI) SyncDevices ¶
func (*PublicAPI) UpdateMessageOutgoingStatus ¶
type PublisherSignalHandler ¶
type PublisherSignalHandler struct{}
PublisherSignalHandler sends signals on protocol events
func (PublisherSignalHandler) BundleAdded ¶
func (h PublisherSignalHandler) BundleAdded(identity string, installationID string)
func (PublisherSignalHandler) DecryptMessageFailed ¶
func (h PublisherSignalHandler) DecryptMessageFailed(pubKey string)
func (PublisherSignalHandler) FilterAdded ¶
func (h PublisherSignalHandler) FilterAdded(filters []*signal.Filter)
func (PublisherSignalHandler) NewMessages ¶
func (h PublisherSignalHandler) NewMessages(response *protocol.MessengerResponse)
type RequestsRegistry ¶
type RequestsRegistry struct {
// contains filtered or unexported fields
}
RequestsRegistry keeps map for all requests with timestamp when they were made.
func NewRequestsRegistry ¶
func NewRequestsRegistry(delay time.Duration) *RequestsRegistry
NewRequestsRegistry creates instance of the RequestsRegistry and returns pointer to it.
func (*RequestsRegistry) Clear ¶
func (r *RequestsRegistry) Clear()
Clear recreates all structures used for caching requests.
func (*RequestsRegistry) Has ¶
func (r *RequestsRegistry) Has(uid types.Hash) bool
Has returns true if given uid is stored in registry.
func (*RequestsRegistry) Register ¶
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 ¶
func (r *RequestsRegistry) Unregister(uid types.Hash)
Unregister removes request with given UID from registry.
type RetryConfig ¶
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 SendDirectMessageRPC ¶
type SendDirectMessageRPC struct { Sig string // TODO: remove Chat string Payload types.HexBytes PubKey types.HexBytes DH bool // TODO: make sure to remove safely }
SendDirectMessageRPC represents the RPC payload for the SendDirectMessage RPC method
func (SendDirectMessageRPC) ID ¶
func (m SendDirectMessageRPC) ID() string
TODO: implement with accordance to https://github.com/status-im/status-go/protocol/issues/28.
func (SendDirectMessageRPC) PublicKey ¶
func (m SendDirectMessageRPC) PublicKey() *ecdsa.PublicKey
func (SendDirectMessageRPC) PublicName ¶
func (m SendDirectMessageRPC) PublicName() string
type SendPublicMessageRPC ¶
SendPublicMessageRPC represents the RPC payload for the SendPublicMessage RPC method
func (SendPublicMessageRPC) ID ¶
func (m SendPublicMessageRPC) ID() string
TODO: implement with accordance to https://github.com/status-im/status-go/protocol/issues/28.
func (SendPublicMessageRPC) PublicKey ¶
func (m SendPublicMessageRPC) PublicKey() *ecdsa.PublicKey
func (SendPublicMessageRPC) PublicName ¶
func (m SendPublicMessageRPC) PublicName() string
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is a service that provides some additional API to whisper-based protocols like Whisper or Waku.
func New ¶
func New( config params.ShhextConfig, n types.Node, ldb *leveldb.DB, mailMonitor *MailRequestMonitor, reqRegistry *RequestsRegistry, eventSub mailservers.EnvelopeEventSubscriber, ) *Service
func (*Service) ConfirmMessagesProcessed ¶
func (*Service) DisableInstallation ¶
DisableInstallation disables an installation for multi-device sync.
func (*Service) EnableInstallation ¶
func (*Service) InitProtocol ¶
func (*Service) NodeID ¶
func (s *Service) NodeID() *ecdsa.PrivateKey
func (*Service) RequestsRegistry ¶
func (s *Service) RequestsRegistry() *RequestsRegistry
func (*Service) Start ¶
Start is run when a service is started. It does nothing in this case but is required by `node.Service` interface.
func (*Service) StartMessenger ¶ added in v0.41.0
type TestNodeWrapper ¶
type TestNodeWrapper struct {
// contains filtered or unexported fields
}
func NewTestNodeWrapper ¶
func NewTestNodeWrapper(whisper types.Whisper, waku types.Waku) *TestNodeWrapper
func (*TestNodeWrapper) AddPeer ¶
func (w *TestNodeWrapper) AddPeer(url string) error
func (*TestNodeWrapper) GetWaku ¶
func (w *TestNodeWrapper) GetWaku(_ interface{}) (types.Waku, error)
func (*TestNodeWrapper) GetWhisper ¶
func (w *TestNodeWrapper) GetWhisper(_ interface{}) (types.Whisper, error)
func (*TestNodeWrapper) NewENSVerifier ¶
func (w *TestNodeWrapper) NewENSVerifier(_ *zap.Logger) enstypes.ENSVerifier
func (*TestNodeWrapper) RemovePeer ¶
func (w *TestNodeWrapper) RemovePeer(url string) error