types

package
v0.184.45 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2024 License: MPL-2.0 Imports: 23 Imported by: 5

Documentation

Index

Constants

View Source
const (
	// PubKeyLength represents the length (in bytes) of an uncompressed public key
	PubKeyLength = 512 / 8
	// AesKeyLength represents the length (in bytes) of an private key
	AesKeyLength = 256 / 8
)
View Source
const (
	// EnvelopeTimeNotSynced represents the code passed to notify of a clock skew situation
	EnvelopeTimeNotSynced uint = 1000
	// EnvelopeOtherError represents the code passed to notify of a generic error situation
	EnvelopeOtherError
)
View Source
const (
	// TopicLength is the expected length of the topic, in bytes
	TopicLength = 4
	// BloomFilterSize is the expected length of a bloom filter byte array, in bytes
	BloomFilterSize = 64
)
View Source
const AddressLength = 20

AddressLength is the expected length of the address

View Source
const (
	// HashLength is the expected length of the hash
	HashLength = 32
)
View Source
const (
	// MaxLimitInMessagesRequest represents the maximum number of messages
	// that can be requested from the mailserver
	MaxLimitInMessagesRequest = 1000
)

Variables

View Source
var (
	ErrEmptyString   = &decError{"empty hex string"}
	ErrSyntax        = &decError{"invalid hex string"}
	ErrMissingPrefix = &decError{"hex string without 0x prefix"}
	ErrOddLength     = &decError{"hex string of odd length"}
	ErrEmptyNumber   = &decError{"hex string \"0x\""}
	ErrLeadingZero   = &decError{"hex number with leading zero digits"}
	ErrUint64Range   = &decError{"hex number > 64 bits"}
	ErrUintRange     = &decError{fmt.Sprintf("hex number > %d bits", uintBits)}
	ErrBig256Range   = &decError{"hex number > 256 bits"}
)

Errors

Functions

func BloomFilterMatch

func BloomFilterMatch(filter, sample []byte) bool

BloomFilterMatch returns true if a sample matches a bloom filter

func Bytes2Hex

func Bytes2Hex(d []byte) string

Bytes2Hex returns the hexadecimal encoding of d.

func DecodeHex

func DecodeHex(input string) ([]byte, error)

DecodeHex decodes a hex string with 0x prefix.

func EncodeHex

func EncodeHex(b []byte) string

EncodeHex encodes b as a hex string with 0x prefix.

func EncodeHexes added in v0.171.21

func EncodeHexes(bs [][]byte) []string

EncodeHex encodes bs as a hex strings with 0x prefix.

func FromHex

func FromHex(s string) []byte

FromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x".

func Hex2Bytes

func Hex2Bytes(str string) []byte

Hex2Bytes returns the bytes represented by the hexadecimal string str.

func IsHexAddress

func IsHexAddress(s string) bool

IsHexAddress verifies whether a string can represent a valid hex-encoded Ethereum address or not.

func MakeFullNodeBloom

func MakeFullNodeBloom() []byte

MakeFullNodeBloom returns a bloom filter which matches all topics

func MustDecodeHex

func MustDecodeHex(input string) []byte

MustDecodeHex decodes a hex string with 0x prefix. It panics for invalid input.

func ToHex added in v0.171.5

func ToHex(bytes []byte) string

ToHex returns the hex string representation of bytes with 0x prefix.

func TopicToBloom

func TopicToBloom(topic TopicType) []byte

TopicToBloom converts the topic (4 bytes) to the bloom filter (64 bytes)

func TopicTypeToByteArray added in v0.98.1

func TopicTypeToByteArray(t TopicType) []byte

func UnmarshalFixedHexText

func UnmarshalFixedHexText(typname string, input, out []byte) error

UnmarshalFixedHexText decodes the input as a string with 0x prefix. The length of out determines the required input length. This function is commonly used to implement the UnmarshalText method for fixed-size types.

func UnmarshalFixedJSON

func UnmarshalFixedJSON(typ reflect.Type, input, out []byte) error

UnmarshalFixedJSON decodes the input as a string with 0x prefix. The length of out determines the required input length. This function is commonly used to implement the UnmarshalJSON method for fixed-size types.

func UnmarshalFixedText

func UnmarshalFixedText(typname string, input, out []byte) error

