Documentation ¶
Index ¶
- type Delta
- type Deltas
- type Digest
- func (d *Digest) EncodeWithoutSender(buf []byte, sender NodePublicKey) []byte
- func (d *Digest) IncrementNode(node NodePublicKey) Version
- func (d *Digest) IntersectingNodes(other *Digest) []NodePublicKey
- func (d *Digest) SubtractNodes(other *Digest) []NodePublicKey
- func (d *Digest) UpdateNode(node NodePublicKey, version Version) Version
- type DigestNodes
- type Digests
- type Message
- type Model
- func (s *Model) Delta(digest *Digest) Deltas
- func (s *Model) Digest() *Digest
- func (s *Model) EncodeToJSON() ([]byte, error)
- func (s *Model) Merge(sender NodePublicKey, deltas Deltas) bool
- func (s *Model) NewMessage(value []byte, attachedSecret device.SharedSecret) Version
- func (model *Model) NewPullPacket() (*PullPacket, error)
- func (model *Model) NewPushPacket(receiverPublicKey NodePublicKey, delta Deltas) *PushPacket
- func (s *Model) UpdateDigest(baseNode, nodeToUpdate NodePublicKey, version Version) bool
- func (s *Model) UpdateDigests(node NodePublicKey, digest *Digest) bool
- type ModelNodeStates
- type ModelType
- type NodePublicKey
- type NodeState
- type PullPacket
- type PushPacket
- type Signature
- type Sync
- func (sync *Sync) ContactState(contact device.ContactID) ([]byte, error)
- func (sync *Sync) DeleteContact(contact device.ContactID)
- func (sync *Sync) HandlePullPacket(session device.SessionID, contact device.ContactID, publicKey NodePublicKey, ...) error
- func (sync *Sync) HasContact(contact device.ContactID) bool
- func (sync *Sync) LoadState(contact device.ContactID, state []byte) error
- func (sync *Sync) MergePushPacket(session device.SessionID, contact device.ContactID, pushPacket *PushPacket) error
- func (sync *Sync) NewContact(contact device.ContactID, privateKey ed25519.PrivateKey, modelType ModelType) error
- func (sync *Sync) NewMessage(contact device.ContactID, body []byte, attachedSecret device.SharedSecret) error
- func (sync *Sync) PullPacket(contact device.ContactID) (*PullPacket, error)
- func (sync *Sync) PushPacketDelivered(contact device.ContactID, session device.SessionID, packet *PushPacket) error
- func (sync *Sync) ReceiveSyncPacket(contact device.ContactID, session device.SessionID, packet []byte) error
- func (sync *Sync) SessionBroken(session device.SessionID)
- type SyncEvents
- type SyncPacketType
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Delta ¶
type Delta struct { PublicKey NodePublicKey Version Version Value []byte AttachedSecret []byte Signature Signature }
type Digest ¶
type Digest struct { Nodes DigestNodes `json:"nodes"` MaxVersion Version `json:"max_version"` }
func DecodeDigest ¶
Decodes the given buffer to a digest, and returns the digest along with an integer representing how many bytes of the buffer was read
func (*Digest) EncodeWithoutSender ¶
func (d *Digest) EncodeWithoutSender(buf []byte, sender NodePublicKey) []byte
func (*Digest) IncrementNode ¶
func (d *Digest) IncrementNode(node NodePublicKey) Version
func (*Digest) IntersectingNodes ¶
func (d *Digest) IntersectingNodes(other *Digest) []NodePublicKey
func (*Digest) SubtractNodes ¶
func (d *Digest) SubtractNodes(other *Digest) []NodePublicKey
func (*Digest) UpdateNode ¶
func (d *Digest) UpdateNode(node NodePublicKey, version Version) Version
type DigestNodes ¶
type DigestNodes map[NodePublicKey]Version
func (DigestNodes) MarshalJSON ¶
func (d DigestNodes) MarshalJSON() ([]byte, error)
func (*DigestNodes) UnmarshalJSON ¶
func (d *DigestNodes) UnmarshalJSON(b []byte) error
type Digests ¶
type Digests map[NodePublicKey]*Digest
func (Digests) MarshalJSON ¶
func (*Digests) UnmarshalJSON ¶
type Message ¶
type Message struct { Value []byte `json:"value"` Signature Signature `json:"sig"` AttachedSecret device.SharedSecret `json:"attached_secret"` }
type Model ¶
type Model struct { Digests Digests `json:"digests"` PrivateKey ed25519.PrivateKey `json:"private_key"` PublicKey NodePublicKey `json:"public_key"` NodeStates ModelNodeStates `json:"node_states"` Type ModelType `json:"type"` }
func DecodeModelFromJSON ¶
func (*Model) EncodeToJSON ¶
func (*Model) NewMessage ¶
func (s *Model) NewMessage(value []byte, attachedSecret device.SharedSecret) Version
func (*Model) NewPullPacket ¶
func (model *Model) NewPullPacket() (*PullPacket, error)
func (*Model) NewPushPacket ¶
func (model *Model) NewPushPacket(receiverPublicKey NodePublicKey, delta Deltas) *PushPacket
func (*Model) UpdateDigest ¶
func (s *Model) UpdateDigest(baseNode, nodeToUpdate NodePublicKey, version Version) bool
func (*Model) UpdateDigests ¶
func (s *Model) UpdateDigests(node NodePublicKey, digest *Digest) bool
type ModelNodeStates ¶
type ModelNodeStates map[NodePublicKey]NodeState
func (ModelNodeStates) MarshalJSON ¶
func (s ModelNodeStates) MarshalJSON() ([]byte, error)
func (*ModelNodeStates) UnmarshalJSON ¶
func (s *ModelNodeStates) UnmarshalJSON(b []byte) error
type NodePublicKey ¶
type NodePublicKey [32]byte
func DecodeNodePublicKey ¶
func DecodeNodePublicKey(buf []byte) NodePublicKey
func ExtractNodePublicKey ¶
func ExtractNodePublicKey(privateKey ed25519.PrivateKey) NodePublicKey
func (NodePublicKey) Encode ¶
func (s NodePublicKey) Encode(buf []byte) []byte
func (NodePublicKey) Key ¶
func (s NodePublicKey) Key() ed25519.PublicKey
func (NodePublicKey) MarshalJSON ¶
func (n NodePublicKey) MarshalJSON() ([]byte, error)
func (*NodePublicKey) UnmarshalJSON ¶
func (k *NodePublicKey) UnmarshalJSON(b []byte) error
type NodeState ¶
func NewNodeState ¶
func NewNodeState() NodeState
type PullPacket ¶
type PullPacket struct {
// contains filtered or unexported fields
}
func DecodePullPacket ¶
func DecodePullPacket(buf []byte) (*PullPacket, error)
func (*PullPacket) Encode ¶
func (packet *PullPacket) Encode() []byte
type PushPacket ¶
type PushPacket struct {
// contains filtered or unexported fields
}
func DecodePushPacket ¶
func DecodePushPacket(buf []byte) (*PushPacket, error)
func (*PushPacket) Encode ¶
func (packet *PushPacket) Encode() []byte
type Sync ¶
type Sync struct {
// contains filtered or unexported fields
}
func NewSync ¶
func NewSync(events SyncEvents) *Sync
func (*Sync) ContactState ¶
func (*Sync) DeleteContact ¶
func (*Sync) HandlePullPacket ¶
func (sync *Sync) HandlePullPacket(session device.SessionID, contact device.ContactID, publicKey NodePublicKey, digest *Digest) error
HandlePullPacket is called in a response to a pull packet
func (*Sync) MergePushPacket ¶
func (*Sync) NewContact ¶
func (*Sync) NewMessage ¶
func (*Sync) PullPacket ¶
func (sync *Sync) PullPacket(contact device.ContactID) (*PullPacket, error)
func (*Sync) PushPacketDelivered ¶
func (*Sync) ReceiveSyncPacket ¶
func (*Sync) SessionBroken ¶
type SyncEvents ¶
type SyncEvents interface { PushSyncUpdates(contact device.ContactID, session device.SessionID, pushPacket *PushPacket) // DiscoverContact is called when there is an update to a contact with no currently active session. // A route request may be broadcasted in order to deliver the update if possible. DiscoverContact(contact device.ContactID) SyncStateChanged(contact device.ContactID, updatedState []byte) Log(message string) }
Click to show internal directories.
Click to hide internal directories.