Documentation ¶
Index ¶
- Constants
- func ContactCodeTopic(publicKey *ecdsa.PublicKey) string
- func PublicKeyToPartitionedTopicBytes(publicKey *ecdsa.PublicKey) []byte
- func ToTopic(s string) []byte
- type Chat
- type ChatsManager
- func (s *ChatsManager) ChatByFilterID(filterID string) *Chat
- func (s *ChatsManager) ChatByID(chatID string) *Chat
- func (s *ChatsManager) Chats() (result []*Chat)
- func (s *ChatsManager) ChatsByPublicKey(publicKey *ecdsa.PublicKey) (result []*Chat)
- func (s *ChatsManager) GetNegotiated(identity *ecdsa.PublicKey) *Chat
- func (s *ChatsManager) Init(chatIDs []string, publicKeys []*ecdsa.PublicKey, ...) ([]*Chat, error)
- func (s *ChatsManager) InitWithChats(chats []*Chat, genericDiscoveryTopicEnabled bool) ([]*Chat, error)
- func (s *ChatsManager) LoadContactCode(pubKey *ecdsa.PublicKey) (*Chat, error)
- func (s *ChatsManager) LoadDiscovery() ([]*Chat, error)
- func (s *ChatsManager) LoadNegotiated(secret NegotiatedSecret) (*Chat, error)
- func (s *ChatsManager) LoadPartitioned(publicKey *ecdsa.PublicKey) (*Chat, error)
- func (s *ChatsManager) LoadPublic(chatID string) (*Chat, error)
- func (s *ChatsManager) Remove(chats ...*Chat) error
- func (s *ChatsManager) Reset() error
- type Filter
- type NegotiatedSecret
Constants ¶
const (
DiscoveryTopic = "contact-discovery"
)
Variables ¶
This section is empty.
Functions ¶
func ContactCodeTopic ¶
func PublicKeyToPartitionedTopicBytes ¶
PublicKeyToPartitionedTopicBytes returns the bytes of the partitioned topic associated with the given public key
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.
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) 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