Documentation ¶
Index ¶
- Variables
- func ContactCodeTopic(publicKey *ecdsa.PublicKey) string
- func DiscoveryTopic() string
- func NegotiatedTopic(publicKey *ecdsa.PublicKey) string
- func PartitionedTopic(publicKey *ecdsa.PublicKey) string
- func PersonalDiscoveryTopic(publicKey *ecdsa.PublicKey) string
- func PubkeyToHex(key *ecdsa.PublicKey) string
- func PublicKeyToStr(publicKey *ecdsa.PublicKey) string
- func StrToPublicKey(str string) (*ecdsa.PublicKey, error)
- func ToTopic(s string) []byte
- type EnvelopeEventsHandler
- type EnvelopeState
- type EnvelopesMonitor
- type EnvelopesMonitorConfig
- type Filter
- type FiltersManager
- func (f *FiltersManager) Filter(chatID string) *Filter
- func (f *FiltersManager) FilterByChatID(chatID string) *Filter
- func (f *FiltersManager) FilterByFilterID(filterID string) *Filter
- func (f *FiltersManager) FilterByTopic(topic []byte) *Filter
- func (f *FiltersManager) Filters() (result []*Filter)
- func (f *FiltersManager) FiltersByIdentities(identities []string) []*Filter
- func (f *FiltersManager) GetNegotiated(identity *ecdsa.PublicKey) *Filter
- func (f *FiltersManager) Init(chatIDs []string, publicKeys []*ecdsa.PublicKey) ([]*Filter, error)
- func (f *FiltersManager) InitCommunityFilters(pks []*ecdsa.PrivateKey) ([]*Filter, error)
- func (f *FiltersManager) InitPublicFilters(chatIDs []string) ([]*Filter, error)
- func (f *FiltersManager) InitWithFilters(filters []*Filter) ([]*Filter, error)
- func (f *FiltersManager) LoadContactCode(pubKey *ecdsa.PublicKey) (*Filter, error)
- func (f *FiltersManager) LoadDiscovery() ([]*Filter, error)
- func (f *FiltersManager) LoadEphemeral(publicKey *ecdsa.PublicKey, identity *ecdsa.PrivateKey, listen bool) (*Filter, error)
- func (f *FiltersManager) LoadNegotiated(secret types.NegotiatedSecret) (*Filter, error)
- func (f *FiltersManager) LoadPartitioned(publicKey *ecdsa.PublicKey, identity *ecdsa.PrivateKey, listen bool) (*Filter, error)
- func (f *FiltersManager) LoadPersonal(publicKey *ecdsa.PublicKey, identity *ecdsa.PrivateKey, listen bool) (*Filter, error)
- func (f *FiltersManager) LoadPublic(chatID string) (*Filter, error)
- func (f *FiltersManager) PersonalTopicFilter() *Filter
- func (f *FiltersManager) Remove(filters ...*Filter) error
- func (f *FiltersManager) RemoveFilterByChatID(chatID string) (*Filter, error)
- func (f *FiltersManager) RemoveNoListenFilters() error
- func (f *FiltersManager) Reset() error
- type FiltersService
- type KeysPersistence
- type Option
- type ProcessedMessageIDsCache
- type RawFilter
- type SqlitePersistence
- type Transport
- func (t *Transport) AddRelayPeer(address string) (peer.ID, error)
- func (t *Transport) AddStorePeer(address string) (peer.ID, error)
- func (t *Transport) BloomFilter() []byte
- func (t *Transport) CleanMessagesProcessed(timestamp uint64) error
- func (t *Transport) ClearProcessedMessageIDsCache() error
- func (t *Transport) ConfirmMessagesProcessed(ids []string, timestamp uint64) error
- func (t *Transport) ConnectionChanged(state connection.State)
- func (t *Transport) DialPeer(address string) error
- func (t *Transport) DialPeerByID(peerID string) error
- func (t *Transport) DropPeer(peerID string) error
- func (t *Transport) FilterByChatID(chatID string) *Filter
- func (t *Transport) FilterByTopic(topic []byte) *Filter
- func (t *Transport) Filters() []*Filter
- func (t *Transport) FiltersByIdentities(identities []string) []*Filter
- func (t *Transport) GetCurrentTime() uint64
- func (t *Transport) GetStats() types.StatsSummary
- func (t *Transport) InitCommunityFilters(pks []*ecdsa.PrivateKey) ([]*Filter, error)
- func (t *Transport) InitFilters(chatIDs []string, publicKeys []*ecdsa.PublicKey) ([]*Filter, error)
- func (t *Transport) InitPublicFilters(chatIDs []string) ([]*Filter, error)
- func (t *Transport) JoinGroup(publicKeys []*ecdsa.PublicKey) ([]*Filter, error)
- func (t *Transport) JoinPrivate(publicKey *ecdsa.PublicKey) (*Filter, error)
- func (t *Transport) JoinPublic(chatID string) (*Filter, error)
- func (t *Transport) LeavePublic(chatID string) error
- func (t *Transport) ListenAddresses() ([]string, error)
- func (t *Transport) LoadFilters(filters []*Filter) ([]*Filter, error)
- func (t *Transport) LoadKeyFilters(key *ecdsa.PrivateKey) (*Filter, error)
- func (t *Transport) MarkP2PMessageAsProcessed(hash common.Hash)
- func (t *Transport) MaxMessageSize() uint32
- func (t *Transport) PeerCount() int
- func (t *Transport) Peers() map[string]types.WakuV2Peer
- func (t *Transport) PersonalTopicFilter() *Filter
- func (t *Transport) ProcessNegotiatedSecret(secret types.NegotiatedSecret) (*Filter, error)
- func (t *Transport) ProcessingP2PMessages() bool
- func (t *Transport) RemoveFilterByChatID(chatID string) (*Filter, error)
- func (t *Transport) RemoveFilters(filters []*Filter) error
- func (t *Transport) ResetFilters() error
- func (t *Transport) RetrieveRawAll() (map[Filter][]*types.Message, error)
- func (t *Transport) SendCommunityMessage(ctx context.Context, newMessage *types.NewMessage, publicKey *ecdsa.PublicKey) ([]byte, error)
- func (t *Transport) SendMessagesRequest(ctx context.Context, peerID []byte, from, to uint32, previousCursor []byte, ...) (cursor []byte, storeCursor *types.StoreRequestCursor, err error)
- func (t *Transport) SendMessagesRequestForFilter(ctx context.Context, peerID []byte, from, to uint32, previousCursor []byte, ...) (cursor []byte, storeCursor *types.StoreRequestCursor, err error)
- func (t *Transport) SendMessagesRequestForTopics(ctx context.Context, peerID []byte, from, to uint32, previousCursor []byte, ...) (cursor []byte, storeCursor *types.StoreRequestCursor, err error)
- func (t *Transport) SendPrivateOnPersonalTopic(ctx context.Context, newMessage *types.NewMessage, publicKey *ecdsa.PublicKey) ([]byte, error)
- func (t *Transport) SendPrivateWithPartitioned(ctx context.Context, newMessage *types.NewMessage, publicKey *ecdsa.PublicKey) ([]byte, error)
- func (t *Transport) SendPrivateWithSharedSecret(ctx context.Context, newMessage *types.NewMessage, publicKey *ecdsa.PublicKey, ...) ([]byte, error)
- func (t *Transport) SendPublic(ctx context.Context, newMessage *types.NewMessage, chatName string) ([]byte, error)
- func (t *Transport) SetEnvelopeEventsHandler(handler EnvelopeEventsHandler) error
- func (t *Transport) StartDiscV5() error
- func (t *Transport) Stop() error
- func (t *Transport) StopDiscV5() error
- func (t *Transport) SubscribeToConnStatusChanges() (*types.ConnStatusSubscription, error)
- func (t *Transport) Track(identifiers [][]byte, hash []byte, newMessage *types.NewMessage)
- func (t *Transport) WakuVersion() uint
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 DiscoveryTopic ¶
func DiscoveryTopic() string
func NegotiatedTopic ¶
func PartitionedTopic ¶
PartitionedTopic returns the associated partitioned topic string with the given public key.
func PersonalDiscoveryTopic ¶
func PubkeyToHex ¶ added in v0.72.0
func PublicKeyToStr ¶
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 ¶ added in v0.76.6
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 waku queue. EnvelopePosted EnvelopeState = iota + 1 // EnvelopeSent is set when envelope is sent to at least one peer. EnvelopeSent )
type EnvelopesMonitor ¶ added in v0.76.6
type EnvelopesMonitor struct {
// contains filtered or unexported fields
}
EnvelopesMonitor is responsible for monitoring waku envelopes state.
func NewEnvelopesMonitor ¶ added in v0.76.6
func NewEnvelopesMonitor(w types.Waku, config EnvelopesMonitorConfig) *EnvelopesMonitor
NewEnvelopesMonitor returns a pointer to an instance of the EnvelopesMonitor.
func (*EnvelopesMonitor) Add ¶ added in v0.76.6
func (m *EnvelopesMonitor) Add(identifiers [][]byte, envelopeHash types.Hash, message types.NewMessage)
Add hash to a tracker.
func (*EnvelopesMonitor) GetState ¶ added in v0.76.6
func (m *EnvelopesMonitor) GetState(hash types.Hash) EnvelopeState
func (*EnvelopesMonitor) Start ¶ added in v0.76.6
func (m *EnvelopesMonitor) Start()
Start processing events.
func (*EnvelopesMonitor) Stop ¶ added in v0.76.6
func (m *EnvelopesMonitor) Stop()
Stop process events.
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"` // Ephemeral indicates that this is an ephemeral filter Ephemeral bool `json:"ephemeral"` // Priority Priority uint64 }
TODO: revise fields encoding/decoding. Some are encoded using hexutil and some using encoding/hex.
type FiltersManager ¶
type FiltersManager struct {
// contains filtered or unexported fields
}
func NewFiltersManager ¶
func NewFiltersManager(persistence KeysPersistence, service FiltersService, privateKey *ecdsa.PrivateKey, logger *zap.Logger) (*FiltersManager, error)
NewFiltersManager returns a new filtersManager.
func (*FiltersManager) Filter ¶
func (f *FiltersManager) Filter(chatID string) *Filter
func (*FiltersManager) FilterByChatID ¶ added in v0.76.3
func (f *FiltersManager) FilterByChatID(chatID string) *Filter
FilterByChatID returns a Filter for given chat id
func (*FiltersManager) FilterByFilterID ¶
func (f *FiltersManager) FilterByFilterID(filterID string) *Filter
FilterByFilterID returns a Filter with a given Whisper filter ID.
func (*FiltersManager) FilterByTopic ¶ added in v0.100.0
func (f *FiltersManager) FilterByTopic(topic []byte) *Filter
func (*FiltersManager) Filters ¶
func (f *FiltersManager) Filters() (result []*Filter)
func (*FiltersManager) FiltersByIdentities ¶ added in v0.79.0
func (f *FiltersManager) FiltersByIdentities(identities []string) []*Filter
FiltersByIdentities returns an array of filters for given list of public keys
func (*FiltersManager) GetNegotiated ¶
func (f *FiltersManager) GetNegotiated(identity *ecdsa.PublicKey) *Filter
GetNegotiated returns a negotiated chat given an identity
func (*FiltersManager) InitCommunityFilters ¶ added in v0.72.0
func (f *FiltersManager) InitCommunityFilters(pks []*ecdsa.PrivateKey) ([]*Filter, error)
func (*FiltersManager) InitPublicFilters ¶ added in v0.67.0
func (f *FiltersManager) InitPublicFilters(chatIDs []string) ([]*Filter, error)
func (*FiltersManager) InitWithFilters ¶
func (f *FiltersManager) InitWithFilters(filters []*Filter) ([]*Filter, error)
DEPRECATED
func (*FiltersManager) LoadContactCode ¶
func (f *FiltersManager) LoadContactCode(pubKey *ecdsa.PublicKey) (*Filter, error)
LoadContactCode creates a filter for the advertise topic for a given public key.
func (*FiltersManager) LoadDiscovery ¶
func (f *FiltersManager) LoadDiscovery() ([]*Filter, error)
LoadDiscovery adds 1 discovery filter for the personal discovery topic.
func (*FiltersManager) LoadEphemeral ¶ added in v0.69.0
func (f *FiltersManager) LoadEphemeral(publicKey *ecdsa.PublicKey, identity *ecdsa.PrivateKey, listen bool) (*Filter, error)
LoadEphemeral creates a filter for a partitioned/personal topic.
func (*FiltersManager) LoadNegotiated ¶
func (f *FiltersManager) LoadNegotiated(secret types.NegotiatedSecret) (*Filter, error)
LoadNegotiated loads a negotiated secret as a filter.
func (*FiltersManager) LoadPartitioned ¶
func (f *FiltersManager) LoadPartitioned(publicKey *ecdsa.PublicKey, identity *ecdsa.PrivateKey, listen bool) (*Filter, error)
LoadPartitioned creates a filter for a partitioned topic.
func (*FiltersManager) LoadPersonal ¶ added in v0.69.0
func (f *FiltersManager) LoadPersonal(publicKey *ecdsa.PublicKey, identity *ecdsa.PrivateKey, listen bool) (*Filter, error)
LoadPersonal creates a filter for a personal topic.
func (*FiltersManager) LoadPublic ¶
func (f *FiltersManager) LoadPublic(chatID string) (*Filter, error)
LoadPublic adds a filter for a public chat.
func (*FiltersManager) PersonalTopicFilter ¶ added in v0.90.0
func (f *FiltersManager) PersonalTopicFilter() *Filter
func (*FiltersManager) Remove ¶
func (f *FiltersManager) Remove(filters ...*Filter) error
Remove remove all the filters associated with a chat/identity
func (*FiltersManager) RemoveFilterByChatID ¶ added in v0.67.0
func (f *FiltersManager) RemoveFilterByChatID(chatID string) (*Filter, error)
Remove remove all the filters associated with a chat/identity
func (*FiltersManager) RemoveNoListenFilters ¶ added in v0.69.0
func (f *FiltersManager) RemoveNoListenFilters() error
Remove remove all the filters associated with a chat/identity
func (*FiltersManager) Reset ¶
func (f *FiltersManager) Reset() error
type FiltersService ¶
type FiltersService interface { AddKeyPair(key *ecdsa.PrivateKey) (string, error) DeleteKeyPair(keyID string) bool AddSymKeyDirect(key []byte) (string, error) AddSymKeyFromPassword(password string) (string, error) GetSymKey(id string) ([]byte, error) DeleteSymKey(id string) bool Subscribe(opts *types.SubscriptionOptions) (string, error) Unsubscribe(id string) error UnsubscribeMany(ids []string) error }
type KeysPersistence ¶
type ProcessedMessageIDsCache ¶ added in v0.68.6
type ProcessedMessageIDsCache struct {
// contains filtered or unexported fields
}
func NewProcessedMessageIDsCache ¶ added in v0.68.6
func NewProcessedMessageIDsCache(db *sql.DB) *ProcessedMessageIDsCache
func (*ProcessedMessageIDsCache) Add ¶ added in v0.68.6
func (c *ProcessedMessageIDsCache) Add(ids []string, timestamp uint64) (err error)
func (*ProcessedMessageIDsCache) Clean ¶ added in v0.68.6
func (c *ProcessedMessageIDsCache) Clean(timestamp uint64) error
func (*ProcessedMessageIDsCache) Clear ¶ added in v0.79.0
func (c *ProcessedMessageIDsCache) Clear() error
type SqlitePersistence ¶ added in v0.80.2
type SqlitePersistence struct {
// contains filtered or unexported fields
}
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport is a transport based on Whisper service.
func NewTransport ¶ added in v0.76.6
func NewTransport( waku types.Waku, privateKey *ecdsa.PrivateKey, db *sql.DB, sqlitePersistenceTableName string, mailservers []string, envelopesMonitorConfig *EnvelopesMonitorConfig, logger *zap.Logger, opts ...Option, ) (*Transport, error)
NewTransport returns a new Transport. 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 (*Transport) AddRelayPeer ¶ added in v0.88.4
func (*Transport) AddStorePeer ¶ added in v0.88.4
func (*Transport) BloomFilter ¶ added in v0.85.0
func (*Transport) CleanMessagesProcessed ¶ added in v0.68.6
CleanMessagesProcessed clears the messages that are older than timestamp
func (*Transport) ClearProcessedMessageIDsCache ¶ added in v0.79.0
func (*Transport) ConfirmMessagesProcessed ¶ added in v0.68.6
ConfirmMessagesProcessed marks the messages as processed in the cache so they won't be passed to the next layer anymore
func (*Transport) ConnectionChanged ¶ added in v0.117.1
func (t *Transport) ConnectionChanged(state connection.State)
func (*Transport) DialPeerByID ¶ added in v0.88.4
func (*Transport) FilterByChatID ¶ added in v0.76.3
func (*Transport) FilterByTopic ¶ added in v0.100.0
func (*Transport) FiltersByIdentities ¶ added in v0.79.0
func (*Transport) GetCurrentTime ¶
GetCurrentTime returns the current unix timestamp in milliseconds
func (*Transport) GetStats ¶ added in v0.83.8
func (t *Transport) GetStats() types.StatsSummary
func (*Transport) InitCommunityFilters ¶ added in v0.72.0
func (t *Transport) InitCommunityFilters(pks []*ecdsa.PrivateKey) ([]*Filter, error)
func (*Transport) InitFilters ¶
func (*Transport) InitPublicFilters ¶ added in v0.67.0
func (*Transport) JoinPrivate ¶
func (*Transport) LeavePublic ¶
func (*Transport) ListenAddresses ¶ added in v0.115.4
func (*Transport) LoadFilters ¶
func (*Transport) LoadKeyFilters ¶ added in v0.56.1
func (t *Transport) LoadKeyFilters(key *ecdsa.PrivateKey) (*Filter, error)
func (*Transport) MarkP2PMessageAsProcessed ¶ added in v0.91.12
func (*Transport) MaxMessageSize ¶ added in v0.63.2
func (*Transport) PersonalTopicFilter ¶ added in v0.90.0
func (*Transport) ProcessNegotiatedSecret ¶
func (t *Transport) ProcessNegotiatedSecret(secret types.NegotiatedSecret) (*Filter, error)
func (*Transport) ProcessingP2PMessages ¶ added in v0.91.12
func (*Transport) RemoveFilterByChatID ¶ added in v0.67.0
func (*Transport) RemoveFilters ¶
func (*Transport) ResetFilters ¶
func (*Transport) RetrieveRawAll ¶
func (*Transport) SendCommunityMessage ¶ added in v0.72.0
func (*Transport) SendMessagesRequest ¶
func (t *Transport) SendMessagesRequest( ctx context.Context, peerID []byte, from, to uint32, previousCursor []byte, previousStoreCursor *types.StoreRequestCursor, waitForResponse bool, ) (cursor []byte, storeCursor *types.StoreRequestCursor, err error)
RequestHistoricMessages requests historic messages for all registered filters.
func (*Transport) SendMessagesRequestForFilter ¶ added in v0.76.3
func (*Transport) SendMessagesRequestForTopics ¶ added in v0.79.0
func (*Transport) SendPrivateOnPersonalTopic ¶ added in v0.69.0
func (*Transport) SendPrivateWithPartitioned ¶
func (*Transport) SendPrivateWithSharedSecret ¶
func (*Transport) SendPublic ¶
func (t *Transport) 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 (*Transport) SetEnvelopeEventsHandler ¶ added in v0.64.7
func (t *Transport) SetEnvelopeEventsHandler(handler EnvelopeEventsHandler) error
func (*Transport) StartDiscV5 ¶ added in v0.91.8
func (*Transport) StopDiscV5 ¶ added in v0.91.8
func (*Transport) SubscribeToConnStatusChanges ¶ added in v0.93.2
func (t *Transport) SubscribeToConnStatusChanges() (*types.ConnStatusSubscription, error)
func (*Transport) Track ¶
func (t *Transport) Track(identifiers [][]byte, hash []byte, newMessage *types.NewMessage)