shhext

package
v0.39.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2020 License: MPL-2.0 Imports: 40 Imported by: 0

README

Whisper API Extension

API

shhext_getNewFilterMessages

Accepts the same input as shh_getFilterMessages.

Returns

Returns a list of whisper messages matching the specified filter. Filters out the messages already confirmed received by shhext_confirmMessagesProcessed

Deduplication is made using the whisper envelope content and topic only, so the same content received in different whisper envelopes will be deduplicated.

shhext_confirmMessagesProcessed

Confirms whisper messages received and processed on the client side. These messages won't appear anymore when shhext_getNewFilterMessages is called.

Parameters

Gets a list of whisper envelopes.

shhext_post

Accepts same input as shh_post.

Returns

DATA, 32 Bytes - the envelope hash

shhext_requestMessages

Sends a request for historic messages to a mail server.

Parameters
  1. Object - The message request object:
  • mailServerPeer:URL - Mail servers' enode addess
  • from:QUANTITY - (optional) Lower bound of time range as unix timestamp, default is 24 hours back from now
  • to:QUANTITY- (optional) Upper bound of time range as unix timestamp, default is now
  • topic:DATA, 4 Bytes - Regular whisper topic
  • symKeyID:DATA- ID of a symmetric key to authenticate to mail server, derived from mail server password
Returns

Boolean - returns true if the request was send, otherwise false.

Signals

Sends sent signal once per envelope.

{
  "type": "envelope.sent",
  "event": {
    "hash": "0xea0b93079ed32588628f1cabbbb5ed9e4d50b7571064c2962c3853972db67790"
  }
}

Sends expired signal if envelope dropped from whisper local queue before it was sent to any peer on the network.

{
  "type": "envelope.expired",
  "event": {
    "hash": "0x754f4c12dccb14886f791abfeb77ffb86330d03d5a4ba6f37a8c21281988b69e"
  }
}

Documentation

Index

Constants

View Source
const (
	// WhisperTimeAllowance is needed to ensure that we won't miss envelopes that were
	// delivered to mail server after we made a request.
	WhisperTimeAllowance = 20 * time.Second
)

Variables

View Source
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 GroupHistoriesByRequestTimespan added in v0.35.0

func GroupHistoriesByRequestTimespan(store db.HistoryStore, histories []db.TopicHistory) []db.HistoryRequest

GroupHistoriesByRequestTimespan creates requests from provided histories. Multiple histories will be included into the same request only if they share timespan.

func RenewRequests added in v0.35.0

func RenewRequests(requests []db.HistoryRequest, now time.Time) []db.HistoryRequest

RenewRequests re-sets current, first and end timestamps. Changes should not be persisted on disk in this method.

Types

type ApplicationMessagesResponse added in v0.35.0

type ApplicationMessagesResponse struct {
	Messages []*protocol.Message `json:"messages"`
	Cursor   string              `json:"cursor"`
}

type Author added in v0.38.5

type Author struct {
	PublicKey types.HexBytes `json:"publicKey"`
	Alias     string         `json:"alias"`
	Identicon string         `json:"identicon"`
}

type BloomFilterOption added in v0.35.0

type BloomFilterOption struct {
	Range  Range
	Filter []byte
}

BloomFilterOption is a request based on bloom filter.

func (BloomFilterOption) ToMessagesRequestPayload added in v0.35.0

func (filter BloomFilterOption) ToMessagesRequestPayload() ([]byte, error)

ToMessagesRequestPayload creates mailserver.MessagesRequestPayload and encodes it to bytes using rlp.

type Context added in v0.35.0

type Context struct {
	context.Context
}

Context provides access to request-scoped values.

func NewContext added in v0.35.0

func NewContext(ctx context.Context, source TimeSource, registry *RequestsRegistry, storage db.Storage) Context

NewContext creates Context with all required fields.

func NewContextFromService added in v0.35.0

func NewContextFromService(ctx context.Context, service *Service, storage db.Storage) Context

NewContextFromService creates new context instance using Service fileds directly and Storage.

func (Context) HistoryStore added in v0.35.0

func (c Context) HistoryStore() db.HistoryStore

HistoryStore returns db.HistoryStore instance associated with this request.

func (Context) RequestRegistry added in v0.35.0

func (c Context) RequestRegistry() *RequestsRegistry

