filter

package
v0.29.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2019 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContactCodeTopic

func ContactCodeTopic(identity string) string

func PublicKeyToPartitionedTopic

func PublicKeyToPartitionedTopic(publicKey *ecdsa.PublicKey) string

PublicKeyToPartitionedTopic returns the associated partitioned topic string with the given public key

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

ToTopic converts a string to a whisper topic

Types

type Chat

type Chat struct {
	// ChatID is the identifier of the chat
	ChatID string `json:"chatId"`
	// 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"`
	// 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"`
	// FilterID the whisper filter id generated
	FilterID string `json:"filterId"`
	// Identity is the public key of the other recipient for non-public chats
	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"`
}

type Filter

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

type Persistence

type Persistence interface {
	Add(chatID string, key []byte) error
	All() (map[string][]byte, error)
}

type SQLLitePersistence

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

func NewSQLLitePersistence

func NewSQLLitePersistence(db *sql.DB) *SQLLitePersistence

func (*SQLLitePersistence) Add

func (s *SQLLitePersistence) Add(chatID string, key []byte) error

func (*SQLLitePersistence) All

func (s *SQLLitePersistence) All() (map[string][]byte, error)

type Service

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

func New

New returns a new filter service

func (*Service) GetByID

func (s *Service) GetByID(chatID string) *Chat

GetByID returns a chat by chatID

func (*Service) GetNegotiated

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

Get returns a negotiated chat given an identity

func (*Service) Init

func (s *Service) Init(chats []*Chat) ([]*Chat, error)

LoadChat should return a list of newly chats loaded

func (*Service) Load

func (s *Service) Load(chat *Chat) ([]*Chat, error)

Load creates filters for a given chat, and returns all the created filters

func (*Service) LoadPartitioned

func (s *Service) LoadPartitioned(myKey *ecdsa.PrivateKey, theirPublicKey *ecdsa.PublicKey, listen bool) (*Chat, error)

LoadPartitioned creates a filter for a partitioned topic

func (*Service) ProcessNegotiatedSecret

func (s *Service) ProcessNegotiatedSecret(secret *sharedsecret.Secret) (*Chat, error)

ProcessNegotiatedSecret adds a filter based on the agreed secret

func (*Service) Remove

func (s *Service) Remove(chats []*Chat) error

Remove remove all the filters associated with a chat/identity

func (*Service) Stop

func (s *Service) Stop() error

Stop removes all the filters

Jump to

Keyboard shortcuts

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