peersyncing

package
v0.179.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: MPL-2.0, MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSyncMessageNotValid = errors.New("sync message not valid")

Functions

This section is empty.

Types

type Config

type Config struct {
	SyncMessagePersistence SyncMessagePersistence
	Database               *sql.DB
	Timesource             common.TimeSource
}

type PeerSyncing

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

func New

func New(config Config) *PeerSyncing

func (*PeerSyncing) Add

func (p *PeerSyncing) Add(message SyncMessage) error

func (*PeerSyncing) AvailableMessages

func (p *PeerSyncing) AvailableMessages() ([]SyncMessage, error)

func (*PeerSyncing) AvailableMessagesByGroupID

func (p *PeerSyncing) AvailableMessagesByGroupID(groupID []byte, limit int) ([]SyncMessage, error)

func (*PeerSyncing) AvailableMessagesByGroupIDs

func (p *PeerSyncing) AvailableMessagesByGroupIDs(groupIDs [][]byte, limit int) ([]SyncMessage, error)

func (*PeerSyncing) MessagesByIDs

func (p *PeerSyncing) MessagesByIDs(messageIDs [][]byte) ([]SyncMessage, error)

func (*PeerSyncing) OnOffer

func (p *PeerSyncing) OnOffer(messages []SyncMessage) ([]SyncMessage, error)

type SyncMessage

type SyncMessage struct {
	ID        []byte
	Type      SyncMessageType
	GroupID   []byte
	Payload   []byte
	Timestamp uint64
}

func (*SyncMessage) Valid

func (s *SyncMessage) Valid() error

type SyncMessagePersistence

type SyncMessagePersistence interface {
	Add(SyncMessage) error
	All() ([]SyncMessage, error)
	Complement([]SyncMessage) ([]SyncMessage, error)
	ByGroupID([]byte, int) ([]SyncMessage, error)
	ByGroupIDs([][]byte, int) ([]SyncMessage, error)
	ByMessageIDs([][]byte) ([]SyncMessage, error)
}

type SyncMessageSQLitePersistence

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

func NewSyncMessageSQLitePersistence

func NewSyncMessageSQLitePersistence(db *sql.DB) *SyncMessageSQLitePersistence

func (*SyncMessageSQLitePersistence) Add

func (*SyncMessageSQLitePersistence) All

func (*SyncMessageSQLitePersistence) ByGroupID

func (p *SyncMessageSQLitePersistence) ByGroupID(groupID []byte, limit int) ([]SyncMessage, error)

func (*SyncMessageSQLitePersistence) ByGroupIDs

func (p *SyncMessageSQLitePersistence) ByGroupIDs(ids [][]byte, limit int) ([]SyncMessage, error)

func (*SyncMessageSQLitePersistence) ByMessageIDs

func (p *SyncMessageSQLitePersistence) ByMessageIDs(ids [][]byte) ([]SyncMessage, error)

func (*SyncMessageSQLitePersistence) Complement

func (p *SyncMessageSQLitePersistence) Complement(messages []SyncMessage) ([]SyncMessage, error)

type SyncMessageType

type SyncMessageType int
const (
	SyncMessageNoType SyncMessageType = iota
	SyncMessageCommunityType
	SyncMessageOneToOneType
	SyncMessagePrivateGroup
)

Jump to

Keyboard shortcuts

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