UnmarshalFixedText decodes the input as a string with 0x prefix. The length of out determines the required input length. This function is commonly used to implement the UnmarshalText method for fixed-size types.

func UnmarshalFixedUnprefixedText

func UnmarshalFixedUnprefixedText(typname string, input, out []byte) error

UnmarshalFixedUnprefixedText decodes the input as a string with optional 0x prefix. The length of out determines the required input length. This function is commonly used to implement the UnmarshalText method for fixed-size types.

Types

type Account

type Account struct {
	Address Address `json:"address"` // Ethereum account address derived from the key
	URL     string  `json:"url"`     // Optional resource locator within a backend
}

Account represents an Ethereum account located at a specific location defined by the optional URL field.

type Address

type Address [AddressLength]byte

Address represents the 20 byte address of an Ethereum account.

func BigToAddress

func BigToAddress(b *big.Int) Address

BigToAddress returns Address with byte values of b. If b is larger than len(h), b will be cropped from the left.

func BytesToAddress

func BytesToAddress(b []byte) Address

BytesToAddress returns Address with value b. If b is larger than len(h), b will be cropped from the left.

func HexToAddress

func HexToAddress(s string) Address

HexToAddress returns Address with byte values of s. If s is larger than len(h), s will be cropped from the left.

func (Address) Bytes

func (a Address) Bytes() []byte

Bytes gets the string representation of the underlying address.

func (Address) Format

func (a Address) Format(s fmt.State, c rune)

Format implements fmt.Formatter, forcing the byte slice to be formatted as is, without going through the stringer interface used for logging.

func (Address) Hash

func (a Address) Hash() Hash

Hash converts an address to a hash by left-padding it with zeros.

func (Address) Hex

func (a Address) Hex() string

Hex returns an EIP55-compliant hex string representation of the address.

func (Address) ImplementsGraphQLType

func (a Address) ImplementsGraphQLType(name string) bool

ImplementsGraphQLType returns true if Hash implements the specified GraphQL type.

func (Address) MarshalText

func (a Address) MarshalText() ([]byte, error)

MarshalText returns the hex representation of a.

func (*Address) Scan

func (a *Address) Scan(src interface{}) error

Scan implements Scanner for database/sql.

func (*Address) SetBytes

func (a *Address) SetBytes(b []byte)

SetBytes sets the address to the value of b. If b is larger than len(a) it will panic.

func (Address) String

func (a Address) String() string

String implements fmt.Stringer.

func (*Address) UnmarshalGraphQL

func (a *Address) UnmarshalGraphQL(input interface{}) error

UnmarshalGraphQL unmarshals the provided GraphQL query data.

func (*Address) UnmarshalJSON

func (a *Address) UnmarshalJSON(input []byte) error

UnmarshalJSON parses a hash in hex syntax.

func (*Address) UnmarshalText

func (a *Address) UnmarshalText(input []byte) error

UnmarshalText parses a hash in hex syntax.

func (Address) Value

func (a Address) Value() (driver.Value, error)

Value implements valuer for database/sql.

type ConnStatus added in v0.93.2

type ConnStatus struct {
	IsOnline bool                  `json:"isOnline"`
	Peers    map[string]WakuV2Peer `json:"peers"`
}

type ConnStatusSubscription added in v0.93.2

type ConnStatusSubscription struct {
	sync.RWMutex

	ID string
	C  chan ConnStatus
	// contains filtered or unexported fields
}

func NewConnStatusSubscription added in v0.93.2

func NewConnStatusSubscription() *ConnStatusSubscription

func (*ConnStatusSubscription) Active added in v0.93.2

func (u *ConnStatusSubscription) Active() bool

func (*ConnStatusSubscription) Send added in v0.175.3

func (*ConnStatusSubscription) Unsubscribe added in v0.93.2

func (u *ConnStatusSubscription) Unsubscribe()

type Criteria

type Criteria struct {
	SymKeyID     string      `json:"symKeyID"`
	PrivateKeyID string      `json:"privateKeyID"`
	Sig          []byte      `json:"sig"`
	MinPow       float64     `json:"minPow"`
	PubsubTopic  string      `json:"pubsubTopic"`
	Topics       []TopicType `json:"topics"`
	AllowP2P     bool        `json:"allowP2P"`
}

Criteria holds various filter options for inbound messages.

type EnodeID

type EnodeID [32]byte

