2020-01-13 19:17:30 +00:00
|
|
|
package types
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/ecdsa"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Whisper represents a dark communication interface through the Ethereum
|
|
|
|
// network, using its very own P2P communication layer.
|
|
|
|
type Waku interface {
|
|
|
|
PublicWakuAPI() PublicWakuAPI
|
|
|
|
|
2021-07-21 19:02:50 +00:00
|
|
|
// Waku protocol version
|
|
|
|
Version() uint
|
|
|
|
|
2021-08-30 14:57:28 +00:00
|
|
|
// PeerCount
|
|
|
|
PeerCount() int
|
|
|
|
|
|
|
|
Peers() map[string][]string
|
|
|
|
|
2021-11-22 13:40:14 +00:00
|
|
|
StartDiscV5() error
|
|
|
|
|
|
|
|
StopDiscV5() error
|
|
|
|
|
2021-09-10 17:06:06 +00:00
|
|
|
AddStorePeer(address string) (string, error)
|
2021-08-30 14:57:28 +00:00
|
|
|
|
2021-09-10 17:06:06 +00:00
|
|
|
AddRelayPeer(address string) (string, error)
|
|
|
|
|
|
|
|
DialPeer(address string) error
|
|
|
|
|
|
|
|
DialPeerByID(peerID string) error
|
2021-08-30 14:57:28 +00:00
|
|
|
|
|
|
|
DropPeer(peerID string) error
|
|
|
|
|
2020-01-13 19:17:30 +00:00
|
|
|
// MinPow returns the PoW value required by this node.
|
|
|
|
MinPow() float64
|
|
|
|
// BloomFilter returns the aggregated bloom filter for all the topics of interest.
|
|
|
|
// The nodes are required to send only messages that match the advertised bloom filter.
|
|
|
|
// If a message does not match the bloom, it will tantamount to spam, and the peer will
|
|
|
|
// be disconnected.
|
|
|
|
BloomFilter() []byte
|
|
|
|
// SetTimeSource assigns a particular source of time to a whisper object.
|
|
|
|
SetTimeSource(timesource func() time.Time)
|
|
|
|
// GetCurrentTime returns current time.
|
|
|
|
GetCurrentTime() time.Time
|
|
|
|
|
|
|
|
// GetPrivateKey retrieves the private key of the specified identity.
|
|
|
|
GetPrivateKey(id string) (*ecdsa.PrivateKey, error)
|
|
|
|
|
|
|
|
SubscribeEnvelopeEvents(events chan<- EnvelopeEvent) Subscription
|
|
|
|
|
|
|
|
// AddKeyPair imports a asymmetric private key and returns a deterministic identifier.
|
|
|
|
AddKeyPair(key *ecdsa.PrivateKey) (string, error)
|
|
|
|
// DeleteKeyPair deletes the key with the specified ID if it exists.
|
|
|
|
DeleteKeyPair(keyID string) bool
|
|
|
|
AddSymKeyDirect(key []byte) (string, error)
|
|
|
|
AddSymKeyFromPassword(password string) (string, error)
|
|
|
|
DeleteSymKey(id string) bool
|
|
|
|
GetSymKey(id string) ([]byte, error)
|
2020-11-03 12:42:42 +00:00
|
|
|
MaxMessageSize() uint32
|
2020-01-13 19:17:30 +00:00
|
|
|
|
2021-08-03 19:27:15 +00:00
|
|
|
GetStats() StatsSummary
|
|
|
|
|
2020-01-13 19:17:30 +00:00
|
|
|
Subscribe(opts *SubscriptionOptions) (string, error)
|
|
|
|
GetFilter(id string) Filter
|
|
|
|
Unsubscribe(id string) error
|
2021-01-14 22:15:13 +00:00
|
|
|
UnsubscribeMany(ids []string) error
|
2020-01-13 19:17:30 +00:00
|
|
|
|
|
|
|
// RequestHistoricMessages sends a message with p2pRequestCode to a specific peer,
|
|
|
|
// which is known to implement MailServer interface, and is supposed to process this
|
|
|
|
// request and respond with a number of peer-to-peer messages (possibly expired),
|
|
|
|
// which are not supposed to be forwarded any further.
|
|
|
|
// The whisper protocol is agnostic of the format and contents of envelope.
|
|
|
|
// A timeout of 0 never expires.
|
|
|
|
RequestHistoricMessagesWithTimeout(peerID []byte, envelope Envelope, timeout time.Duration) error
|
|
|
|
// SendMessagesRequest sends a MessagesRequest. This is an equivalent to RequestHistoricMessages
|
|
|
|
// in terms of the functionality.
|
|
|
|
SendMessagesRequest(peerID []byte, request MessagesRequest) error
|
2021-06-16 20:19:45 +00:00
|
|
|
|
|
|
|
// RequestStoreMessages uses the WAKU2-STORE protocol to request historic messages
|
2021-07-21 19:02:50 +00:00
|
|
|
RequestStoreMessages(peerID []byte, request MessagesRequest) (*StoreRequestCursor, error)
|
2020-01-13 19:17:30 +00:00
|
|
|
}
|