RequestRegistry returns RequestRegistry that tracks each request life-span.

func (Context) Time added in v0.35.0

func (c Context) Time() time.Time

Time returns current time using time function associated with this request.

type ContextKey added in v0.35.0

type ContextKey struct {
	Name string
}

ContextKey is a type used for keys in shhext Context.

func NewContextKey added in v0.35.0

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
	// 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 HistoryUpdateReactor added in v0.35.0

type HistoryUpdateReactor struct {
	// contains filtered or unexported fields
}

HistoryUpdateReactor responsible for tracking progress for all history requests. It listens for 2 events:

  • when envelope from mail server is received we will update appropriate topic on disk
  • when confirmation for request completion is received - we will set last envelope timestamp as the last timestamp for all TopicLists in current request.

func NewHistoryUpdateReactor added in v0.35.0

func NewHistoryUpdateReactor() *HistoryUpdateReactor

NewHistoryUpdateReactor creates HistoryUpdateReactor instance.

func (*HistoryUpdateReactor) CreateRequests added in v0.35.0

func (reactor *HistoryUpdateReactor) CreateRequests(ctx Context, topicRequests []TopicRequest) ([]db.HistoryRequest, error)

CreateRequests receives list of topic with desired timestamps and initiates both pending requests and requests that cover new topics.

func (*HistoryUpdateReactor) UpdateFinishedRequest added in v0.35.0

func (reactor *HistoryUpdateReactor) UpdateFinishedRequest(ctx Context, id types.Hash) error

UpdateFinishedRequest removes successfully finished request and updates every topic attached to the request.

func (*HistoryUpdateReactor) UpdateTopicHistory added in v0.35.0

func (reactor *HistoryUpdateReactor) UpdateTopicHistory(ctx Context, topic types.TopicType, timestamp time.Time) error

UpdateTopicHistory updates Current timestamp for the TopicHistory with a given timestamp.

type InitiateHistoryRequestParams added in v0.35.0

type InitiateHistoryRequestParams struct {
	Peer     string
	SymKeyID string
	Requests []TopicRequest
	Force    bool
	Timeout  time.Duration
}

InitiateHistoryRequestParams type for initiating history requests from a peer.

type JoinRPC added in v0.35.0

type JoinRPC struct {
	Chat    string
	PubKey  types.HexBytes
	Payload types.HexBytes
}

func (JoinRPC) ID added in v0.35.0

func (m JoinRPC) ID() string

func (JoinRPC) PublicKey added in v0.35.0

func (m JoinRPC) PublicKey() *ecdsa.PublicKey

func (JoinRPC) PublicName added in v0.35.0

func (m JoinRPC) PublicName() string

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 types.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 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.

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 Metadata added in v0.38.5

type Metadata struct {
	DedupID      []byte         `json:"dedupId"`
	EncryptionID types.HexBytes `json:"encryptionId"`
	MessageID    types.HexBytes `json:"messageId"`
	Author       Author         `json:"author"`
}

type PublicAPI

type PublicAPI struct {
	// contains filtered or unexported fields
}

PublicAPI extends whisper public API.

func NewPublicAPI

func NewPublicAPI(s *Service) *PublicAPI

NewPublicAPI returns instance of the public API.

func (*PublicAPI) AcceptRequestAddressForTransaction added in v0.39.2

func (api *PublicAPI) AcceptRequestAddressForTransaction(ctx context.Context, messageID, address string) (*protocol.MessengerResponse, error)

func (*PublicAPI) AcceptRequestTransaction added in v0.39.2

func (api *PublicAPI) AcceptRequestTransaction(ctx context.Context, transactionHash, messageID string, signature types.HexBytes) (*protocol.MessengerResponse, error)

func (*PublicAPI) AddAdminsToGroupChat added in v0.38.0

func (api *PublicAPI) AddAdminsToGroupChat(ctx Context, chatID string, members []string) (*protocol.MessengerResponse, error)

func (*PublicAPI) AddMembersToGroupChat added in v0.38.0

func (api *PublicAPI) AddMembersToGroupChat(ctx Context, chatID string, members []string) (*protocol.MessengerResponse, error)

func (*PublicAPI) BlockContact added in v0.35.0

func (api *PublicAPI) BlockContact(parent context.Context, contact *protocol.Contact) ([]*protocol.Chat, error)

