database

package
v0.0.0-...-4937328 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBPeer

type DBPeer struct {
	PeerID    string
	Addresses []string
}

type DataEntry

type DataEntry struct {
	Key   []byte
	Value []byte
	Size  int64
	Hash  []byte
}

type EndershareDB

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

func Create

func Create() *EndershareDB

The node table stores key-value pairs for this node The data table stores data replicated between nodes

func (*EndershareDB) AddPeer

func (db *EndershareDB) AddPeer(addrInfo peer.AddrInfo) error

func (*EndershareDB) DeleteData

func (db *EndershareDB) DeleteData(key []byte) error

func (*EndershareDB) DeleteNodeProperty

func (db *EndershareDB) DeleteNodeProperty(key string) error

func (*EndershareDB) DeleteStaleEntries

func (db *EndershareDB) DeleteStaleEntries() error

DeleteStaleEntries deletes all stale entries (in_current = 0)

func (*EndershareDB) GetAllData

func (db *EndershareDB) GetAllData() ([]DataEntry, error)

func (*EndershareDB) GetAllDataHashes

func (db *EndershareDB) GetAllDataHashes() [][]byte

GetAllDataHashes returns all hash column values for merkle tree construction

func (*EndershareDB) GetAllPeerIDs

func (db *EndershareDB) GetAllPeerIDs() []string

GetAllPeerIDs returns a sorted list of all peer IDs

func (*EndershareDB) GetBucketHashes

func (db *EndershareDB) GetBucketHashes(bucketIdx int, numBuckets int) [][]byte

GetBucketHashes returns data entry hashes for a specific bucket index

func (*EndershareDB) GetCurrentUpdateID

func (db *EndershareDB) GetCurrentUpdateID() (uint64, error)

func (*EndershareDB) GetData

func (db *EndershareDB) GetData(key []byte) ([]byte, error)

func (*EndershareDB) GetDataByFolderTag

func (db *EndershareDB) GetDataByFolderTag(folderTag []byte) ([]DataEntry, error)

GetDataByFolderTag returns entries matching a folder tag for fast folder listing

func (*EndershareDB) GetDataByHashes

func (db *EndershareDB) GetDataByHashes(hashes [][]byte) []DataEntry

GetDataByHashes returns complete entries for specific hashes

func (*EndershareDB) GetDataHash

func (db *EndershareDB) GetDataHash() ([]byte, error)

func (*EndershareDB) GetDataRootHash

func (db *EndershareDB) GetDataRootHash() ([]byte, error)

func (*EndershareDB) GetDataWithNullFolderTag

func (db *EndershareDB) GetDataWithNullFolderTag() ([]DataEntry, error)

GetDataWithNullFolderTag returns entries that don't have a folder_tag set yet

func (*EndershareDB) GetDownloadProgress

func (db *EndershareDB) GetDownloadProgress(hash []byte) int64

GetDownloadProgress returns download progress for a file (0 if not started, size of the file if complete)

func (*EndershareDB) GetKeys

func (db *EndershareDB) GetKeys() *crypto.CryptoKeys

func (*EndershareDB) GetLatestUpdate

func (db *EndershareDB) GetLatestUpdate() (string, error)

func (*EndershareDB) GetLatestUpdateJSON

func (db *EndershareDB) GetLatestUpdateJSON() (string, error)

func (*EndershareDB) GetMasterPubKey

func (db *EndershareDB) GetMasterPubKey() (ed25519.PublicKey, error)

func (*EndershareDB) GetPeerListHash

func (db *EndershareDB) GetPeerListHash() ([]byte, error)

func (*EndershareDB) GetPeers

func (db *EndershareDB) GetPeers() (peers []peer.AddrInfo)

func (*EndershareDB) GetStaleHashes

func (db *EndershareDB) GetStaleHashes() [][]byte

GetStaleHashes returns hashes of all stale entries (in_current = 0)

func (*EndershareDB) GetStorageStats

func (db *EndershareDB) GetStorageStats() (int64, int64)

GetStorageStats returns total entry count and total size in bytes

func (*EndershareDB) GetUpdateByID

func (db *EndershareDB) GetUpdateByID(updateID uint64) (string, error)

func (*EndershareDB) InsertSignedUpdate

func (db *EndershareDB) InsertSignedUpdate(updateID uint64, signedUpdateJSON string) error

func (*EndershareDB) MarkAllStale

func (db *EndershareDB) MarkAllStale() error

MarkAllStale marks all entries as stale before sync

func (*EndershareDB) MarkHashCurrent

func (db *EndershareDB) MarkHashCurrent(hash []byte) error

MarkHashCurrent marks a specific hash as current (in_current = 1)

func (*EndershareDB) PutData

func (db *EndershareDB) PutData(key []byte, value []byte, size int64, hash []byte) error

func (*EndershareDB) PutDataWithTag

func (db *EndershareDB) PutDataWithTag(key []byte, value []byte, size int64, hash []byte, folderTag []byte) error

func (*EndershareDB) RemovePeer

func (db *EndershareDB) RemovePeer(peerID string) error

RemovePeer removes a peer by ID

func (*EndershareDB) ReplaceAllPeers

func (db *EndershareDB) ReplaceAllPeers(peers []DBPeer) error

ReplaceAllPeers atomically replaces all peers with a new list

func (*EndershareDB) SetCurrentUpdateID

func (db *EndershareDB) SetCurrentUpdateID(id uint64) error

func (*EndershareDB) SetDataRootHash

func (db *EndershareDB) SetDataRootHash(hash []byte) error

func (*EndershareDB) SetDownloadProgress

func (db *EndershareDB) SetDownloadProgress(hash []byte, progress int64) error

SetDownloadProgress updates download progress for a file

func (*EndershareDB) SetFolderTag

func (db *EndershareDB) SetFolderTag(key []byte, folderTag []byte) error

func (*EndershareDB) SetLatestUpdateJSON

func (db *EndershareDB) SetLatestUpdateJSON(jsonStr string) error

func (*EndershareDB) SetMasterPublicKey

func (db *EndershareDB) SetMasterPublicKey(key []byte) error

func (*EndershareDB) SetPeerListHash

func (db *EndershareDB) SetPeerListHash(hash []byte) error

func (*EndershareDB) StoreKeys

func (db *EndershareDB) StoreKeys(keys *crypto.CryptoKeys)

StoreKeys saves the master private key, peer private key, and AES key into the database StoreKeys also inserts the peer's public key into the peers table

func (*EndershareDB) UpdatePeerAddresses

func (db *EndershareDB) UpdatePeerAddresses(peerID string, addrs []string) error

UpdatePeerAddresses updates the addresses for an existing peer

Jump to

Keyboard shortcuts

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