filter

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2019 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DiscoveryTopic = "contact-discovery"
)

Variables

This section is empty.

Functions

func ContactCodeTopic

func ContactCodeTopic(publicKey *ecdsa.PublicKey) string

func PublicKeyToPartitionedTopicBytes

func PublicKeyToPartitionedTopicBytes(publicKey *ecdsa.PublicKey) []byte

PublicKeyToPartitionedTopicBytes returns the bytes of the partitioned topic associated with the given public key

func ToTopic

func ToTopic(s string) []byte

Types

type Chat

type Chat 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 chats
	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 chats.
	// It's encoded using encoding/hex.
	Identity string `json:"identity"`
	// Topic is the whisper topic
	Topic whisper.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.

func (*Chat) IsPublic added in v0.1.2

func (c *Chat) IsPublic() bool

type ChatsManager

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

func New

func New(db *sql.DB, w *whisper.Whisper, privateKey *ecdsa.PrivateKey, logger *zap.Logger) (*ChatsManager, error)

New returns a new ChatsManager service

func (*ChatsManager) ChatByFilterID

func (s *ChatsManager) ChatByFilterID(filterID string) *Chat

func (*ChatsManager) ChatByID

func (s *ChatsManager) ChatByID(chatID string) *Chat

ChatByID returns a chat by id.

func (*ChatsManager) Chats

func (s *ChatsManager) Chats() (result []*Chat)

func (*ChatsManager) ChatsByPublicKey

func (s *ChatsManager) ChatsByPublicKey(publicKey *ecdsa.PublicKey) (result []*Chat)

func (*ChatsManager) GetNegotiated

func (s *ChatsManager) GetNegotiated(identity *ecdsa.PublicKey) *Chat

GetNegotiated returns a negotiated chat given an identity

func (*ChatsManager) Init

func (s *ChatsManager) Init(
	chatIDs []string,
	publicKeys []*ecdsa.PublicKey,
	genericDiscoveryTopicEnabled bool,
) ([]*Chat, error)

func (*ChatsManager) InitWithChats

func (s *ChatsManager) InitWithChats(chats []*Chat, genericDiscoveryTopicEnabled bool) ([]*Chat, error)

DEPRECATED

func (*ChatsManager) LoadContactCode

func (s *ChatsManager) LoadContactCode(pubKey *ecdsa.PublicKey) (*Chat, error)

LoadContactCode creates a filter for the advertise topic for a given public key.

func (*ChatsManager) LoadDiscovery

func (s *ChatsManager) LoadDiscovery() ([]*Chat, error)

LoadDiscovery adds 1-2 discovery filters: one for generic discovery topic (if enabled) and one for the personal discovery topic.

func (*ChatsManager) LoadNegotiated

func (s *ChatsManager) LoadNegotiated(secret NegotiatedSecret) (*Chat, error)

LoadNegotiated loads a negotiated secret as a filter.

func (*ChatsManager) LoadPartitioned

func (s *ChatsManager) LoadPartitioned(publicKey *ecdsa.PublicKey) (*Chat, error)

LoadPartitioned creates a filter for a partitioned topic.

func (*ChatsManager) LoadPublic

func (s *ChatsManager) LoadPublic(chatID string) (*Chat, error)

LoadPublic adds a filter for a public chat.

func (*ChatsManager) Remove

func (s *ChatsManager) Remove(chats ...*Chat) error

Remove remove all the filters associated with a chat/identity

func (*ChatsManager) Reset

func (s *ChatsManager) Reset() error

type Filter

type Filter struct {
	FilterID string
	Topic    whisper.TopicType
	SymKeyID string
}

type NegotiatedSecret

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

Jump to

Keyboard shortcuts

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