func (*PublicAPI) ChatMessages added in v0.35.0

func (api *PublicAPI) ChatMessages(chatID, cursor string, limit int) (*ApplicationMessagesResponse, error)

func (*PublicAPI) Chats added in v0.35.0

func (api *PublicAPI) Chats(parent context.Context) []*protocol.Chat

func (*PublicAPI) CompleteRequest added in v0.35.0

func (api *PublicAPI) CompleteRequest(parent context.Context, hex string) (err error)

CompleteRequest client must mark request completed when all envelopes were processed.

func (*PublicAPI) ConfirmJoiningGroup added in v0.38.0

func (api *PublicAPI) ConfirmJoiningGroup(ctx context.Context, chatID string) (*protocol.MessengerResponse, error)

func (*PublicAPI) ConfirmMessagesProcessedByID added in v0.35.0

func (api *PublicAPI) ConfirmMessagesProcessedByID(messageConfirmations []*Metadata) error

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) Contacts added in v0.35.0

func (api *PublicAPI) Contacts(parent context.Context) []*protocol.Contact

func (*PublicAPI) CreateGroupChatWithMembers added in v0.38.0

func (api *PublicAPI) CreateGroupChatWithMembers(ctx Context, name string, members []string) (*protocol.MessengerResponse, error)

func (*PublicAPI) DeclineRequestAddressForTransaction added in v0.39.2

func (api *PublicAPI) DeclineRequestAddressForTransaction(ctx context.Context, messageID string) (*protocol.MessengerResponse, error)

func (*PublicAPI) DeclineRequestTransaction added in v0.39.2

func (api *PublicAPI) DeclineRequestTransaction(ctx context.Context, messageID string) (*protocol.MessengerResponse, error)

func (*PublicAPI) DeleteChat added in v0.35.0

func (api *PublicAPI) DeleteChat(parent context.Context, chatID string) error

func (*PublicAPI) DeleteMessage added in v0.35.0

func (api *PublicAPI) DeleteMessage(id string) error

func (*PublicAPI) DeleteMessagesByChatID added in v0.35.0

func (api *PublicAPI) DeleteMessagesByChatID(id string) error

func (*PublicAPI) DisableInstallation added in v0.35.0

func (api *PublicAPI) DisableInstallation(installationID string) error

DisableInstallation disables an installation for multi-device sync.

func (*PublicAPI) EnableInstallation added in v0.35.0

func (api *PublicAPI) EnableInstallation(installationID string) error

EnableInstallation enables an installation for multi-device sync.

func (*PublicAPI) GetOurInstallations added in v0.35.0

func (api *PublicAPI) GetOurInstallations() []*multidevice.Installation

GetOurInstallations returns all the installations available given an identity

func (*PublicAPI) InitiateHistoryRequests added in v0.35.0

func (api *PublicAPI) InitiateHistoryRequests(parent context.Context, request InitiateHistoryRequestParams) (rst []types.HexBytes, err error)

InitiateHistoryRequests is a stateful API for initiating history request for each topic. Caller of this method needs to define only two parameters per each TopicRequest: - Topic - Duration in nanoseconds. Will be used to determine starting time for history request. After that status-go will guarantee that request for this topic and date will be performed.

func (*PublicAPI) Join added in v0.38.0

func (api *PublicAPI) Join(chat protocol.Chat) error

func (*PublicAPI) Leave added in v0.38.0

func (api *PublicAPI) Leave(chat protocol.Chat) error

func (*PublicAPI) LeaveGroupChat added in v0.38.0

func (api *PublicAPI) LeaveGroupChat(ctx Context, chatID string) (*protocol.MessengerResponse, error)

func (*PublicAPI) LoadFilters added in v0.35.0

func (api *PublicAPI) LoadFilters(parent context.Context, chats []*statustransp.Filter) ([]*statustransp.Filter, error)

func (*PublicAPI) MarkMessagesSeen added in v0.35.0

func (api *PublicAPI) MarkMessagesSeen(chatID string, ids []string) error

func (*PublicAPI) Post

func (api *PublicAPI) Post(ctx context.Context, newMessage types.NewMessage) (types.HexBytes, error)

