Documentation ¶
Overview ¶
Package sync implements a sync mechanism using Merkle trees (tree of hahes) for a two-way sync between two BlobStash instances.
The algorithm is inspired by Dynamo or Cassandra uses of Merkle trees (as an anti-entropy mechanism).
Each node maintains its own Merkle tree, when doing a sync, the hashes of the tree are checked against each other starting from the root hash to the leaves.
This first implementation only keep 256 (16**2) buckets (the first 2 hex of the hashes).
Blake2B (the same hashing algorithm used by the Blob Store) is used to compute the tree.
Index ¶
- func NewHash() (h hash.Hash)
- type LeafState
- type State
- type StateTree
- func (st *StateTree) Add(h string)
- func (st *StateTree) Close() error
- func (st *StateTree) Count() int
- func (st *StateTree) Level1() map[string]string
- func (st *StateTree) Level1Prefix(prefix string) string
- func (st *StateTree) Root() string
- func (st *StateTree) State() *State
- func (st *StateTree) String() string
- type Sync
- type SyncClient
- type SyncStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type State ¶
type StateTree ¶
func NewStateTree ¶
func NewStateTree() *StateTree
func (*StateTree) Level1Prefix ¶
type SyncClient ¶
type SyncClient struct {
// contains filtered or unexported fields
}
func NewSyncClient ¶
func (*SyncClient) Receive ¶
func (stc *SyncClient) Receive(h string) error
func (*SyncClient) RemoteLeaf ¶
func (stc *SyncClient) RemoteLeaf(prefix string) (*LeafState, error)
func (*SyncClient) RemoteState ¶
func (stc *SyncClient) RemoteState() (*State, error)
func (*SyncClient) Send ¶
func (stc *SyncClient) Send(h string) error
func (*SyncClient) Sync ¶
func (stc *SyncClient) Sync() (*SyncStats, error)
type SyncStats ¶
type SyncStats struct { Downloaded int `json:"blobs_downloaded"` DownloadedSize int `json:"downloaded_size"` Uploaded int `json:"blobs_uploaded"` UploadedSize int `json:"uploaded_size"` Duration string `json:"sync_duration"` AlreadySynced bool `json:"already_in_sync"` OneWay bool `json:"one_way_sync"` }
Click to show internal directories.
Click to hide internal directories.