whisper

package
v0.56.9 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2020 License: MPL-2.0, MPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoMailservers returned if there is no configured mailservers that can be used.
	ErrNoMailservers = errors.New("no configured mailservers")
)

Functions

This section is empty.

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 at least 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 transport.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

func (*EnvelopesMonitor) Start

func (m *EnvelopesMonitor) Start()

Start processing events.

func (*EnvelopesMonitor) Stop

func (m *EnvelopesMonitor) Stop()

Stop process events.

type Message

type Message struct {
	Message *types.Message
	Public  bool
}

type Option

type Option func(*Transport) error

type RequestOptions

type RequestOptions struct {
	Topics   []types.TopicType
	Password string
	Limit    int
	From     int64 // in seconds
	To       int64 // in seconds
}

type Transport

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

Transport is a transport based on Whisper service.

func NewTransport

func NewTransport(
	shh types.Whisper,
	privateKey *ecdsa.PrivateKey,
	db *sql.DB,
	mailservers []string,
	envelopesMonitorConfig *transport.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) Filters

func (a *Transport) Filters() []*transport.Filter

func (*Transport) GetCurrentTime

func (a *Transport) GetCurrentTime() uint64

GetCurrentTime returns the current unix timestamp in milliseconds

func (*Transport) InitFilters

func (a *Transport) InitFilters(chatIDs []string, publicKeys []*ecdsa.PublicKey) ([]*transport.Filter, error)

func (*Transport) JoinGroup

func (a *Transport) JoinGroup(publicKeys []*ecdsa.PublicKey) error

func (*Transport) JoinPrivate

func (a *Transport) JoinPrivate(publicKey *ecdsa.PublicKey) error

func (*Transport) JoinPublic

func (a *Transport) JoinPublic(chatID string) error

func (*Transport) LeaveGroup

func (a *Transport) LeaveGroup(publicKeys []*ecdsa.PublicKey) error

func (*Transport) LeavePrivate

func (a *Transport) LeavePrivate(publicKey *ecdsa.PublicKey) error

func (*Transport) LeavePublic

func (a *Transport) LeavePublic(chatID string) error

func (*Transport) LoadFilters

func (a *Transport) LoadFilters(filters []*transport.Filter) ([]*transport.Filter, error)

DEPRECATED

func (*Transport) LoadKeyFilters added in v0.56.1

func (a *Transport) LoadKeyFilters(key *ecdsa.PrivateKey) (*transport.Filter, error)

func (*Transport) ProcessNegotiatedSecret

func (a *Transport) ProcessNegotiatedSecret(secret types.NegotiatedSecret) (*transport.Filter, error)

func (*Transport) RemoveFilters

func (a *Transport) RemoveFilters(filters []*transport.Filter) error

DEPRECATED

func (*Transport) ResetFilters

func (a *Transport) ResetFilters() error

func (*Transport) RetrieveAllMessages

func (a *Transport) RetrieveAllMessages() ([]Message, error)

func (*Transport) RetrievePrivateMessages

func (a *Transport) RetrievePrivateMessages(publicKey *ecdsa.PublicKey) ([]*types.Message, error)

func (*Transport) RetrievePublicMessages

func (a *Transport) RetrievePublicMessages(chatID string) ([]*types.Message, error)

func (*Transport) RetrieveRawAll

func (a *Transport) RetrieveRawAll() (map[transport.Filter][]*types.Message, error)

func (*Transport) SendMessagesRequest

func (a *Transport) SendMessagesRequest(
	ctx context.Context,
	peerID []byte,
	from, to uint32,
	previousCursor []byte,
) (cursor []byte, err error)

RequestHistoricMessages requests historic messages for all registered filters.

func (*Transport) SendPrivateOnDiscovery

func (a *Transport) SendPrivateOnDiscovery(ctx context.Context, newMessage *types.NewMessage, publicKey *ecdsa.PublicKey) ([]byte, error)

func (*Transport) SendPrivateWithPartitioned

func (a *Transport) SendPrivateWithPartitioned(ctx context.Context, newMessage *types.NewMessage, publicKey *ecdsa.PublicKey) ([]byte, error)

func (*Transport) SendPrivateWithSharedSecret

func (a *Transport) SendPrivateWithSharedSecret(ctx context.Context, newMessage *types.NewMessage, publicKey *ecdsa.PublicKey, secret []byte) ([]byte, error)

func (*Transport) SendPublic

func (a *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) Stop

func (a *Transport) Stop() error

func (*Transport) Track

func (a *Transport) Track(identifiers [][]byte, hash []byte, newMessage *types.NewMessage)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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