Post is used to send one-to-one for those who did not enabled device-to-device sync, in other words don't use PFS-enabled messages. Otherwise, SendDirectMessage is used. It's important to call PublicAPI.afterSend() so that the client receives a signal with confirmation that the message left the device.

func (*PublicAPI) ReSendChatMessage added in v0.36.1

func (api *PublicAPI) ReSendChatMessage(ctx context.Context, messageID string) error

func (*PublicAPI) RemoveFilters added in v0.35.0

func (api *PublicAPI) RemoveFilters(parent context.Context, chats []*statustransp.Filter) error

func (*PublicAPI) RemoveMemberFromGroupChat added in v0.38.0

func (api *PublicAPI) RemoveMemberFromGroupChat(ctx Context, chatID string, member string) (*protocol.MessengerResponse, error)

func (*PublicAPI) RequestAddressForTransaction added in v0.39.2

func (api *PublicAPI) RequestAddressForTransaction(ctx context.Context, chatID, from, value, contract string) (*protocol.MessengerResponse, error)

func (*PublicAPI) RequestMessages

func (api *PublicAPI) RequestMessages(_ context.Context, r MessagesRequest) (types.HexBytes, error)

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) RequestTransaction added in v0.39.2

func (api *PublicAPI) RequestTransaction(ctx context.Context, chatID, value, contract, address string) (*protocol.MessengerResponse, error)

func (*PublicAPI) SaveChat added in v0.35.0

func (api *PublicAPI) SaveChat(parent context.Context, chat *protocol.Chat) error

func (*PublicAPI) SaveContact added in v0.35.0

func (api *PublicAPI) SaveContact(parent context.Context, contact *protocol.Contact) error

func (*PublicAPI) SendChatMessage added in v0.36.1

func (api *PublicAPI) SendChatMessage(ctx context.Context, message *protocol.Message) (*protocol.MessengerResponse, error)

func (*PublicAPI) SendContactUpdate added in v0.39.2

func (api *PublicAPI) SendContactUpdate(ctx context.Context, contactID, name, picture string) (*protocol.MessengerResponse, error)

func (*PublicAPI) SendContactUpdates added in v0.39.2

func (api *PublicAPI) SendContactUpdates(ctx context.Context, name, picture string) error

func (*PublicAPI) SendDirectMessage added in v0.15.1

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) SendPublicMessage added in v0.15.1

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 added in v0.39.2

func (api *PublicAPI) SendTransaction(ctx context.Context, chatID, transactionHash string, signature types.HexBytes) (*protocol.MessengerResponse, error)

func (*PublicAPI) SetInstallationMetadata added in v0.35.0

func (api *PublicAPI) SetInstallationMetadata(installationID string, data *multidevice.InstallationMetadata) error

SetInstallationMetadata sets the metadata for our own installation

func (*PublicAPI) SyncMessages added in v0.35.0

SyncMessages sends a request to a given MailServerPeer to sync historic messages. MailServerPeers needs to be added as a trusted peer first.

func (*PublicAPI) UpdateMessageOutgoingStatus added in v0.35.0

func (api *PublicAPI) UpdateMessageOutgoingStatus(id, newOutgoingStatus string) error

func (*PublicAPI) VerifyENSNames added in v0.35.0

func (api *PublicAPI) VerifyENSNames(details []enstypes.ENSDetails) (map[string]enstypes.ENSResponse, error)

VerifyENSNames takes a list of ensdetails and returns whether they match the public key specified

type PublisherSignalHandler added in v0.35.0

type PublisherSignalHandler struct{}

PublisherSignalHandler sends signals on protocol events

func (PublisherSignalHandler) BundleAdded added in v0.35.0

func (h PublisherSignalHandler) BundleAdded(identity string, installationID string)

func (PublisherSignalHandler) DecryptMessageFailed added in v0.35.0

func (h PublisherSignalHandler) DecryptMessageFailed(pubKey string)

func (PublisherSignalHandler) NewMessages added in v0.35.0

func (h PublisherSignalHandler) NewMessages(response *protocol.MessengerResponse)

func (PublisherSignalHandler) WhisperFilterAdded added in v0.35.0

func (h PublisherSignalHandler) WhisperFilterAdded(filters []*signal.Filter)

type Range added in v0.35.0

type Range struct {
	Start uint64
	End   uint64
}

Range of the request.

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) Has added in v0.35.0