EnodeID is a unique identifier for each node.

func (EnodeID) String

func (n EnodeID) String() string

ID prints as a long hexadecimal number.

type Envelope

type Envelope interface {
	Wrapped

	Hash() Hash // cached hash of the envelope to avoid rehashing every time
	Bloom() []byte
	PoW() float64
	Expiry() uint32
	TTL() uint32
	Topic() TopicType
	Size() int
}

Envelope represents a clear-text data packet to transmit through the Whisper network. Its contents may or may not be encrypted and signed.

type EnvelopeError

type EnvelopeError struct {
	Hash        Hash
	Code        uint
	Description string
}

EnvelopeError code and optional description of the error.

type EnvelopeEvent

type EnvelopeEvent struct {
	Event EventType
	Hash  Hash
	Batch Hash
	Peer  EnodeID
	Data  interface{}
}

EnvelopeEvent used for envelopes events.

type EventType

type EventType string

EventType used to define known envelope events.

const (
	// EventEnvelopeSent fires when envelope was sent to a peer.
	EventEnvelopeSent EventType = "envelope.sent"
	// EventEnvelopeExpired fires when envelop expired
	EventEnvelopeExpired EventType = "envelope.expired"
	// EventEnvelopeReceived is sent once envelope was received from a peer.
	// EventEnvelopeReceived must be sent to the feed even if envelope was previously in the cache.
	// And event, ideally, should contain information about peer that sent envelope to us.
	EventEnvelopeReceived EventType = "envelope.received"
	// EventBatchAcknowledged is sent when batch of envelopes was acknowledged by a peer.
	EventBatchAcknowledged EventType = "batch.acknowledged"
	// EventEnvelopeAvailable fires when envelop is available for filters
	EventEnvelopeAvailable EventType = "envelope.available"
	// EventMailServerRequestSent fires when such request is sent.
	EventMailServerRequestSent EventType = "mailserver.request.sent"
	// EventMailServerRequestCompleted fires after mailserver sends all the requested messages
	EventMailServerRequestCompleted EventType = "mailserver.request.completed"
	// EventMailServerRequestExpired fires after mailserver the request TTL ends.
	// This event is independent and concurrent to EventMailServerRequestCompleted.
	// Request should be considered as expired only if expiry event was received first.
	EventMailServerRequestExpired EventType = "mailserver.request.expired"
	// EventMailServerEnvelopeArchived fires after an envelope has been archived
	EventMailServerEnvelopeArchived EventType = "mailserver.envelope.archived"
	// EventMailServerSyncFinished fires when the sync of messages is finished.
	EventMailServerSyncFinished EventType = "mailserver.sync.finished"
)

NOTE: This list of event names is extracted from Geth. It must be kept in sync, or otherwise a mapping layer needs to be created

type Filter

type Filter interface {
	ID() string
}

Filter represents a Whisper message filter

type Hash

type Hash [HashLength]byte

Hash represents the 32 byte Keccak256 hash of arbitrary data.

func BytesToHash

func BytesToHash(b []byte) Hash

BytesToHash sets b to hash. If b is larger than len(h), b will be cropped from the left.

func HexToHash

func HexToHash(s string) Hash

HexToHash sets byte representation of s to hash. If b is larger than len(h), b will be cropped from the left.

func (Hash) Bytes

func (h Hash) Bytes() []byte

Bytes gets the byte representation of the underlying hash.

func (*Hash) Hex

func (h *Hash) Hex() string

Hex converts a hash to a hex string.

func (Hash) MarshalText

func (h Hash) MarshalText() ([]byte, error)

MarshalText returns the hex representation of h.

func (*Hash) SetBytes

func (h *Hash) SetBytes(b []byte)

SetBytes sets the hash to the value of b. If b is larger than len(h), b will be cropped from the left.

func (Hash) String

func (h Hash) String() string

String implements the stringer interface and is used also by the logger when doing full logging into a file.

func (*Hash) UnmarshalJSON

func (h *Hash) UnmarshalJSON(input []byte) error

UnmarshalJSON parses a hash in hex syntax.

func (*Hash) UnmarshalText

func (h *Hash) UnmarshalText(input []byte) error

UnmarshalText parses a hash in hex syntax.

type HexBytes

type HexBytes []byte

HexBytes marshals/unmarshals as a JSON string with 0x prefix. The empty slice marshals as "0x".

func (HexBytes) Bytes added in v0.92.6

func (b HexBytes) Bytes() []byte

func (HexBytes) MarshalText

func (b HexBytes) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler

func (HexBytes) String

func (b HexBytes) String() string

String returns the hex encoding of b.

func (*HexBytes) UnmarshalJSON

func (b *HexBytes) UnmarshalJSON(input []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*HexBytes) UnmarshalText

func (b *HexBytes) UnmarshalText(input []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type Key

type Key struct {
	ID uuid.UUID // Version 4 "random" for unique id not derived from key data
	// to simplify lookups we also store the address
	Address Address
	// we only store privkey as pubkey/address can be derived from it
	// privkey in this struct is always in plaintext
	PrivateKey *ecdsa.PrivateKey
	// ExtendedKey is the extended key of the PrivateKey itself, and it's used
	// to derive child keys.
	ExtendedKey *extkeys.ExtendedKey
	// Deprecated: SubAccountIndex
	// It was use in Status to keep track of the number of sub-account created
	// before having multi-account support.
	SubAccountIndex uint32
}

type KeyStore

type KeyStore interface {
	// ImportAccount imports the account specified with privateKey.
	ImportECDSA(priv *ecdsa.PrivateKey, passphrase string) (Account, error)
	// ImportSingleExtendedKey imports an extended key setting it in both the PrivateKey and ExtendedKey fields
	// of the Key struct.
	// ImportExtendedKey is used in older version of Status where PrivateKey is set to be the BIP44 key at index 0,
	// and ExtendedKey is the extended key of the BIP44 key at index 1.
	ImportSingleExtendedKey(extKey *extkeys.ExtendedKey, passphrase string) (Account, error)
	// ImportExtendedKeyForPurpose stores ECDSA key (obtained from extended key) along with CKD#2 (root for sub-accounts)
	// If key file is not found, it is created. Key is encrypted with the given passphrase.
	// Deprecated: status-go is now using ImportSingleExtendedKey
	ImportExtendedKeyForPurpose(keyPurpose extkeys.KeyPurpose, extKey *extkeys.ExtendedKey, passphrase string) (Account, error)
	// AccountDecryptedKey returns decrypted key for account (provided that password is correct).
	AccountDecryptedKey(a Account, auth string) (Account, *Key, error)
	// Delete deletes the key matched by account if the passphrase is correct.
	// If the account contains no filename, the address must match a unique key.
	Delete(a Account) error
}

type MailServerResponse

type MailServerResponse struct {
	LastEnvelopeHash Hash
	Cursor           []byte
	Error            error
}

MailServerResponse is the response payload sent by the mailserver.

type Message

type Message struct {
	Sig          []byte    `json:"sig,omitempty"`
	TTL          uint32    `json:"ttl"`
	Timestamp    uint32    `json:"timestamp"`
	PubsubTopic  string    `json:"pubsubTopic"`
	Topic        TopicType `json:"topic"`
	Payload      []byte    `json:"payload"`
	Padding      []byte    `json:"padding"`
	PoW          float64   `json:"pow"`
	Hash         []byte    `json:"hash"`
	Dst          []byte    `json:"recipientPublicKey,omitempty"`
	P2P          bool      `json:"bool,omitempty"`
	ThirdPartyID string    `json:"thirdPartyId,omitempty"`
}

Message is the RPC representation of a whisper message.

type MessagesRequest

type MessagesRequest struct {
	// ID of the request. The current implementation requires ID to be 32-byte array,
	// however, it's not enforced for future implementation.
	ID []byte `json:"id"`
	// From is a lower bound of time range.
	From uint32 `json:"from"`
	// To is a upper bound of time range.
	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 []byte `json:"cursor"`
	// StoreCursor is used as starting point for WAKUV2 paginatedRequests
	StoreCursor StoreRequestCursor `json:"storeCursor"`
	// Bloom is a filter to match requested messages.
	Bloom []byte `json:"bloom"`
	// PubsubTopic is the gossipsub topic on which the message was broadcasted
	PubsubTopic string `json:"pubsubTopic"`
	// ContentTopics is a list of topics. A returned message should
	// belong to one of the topics from the list.
	ContentTopics [][]byte `json:"contentTopics"`
}

MessagesRequest contains details of a request of historic messages.

func (*MessagesRequest) SetDefaults

func (r *MessagesRequest) SetDefaults(now time.Time)

SetDefaults sets the From and To defaults

type MixedcaseAddress

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

MixedcaseAddress retains the original string, which may or may not be correctly checksummed

func NewMixedcaseAddress

func NewMixedcaseAddress(addr Address) MixedcaseAddress

NewMixedcaseAddress constructor (mainly for testing)

func NewMixedcaseAddressFromString

func NewMixedcaseAddressFromString(hexaddr string) (*MixedcaseAddress, error)

NewMixedcaseAddressFromString is mainly meant for unit-testing

func (*MixedcaseAddress) Address

func (ma *MixedcaseAddress) Address() Address

Address returns the address

func (*MixedcaseAddress) MarshalJSON

func (ma *MixedcaseAddress) MarshalJSON() ([]byte, error)

MarshalJSON marshals the original value

func (*MixedcaseAddress) Original

func (ma *MixedcaseAddress) Original() string

Original returns the mixed-case input string

func (*MixedcaseAddress) String

func (ma *MixedcaseAddress) String() string

String implements fmt.Stringer

func (*MixedcaseAddress) UnmarshalJSON

func (ma *MixedcaseAddress) UnmarshalJSON(input []byte) error

UnmarshalJSON parses MixedcaseAddress

func (*MixedcaseAddress) ValidChecksum

func (ma *MixedcaseAddress) ValidChecksum() bool

ValidChecksum returns true if the address has valid checksum

type NegotiatedSecret

type NegotiatedSecret struct {
	PublicKey *ecdsa.PublicKey
	Key       []byte
}

NegotiatedSecret represents a negotiated secret (both public and private keys)

type NewMessage

type NewMessage struct {
	SymKeyID    string    `json:"symKeyID"`
	PublicKey   []byte    `json:"pubKey"`
	SigID       string    `json:"sig"`
	TTL         uint32    `json:"ttl"`
	PubsubTopic string    `json:"pubsubTopic"`
	Topic       TopicType `json:"topic"`
	Payload     []byte    `json:"payload"`
	Padding     []byte    `json:"padding"`
	PowTime     uint32    `json:"powTime"`
	PowTarget   float64   `json:"powTarget"`
	TargetPeer  string    `json:"targetPeer"`
	Ephemeral   bool      `json:"ephemeral"`
	Priority    *int      `json:"priority"`
}

NewMessage represents a new whisper message that is posted through the RPC.

type Node

type Node interface {
	NewENSVerifier(logger *zap.Logger) enstypes.ENSVerifier
	GetWaku(ctx interface{}) (Waku, error)
	GetWakuV2(ctx interface{}) (Waku, error)
	AddPeer(url string) error
	RemovePeer(url string) error
	PeersCount() int
}

type PeerList added in v0.182.35

type PeerList struct {
	FullMeshPeers []peer.ID `json:"fullMesh"`
	AllPeers      []peer.ID `json:"all"`
}

type PublicWakuAPI

type PublicWakuAPI interface {
	// AddPrivateKey imports the given private key.
	AddPrivateKey(ctx context.Context, privateKey HexBytes) (string, error)
	// GenerateSymKeyFromPassword derives a key from the given password, stores it, and returns its ID.
	GenerateSymKeyFromPassword(ctx context.Context, passwd string) (string, error)
	// DeleteKeyPair removes the key with the given key if it exists.
	DeleteKeyPair(ctx context.Context, key string) (bool, error)

	// Post posts a message on the Whisper network.
	// returns the hash of the message in case of success.
	Post(ctx context.Context, req NewMessage) ([]byte, error)

	// NewMessageFilter creates a new filter that can be used to poll for
	// (new) messages that satisfy the given criteria.
	NewMessageFilter(req Criteria) (string, error)
	// GetFilterMessages returns the messages that match the filter criteria and
	// are received between the last poll and now.
	GetFilterMessages(id string) ([]*Message, error)

	BloomFilter() []byte
}

PublicWakuAPI provides the waku RPC service that can be use publicly without security implications.

type PublicWhisperAPI

type PublicWhisperAPI interface {
	// AddPrivateKey imports the given private key.
	AddPrivateKey(ctx context.Context, privateKey HexBytes) (string, error)
	// GenerateSymKeyFromPassword derives a key from the given password, stores it, and returns its ID.
	GenerateSymKeyFromPassword(ctx context.Context, passwd string) (string, error)
	// DeleteKeyPair removes the key with the given key if it exists.
	DeleteKeyPair(ctx context.Context, key string) (bool, error)

	// Post posts a message on the Whisper network.
	// returns the hash of the message in case of success.
	Post(ctx context.Context, req NewMessage) ([]byte, error)

	// NewMessageFilter creates a new filter that can be used to poll for
	// (new) messages that satisfy the given criteria.
	NewMessageFilter(req Criteria) (string, error)
	// GetFilterMessages returns the messages that match the filter criteria and
	// are received between the last poll and now.
	GetFilterMessages(id string) ([]*Message, error)
	// BloomFilter returns the current bloomfilter of the node
	BloomFilter() []byte
}

PublicWhisperAPI provides the whisper RPC service that can be use publicly without security implications.

type StatsSummary added in v0.83.8

type StatsSummary struct {
	UploadRate   uint64 `json:"uploadRate"`
	DownloadRate uint64 `json:"downloadRate"`
}

type StoreRequestCursor added in v0.83.2

type StoreRequestCursor []byte

type Subscription

type Subscription interface {
	Err() <-chan error // returns the error channel
	Unsubscribe()      // cancels sending of events, closing the error channel
}

Subscription represents a stream of events. The carrier of the events is typically a channel, but isn't part of the interface.

Subscriptions can fail while established. Failures are reported through an error channel. It receives a value if there is an issue with the subscription (e.g. the network connection delivering the events has been closed). Only one value will ever be sent.

The error channel is closed when the subscription ends successfully (i.e. when the source of events is closed). It is also closed when Unsubscribe is called.

The Unsubscribe method cancels the sending of events. You must call Unsubscribe in all cases to ensure that resources related to the subscription are released. It can be called any number of times.

type SubscriptionOptions

type SubscriptionOptions struct {
	PrivateKeyID string
	SymKeyID     string
	PoW          float64
	PubsubTopic  string
	Topics       [][]byte
}

SubscriptionOptions represents the parameters passed to Subscribe() to customize the subscription behavior.

type SyncEventResponse

type SyncEventResponse struct {
	Cursor []byte
	Error  string
}

SyncEventResponse is a response from the Mail Server form which the peer received envelopes.

type SyncMailRequest

type SyncMailRequest struct {
	// Lower is a lower bound of time range for which messages are requested.
	Lower uint32
	// Upper is a lower bound of time range for which messages are requested.
	Upper uint32
	// Bloom is a bloom filter to filter envelopes.
	Bloom []byte
	// Limit is the max number of envelopes to return.
	Limit uint32
	// Cursor is used for pagination of the results.
	Cursor []byte
}

SyncMailRequest contains details which envelopes should be synced between Mail Servers.

type TopicType

type TopicType [TopicLength]byte

TopicType represents a cryptographically secure, probabilistic partial classifications of a message, determined as the first (left) 4 bytes of the SHA3 hash of some arbitrary data given by the original author of the message.

func BytesToTopic

func BytesToTopic(b []byte) (t TopicType)

BytesToTopic converts from the byte array representation of a topic into the TopicType type.

func StringToTopic added in v0.98.1

func StringToTopic(s string) (t TopicType)

func (TopicType) MarshalText

func (t TopicType) MarshalText() ([]byte, error)

MarshalText returns the hex representation of t.

func (*TopicType) String

func (t *TopicType) String() string

String converts a topic byte array to a string representation.

func (*TopicType) UnmarshalText

func (t *TopicType) UnmarshalText(input []byte) error

UnmarshalText parses a hex representation to a topic.

type UnprefixedAddress

type UnprefixedAddress Address

UnprefixedAddress allows marshaling an Address without 0x prefix.

func (UnprefixedAddress) MarshalText

func (a UnprefixedAddress) MarshalText() ([]byte, error)

MarshalText encodes the address as hex.

func (*UnprefixedAddress) UnmarshalText

func (a *UnprefixedAddress) UnmarshalText(input []byte) error

UnmarshalText decodes the address from hex. The 0x prefix is optional.

type Waku

type Waku interface {
	PublicWakuAPI() PublicWakuAPI

	// Waku protocol version
	Version() uint

	// PeerCount
	PeerCount() int

	ListenAddresses() ([]string, error)

	RelayPeersByTopic(topic string) (*PeerList, error)

	ENR() (string, error)

	Peers() map[string]WakuV2Peer

	StartDiscV5() error

	StopDiscV5() error

	SubscribeToPubsubTopic(topic string, optPublicKey *ecdsa.PublicKey) error

	UnsubscribeFromPubsubTopic(topic string) error

	StorePubsubTopicKey(topic string, privKey *ecdsa.PrivateKey) error

	RetrievePubsubTopicKey(topic string) (*ecdsa.PrivateKey, error)

	RemovePubsubTopicKey(topic string) error

	AddStorePeer(address string) (peer.ID, error)

	AddRelayPeer(address string) (peer.ID, error)

	DialPeer(address string) error

	DialPeerByID(peerID string) error

	DropPeer(peerID string) error

	SubscribeToConnStatusChanges() (*ConnStatusSubscription, error)

	SetCriteriaForMissingMessageVerification(peerID peer.ID, pubsubTopic string, contentTopics []string) error

	// 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

	// 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)
	MaxMessageSize() uint32

	GetStats() StatsSummary

	Subscribe(opts *SubscriptionOptions) (string, error)
	GetFilter(id string) Filter
	Unsubscribe(ctx context.Context, id string) error
	UnsubscribeMany(ids []string) error

	// 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

	// RequestStoreMessages uses the WAKU2-STORE protocol to request historic messages
	RequestStoreMessages(ctx context.Context, peerID []byte, request MessagesRequest, processEnvelopes bool) (StoreRequestCursor, int, error)

	// ProcessingP2PMessages indicates whether there are in-flight p2p messages
	ProcessingP2PMessages() bool

	// MarkP2PMessageAsProcessed tells the waku layer that a P2P message has been processed
	MarkP2PMessageAsProcessed(common.Hash)

	// ConnectionChanged is called whenever the client knows its connection status has changed
	ConnectionChanged(connection.State)

	// ClearEnvelopesCache clears waku envelopes cache
	ClearEnvelopesCache()

	// ConfirmMessageDelivered updates a message has been delivered in waku
	ConfirmMessageDelivered(hash []common.Hash)

	// SetStorePeerID updates the peer id of store node
	SetStorePeerID(peerID peer.ID)

	// PeerID returns node's PeerID
	PeerID() peer.ID
}

Whisper represents a dark communication interface through the Ethereum network, using its very own P2P communication layer.

type WakuKeyManager added in v0.94.12

type WakuKeyManager interface {
	// GetPrivateKey retrieves the private key of the specified identity.
	GetPrivateKey(id string) (*ecdsa.PrivateKey, error)
	// 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
	// DeleteKeyPairs deletes all the keys
	DeleteKeyPairs() error
	AddSymKeyDirect(key []byte) (string, error)
	AddSymKeyFromPassword(password string) (string, error)
	DeleteSymKey(id string) bool
	GetSymKey(id string) ([]byte, error)
}

type WakuV2Peer added in v0.115.4

type WakuV2Peer struct {
	Protocols []protocol.ID `json:"protocols"`
	Addresses []string      `json:"addresses"`
}

type Whisper

type Whisper interface {
	PublicWhisperAPI() PublicWhisperAPI

	// 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
	MaxMessageSize() uint32

	// 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
	// DeleteKeyPairs removes all cryptographic identities known to the node
	DeleteKeyPairs() error
	AddSymKeyDirect(key []byte) (string, error)
	AddSymKeyFromPassword(password string) (string, error)
	DeleteSymKey(id string) bool
	GetSymKey(id string) ([]byte, error)

	Subscribe(opts *SubscriptionOptions) (string, error)
	GetFilter(id string) Filter
	Unsubscribe(id string) error
	UnsubscribeMany(ids []string) error

	// 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
	// SyncMessages can be sent between two Mail Servers and syncs envelopes between them.
	SyncMessages(peerID []byte, req SyncMailRequest) error
}

Whisper represents a dark communication interface through the Ethereum network, using its very own P2P communication layer.

type Wrapped

type Wrapped interface {
	Unwrap() interface{}
}

Wrapped tells that a given object has an underlying representation and this representation can be accessed using `Unwrap` method.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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