Documentation
¶
Index ¶
- Variables
- func ContactCodeTopic(publicKey *ecdsa.PublicKey) string
- func DefaultWhisperMessage() types.NewMessage
- func ToTopic(s string) []byte
- type EnvelopeEventsHandler
- type EnvelopeState
- type EnvelopesMonitor
- type EnvelopesMonitorConfig
- type Filter
- type Message
- type Option
- type RequestOptions
- type WhisperServiceTransport
- func (a *WhisperServiceTransport) Filters() []*Filter
- func (a *WhisperServiceTransport) InitFilters(chatIDs []string, publicKeys []*ecdsa.PublicKey) ([]*Filter, error)
- func (a *WhisperServiceTransport) JoinGroup(publicKeys []*ecdsa.PublicKey) error
- func (a *WhisperServiceTransport) JoinPrivate(publicKey *ecdsa.PublicKey) error
- func (a *WhisperServiceTransport) JoinPublic(chatID string) error
- func (a *WhisperServiceTransport) LeaveGroup(publicKeys []*ecdsa.PublicKey) error
- func (a *WhisperServiceTransport) LeavePrivate(publicKey *ecdsa.PublicKey) error
- func (a *WhisperServiceTransport) LeavePublic(chatID string) error
- func (a *WhisperServiceTransport) LoadFilters(filters []*Filter) ([]*Filter, error)
- func (a *WhisperServiceTransport) ProcessNegotiatedSecret(secret types.NegotiatedSecret) (*Filter, error)
- func (a *WhisperServiceTransport) RemoveFilters(filters []*Filter) error
- func (a *WhisperServiceTransport) Reset() error
- func (a *WhisperServiceTransport) RetrieveAllMessages() ([]Message, error)
- func (a *WhisperServiceTransport) RetrievePrivateMessages(publicKey *ecdsa.PublicKey) ([]*types.Message, error)
- func (a *WhisperServiceTransport) RetrievePublicMessages(chatID string) ([]*types.Message, error)
- func (a *WhisperServiceTransport) RetrieveRawAll() (map[Filter][]*types.Message, error)
- func (a *WhisperServiceTransport) SendMessagesRequest(ctx context.Context, peerID []byte, from, to uint32, previousCursor []byte) (cursor []byte, err error)
- func (a *WhisperServiceTransport) SendPrivateOnDiscovery(ctx context.Context, newMessage *types.NewMessage, publicKey *ecdsa.PublicKey) ([]byte, error)
- func (a *WhisperServiceTransport) SendPrivateWithPartitioned(ctx context.Context, newMessage *types.NewMessage, publicKey *ecdsa.PublicKey) ([]byte, error)
- func (a *WhisperServiceTransport) SendPrivateWithSharedSecret(ctx context.Context, newMessage *types.NewMessage, publicKey *ecdsa.PublicKey, ...) ([]byte, error)
- func (a *WhisperServiceTransport) SendPublic(ctx context.Context, newMessage *types.NewMessage, chatName string) ([]byte, error)
- func (a *WhisperServiceTransport) Stop() error
- func (a *WhisperServiceTransport) Track(identifiers [][]byte, hash []byte, newMessage *types.NewMessage)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoMailservers returned if there is no configured mailservers that can be used. ErrNoMailservers = errors.New("no configured mailservers") )
Functions ¶
func ContactCodeTopic ¶
func DefaultWhisperMessage ¶
func DefaultWhisperMessage() types.NewMessage
Types ¶
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 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 )
type EnvelopesMonitor ¶
type EnvelopesMonitor struct {
// contains filtered or unexported fields
}
EnvelopesMonitor is responsible for monitoring whisper envelopes state.
func NewEnvelopesMonitor ¶
func NewEnvelopesMonitor(w types.Whisper, config EnvelopesMonitorConfig) *EnvelopesMonitor
NewEnvelopesMonitor returns a pointer to an instance of the EnvelopesMonitor.
func (*EnvelopesMonitor) Add ¶
func (m *EnvelopesMonitor) Add(identifiers [][]byte, envelopeHash types.Hash, message types.NewMessage)
Add hash to a tracker.
func (*EnvelopesMonitor) GetState ¶
func (m *EnvelopesMonitor) GetState(hash types.Hash) EnvelopeState
type EnvelopesMonitorConfig ¶
type Filter ¶
type Filter struct {
// ChatID is the identifier of the chat
ChatID string `json:"chatId"`
// FilterID the whisper filter id generated
FilterID string `json:"filterId"`
// SymKeyID is the symmetric key id used for symmetric filters
SymKeyID string `json:"symKeyId"`
// OneToOne tells us if we need to use asymmetric encryption for this chat
OneToOne bool `json:"oneToOne"`
// Identity is the public key of the other recipient for non-public filters.
// It's encoded using encoding/hex.
Identity string `json:"identity"`
// Topic is the whisper topic
Topic types.TopicType `json:"topic"`
// Discovery is whether this is a discovery topic
Discovery bool `json:"discovery"`
// Negotiated tells us whether is a negotiated topic
Negotiated bool `json:"negotiated"`
// Listen is whether we are actually listening for messages on this chat, or the filter is only created in order to be able to post on the topic
Listen bool `json:"listen"`
}
TODO: revise fields encoding/decoding. Some are encoded using hexutil and some using encoding/hex.
type Option ¶
type Option func(*WhisperServiceTransport) error
type RequestOptions ¶
type WhisperServiceTransport ¶
type WhisperServiceTransport struct {
// contains filtered or unexported fields
}
WhisperServiceTransport is a transport based on Whisper service.
func NewWhisperServiceTransport ¶
func NewWhisperServiceTransport( shh types.Whisper, privateKey *ecdsa.PrivateKey, db *sql.DB, mailservers []string, envelopesMonitorConfig *EnvelopesMonitorConfig, logger *zap.Logger, opts ...Option, ) (*WhisperServiceTransport, error)
NewWhisperServiceTransport returns a new WhisperServiceTransport. TODO: leaving a chat should verify that for a given public key
there are no other chats. It may happen that we leave a private chat but still have a public chat for a given public key.
func (*WhisperServiceTransport) Filters ¶
func (a *WhisperServiceTransport) Filters() []*Filter
func (*WhisperServiceTransport) InitFilters ¶
func (*WhisperServiceTransport) JoinGroup ¶
func (a *WhisperServiceTransport) JoinGroup(publicKeys []*ecdsa.PublicKey) error
func (*WhisperServiceTransport) JoinPrivate ¶
func (a *WhisperServiceTransport) JoinPrivate(publicKey *ecdsa.PublicKey) error
func (*WhisperServiceTransport) JoinPublic ¶
func (a *WhisperServiceTransport) JoinPublic(chatID string) error
func (*WhisperServiceTransport) LeaveGroup ¶
func (a *WhisperServiceTransport) LeaveGroup(publicKeys []*ecdsa.PublicKey) error
func (*WhisperServiceTransport) LeavePrivate ¶
func (a *WhisperServiceTransport) LeavePrivate(publicKey *ecdsa.PublicKey) error
func (*WhisperServiceTransport) LeavePublic ¶
func (a *WhisperServiceTransport) LeavePublic(chatID string) error
func (*WhisperServiceTransport) LoadFilters ¶
func (a *WhisperServiceTransport) LoadFilters(filters []*Filter) ([]*Filter, error)
DEPRECATED
func (*WhisperServiceTransport) ProcessNegotiatedSecret ¶
func (a *WhisperServiceTransport) ProcessNegotiatedSecret(secret types.NegotiatedSecret) (*Filter, error)
func (*WhisperServiceTransport) RemoveFilters ¶
func (a *WhisperServiceTransport) RemoveFilters(filters []*Filter) error
DEPRECATED
func (*WhisperServiceTransport) Reset ¶
func (a *WhisperServiceTransport) Reset() error
func (*WhisperServiceTransport) RetrieveAllMessages ¶
func (a *WhisperServiceTransport) RetrieveAllMessages() ([]Message, error)
func (*WhisperServiceTransport) RetrievePrivateMessages ¶
func (*WhisperServiceTransport) RetrievePublicMessages ¶
func (a *WhisperServiceTransport) RetrievePublicMessages(chatID string) ([]*types.Message, error)
func (*WhisperServiceTransport) RetrieveRawAll ¶
func (a *WhisperServiceTransport) RetrieveRawAll() (map[Filter][]*types.Message, error)
func (*WhisperServiceTransport) SendMessagesRequest ¶
func (a *WhisperServiceTransport) SendMessagesRequest( ctx context.Context, peerID []byte, from, to uint32, previousCursor []byte, ) (cursor []byte, err error)
RequestHistoricMessages requests historic messages for all registered filters.
func (*WhisperServiceTransport) SendPrivateOnDiscovery ¶
func (a *WhisperServiceTransport) SendPrivateOnDiscovery(ctx context.Context, newMessage *types.NewMessage, publicKey *ecdsa.PublicKey) ([]byte, error)
func (*WhisperServiceTransport) SendPrivateWithPartitioned ¶
func (a *WhisperServiceTransport) SendPrivateWithPartitioned(ctx context.Context, newMessage *types.NewMessage, publicKey *ecdsa.PublicKey) ([]byte, error)
func (*WhisperServiceTransport) SendPrivateWithSharedSecret ¶
func (a *WhisperServiceTransport) SendPrivateWithSharedSecret(ctx context.Context, newMessage *types.NewMessage, publicKey *ecdsa.PublicKey, secret []byte) ([]byte, error)
func (*WhisperServiceTransport) SendPublic ¶
func (a *WhisperServiceTransport) SendPublic(ctx context.Context, newMessage *types.NewMessage, chatName string) ([]byte, error)
SendPublic sends a new message using the Whisper service. For public filters, chat name is used as an ID as well as a topic.
func (*WhisperServiceTransport) Stop ¶
func (a *WhisperServiceTransport) Stop() error
func (*WhisperServiceTransport) Track ¶
func (a *WhisperServiceTransport) Track(identifiers [][]byte, hash []byte, newMessage *types.NewMessage)