func (r *RequestsRegistry) Has(uid types.Hash) bool

Has returns true if given uid is stored in registry.

func (*RequestsRegistry) Register added in v0.35.0

func (r *RequestsRegistry) Register(uid types.Hash, topics []types.TopicType) error

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 types.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 SendDirectMessageRPC added in v0.35.0

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 added in v0.35.0

TODO: implement with accordance to https://github.com/status-im/status-go/protocol/issues/28.

func (SendDirectMessageRPC) PublicKey added in v0.35.0

func (m SendDirectMessageRPC) PublicKey() *ecdsa.PublicKey

func (SendDirectMessageRPC) PublicName added in v0.35.0

func (m SendDirectMessageRPC) PublicName() string

type SendPublicMessageRPC added in v0.35.0

type SendPublicMessageRPC struct {
	Sig     string // TODO: remove
	Chat    string
	Payload types.HexBytes
}

SendPublicMessageRPC represents the RPC payload for the SendPublicMessage RPC method

func (SendPublicMessageRPC) ID added in v0.35.0

TODO: implement with accordance to https://github.com/status-im/status-go/protocol/issues/28.

func (SendPublicMessageRPC) PublicKey added in v0.35.0

func (m SendPublicMessageRPC) PublicKey() *ecdsa.PublicKey

func (SendPublicMessageRPC) PublicName added in v0.35.0

func (m SendPublicMessageRPC) PublicName() string

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is a service that provides some additional Whisper API.

func New

func New(n types.Node, ctx interface{}, handler EnvelopeEventsHandler, ldb *leveldb.DB, config params.ShhextConfig) *Service

New returns a new shhext Service.

func (*Service) APIs

func (s *Service) APIs() []rpc.API

APIs returns a list of new APIs.

func (*Service) ConfirmMessagesProcessed added in v0.35.0

func (s *Service) ConfirmMessagesProcessed(messageIDs [][]byte) error

func (*Service) DisableInstallation added in v0.35.0

func (s *Service) DisableInstallation(installationID string) error

DisableInstallation disables an installation for multi-device sync.

func (*Service) EnableInstallation added in v0.35.0

func (s *Service) EnableInstallation(installationID string) error

func (*Service) InitProtocol added in v0.15.1

func (s *Service) InitProtocol(identity *ecdsa.PrivateKey, db *sql.DB) error

func (*Service) Protocols

func (s *Service) Protocols() []p2p.Protocol

Protocols returns a new protocols list. In this case, there are none.

func (*Service) Start

func (s *Service) Start(server *p2p.Server) error

Start is run when a service is started. It does nothing in this case but is required by `node.Service` interface.

func (*Service) Stop

func (s *Service) Stop() error

Stop is run when a service is stopped.

func (*Service) UpdateMailservers added in v0.35.0

func (s *Service) UpdateMailservers(nodes []*enode.Node) error

UpdateMailservers updates information about selected mail servers.

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"`

	// FollowCursor if true loads messages until cursor is empty.
	FollowCursor bool `json:"followCursor"`

	// Topics is a list of Whisper topics.
	// If empty, a full bloom filter will be used.
	Topics []types.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.

type TimeSource added in v0.35.0

type TimeSource func() time.Time

TimeSource is a type used for current time.

type TopicOption added in v0.35.0

type TopicOption struct {
	Topic types.TopicType
	Range Range
}

TopicOption request for a single topic.

type TopicOptions added in v0.35.0

type TopicOptions []TopicOption

TopicOptions is a list of topic-based requsts.

func CreateTopicOptionsFromRequest added in v0.35.0

func CreateTopicOptionsFromRequest(req db.HistoryRequest) TopicOptions

CreateTopicOptionsFromRequest transforms histories attached to a single request to a simpler format - TopicOptions.

func (TopicOptions) ToBloomFilterOption added in v0.35.0

func (options TopicOptions) ToBloomFilterOption() BloomFilterOption

ToBloomFilterOption creates bloom filter request from a list of topics.

func (TopicOptions) Topics added in v0.35.0

func (options TopicOptions) Topics() []types.TopicType

Topics returns list of whisper TopicType attached to each TopicOption.

type TopicRequest added in v0.35.0

type TopicRequest struct {
	Topic    types.TopicType
	Duration time.Duration
}

TopicRequest defines what user has to provide.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL