status-go/protocol/transport/transport.go

69 lines
2.4 KiB
Go
Raw Normal View History

package transport
import (
"context"
"crypto/ecdsa"
2021-01-11 10:32:51 +00:00
"github.com/status-im/status-go/eth-node/crypto"
"github.com/status-im/status-go/eth-node/types"
)
type Transport interface {
Stop() error
2021-01-11 10:32:51 +00:00
JoinPrivate(publicKey *ecdsa.PublicKey) (*Filter, error)
LeavePrivate(publicKey *ecdsa.PublicKey) error
2021-01-11 10:32:51 +00:00
JoinGroup(publicKeys []*ecdsa.PublicKey) ([]*Filter, error)
LeaveGroup(publicKeys []*ecdsa.PublicKey) error
2021-01-11 10:32:51 +00:00
JoinPublic(chatID string) (*Filter, error)
LeavePublic(chatID string) error
GetCurrentTime() uint64
MaxMessageSize() uint32
SendPublic(ctx context.Context, newMessage *types.NewMessage, chatName string) ([]byte, error)
SendPrivateWithSharedSecret(ctx context.Context, newMessage *types.NewMessage, publicKey *ecdsa.PublicKey, secret []byte) ([]byte, error)
SendPrivateWithPartitioned(ctx context.Context, newMessage *types.NewMessage, publicKey *ecdsa.PublicKey) ([]byte, error)
SendPrivateOnPersonalTopic(ctx context.Context, newMessage *types.NewMessage, publicKey *ecdsa.PublicKey) ([]byte, error)
2021-01-11 10:32:51 +00:00
SendCommunityMessage(ctx context.Context, newMessage *types.NewMessage, publicKey *ecdsa.PublicKey) ([]byte, error)
SendMessagesRequest(
ctx context.Context,
peerID []byte,
from, to uint32,
previousCursor []byte,
waitForResponse bool,
) (cursor []byte, err error)
SendMessagesRequestForFilter(
ctx context.Context,
peerID []byte,
from, to uint32,
previousCursor []byte,
filter *Filter,
waitForResponse bool,
) (cursor []byte, err error)
FilterByChatID(string) *Filter
Track(identifiers [][]byte, hash []byte, newMessage *types.NewMessage)
InitFilters(chatIDs []string, publicKeys []*ecdsa.PublicKey) ([]*Filter, error)
InitPublicFilters(chatIDs []string) ([]*Filter, error)
2021-01-11 10:32:51 +00:00
InitCommunityFilters(pks []*ecdsa.PrivateKey) ([]*Filter, error)
LoadFilters(filters []*Filter) ([]*Filter, error)
RemoveFilters(filters []*Filter) error
2020-12-22 17:12:03 +00:00
RemoveFilterByChatID(string) (*Filter, error)
ResetFilters() error
2020-01-17 12:39:09 +00:00
Filters() []*Filter
LoadKeyFilters(*ecdsa.PrivateKey) (*Filter, error)
ProcessNegotiatedSecret(secret types.NegotiatedSecret) (*Filter, error)
RetrieveRawAll() (map[Filter][]*types.Message, error)
2020-12-15 14:43:41 +00:00
ConfirmMessagesProcessed([]string, uint64) error
CleanMessagesProcessed(uint64) error
2020-12-15 14:43:41 +00:00
SetEnvelopeEventsHandler(handler EnvelopeEventsHandler) error
}
2021-01-11 10:32:51 +00:00
func PubkeyToHex(key *ecdsa.PublicKey) string {
return types.EncodeHex(crypto.FromECDSAPub(key))
}