Documentation
¶
Index ¶
- func Hash(data string) string
- type BloomFilter
- type DataStore
- func (ds *DataStore) Close()
- func (ds *DataStore) GetAllKeys() ([]string, error)
- func (ds *DataStore) GetAllTransactions() ([]*protoc.Transaction, error)
- func (d *DataStore) GetDBPath() string
- func (ds *DataStore) GetData(key string) (string, error)
- func (ds *DataStore) GetKeysByPrefix(prefix string) ([]string, error)
- func (ds *DataStore) GetMerkleRoot() string
- func (ds *DataStore) StoreData(key string, value string) error
- func (ds *DataStore) VerifyData(key string, value string) bool
- type MerkleNode
- type MerkleTree
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BloomFilter ¶
type BloomFilter struct {
// contains filtered or unexported fields
}
BloomFilter represents a Bloom filter for efficient data lookups
func NewBloomFilter ¶
func NewBloomFilter(size int, hashFunctions int) *BloomFilter
NewBloomFilter creates a new Bloom filter
func (*BloomFilter) Add ¶
func (bf *BloomFilter) Add(data string)
Add adds an item to the Bloom filter
func (*BloomFilter) Contains ¶
func (bf *BloomFilter) Contains(data string) bool
Contains checks if an item might be in the Bloom filter
type DataStore ¶
type DataStore struct {
// contains filtered or unexported fields
}
DataStore represents the key-value store with LevelDB and Redis
func NewDataStore ¶
NewDataStore initializes a new DataStore
func (*DataStore) GetAllKeys ¶
GetAllKeys returns all keys in the database
func (*DataStore) GetAllTransactions ¶
func (ds *DataStore) GetAllTransactions() ([]*protoc.Transaction, error)
func (*DataStore) GetKeysByPrefix ¶
GetKeysByPrefix returns all keys with a given prefix
func (*DataStore) GetMerkleRoot ¶
GetMerkleRoot returns the root hash of the Merkle tree
type MerkleNode ¶
type MerkleNode struct { Hash string Left *MerkleNode Right *MerkleNode Data string // Only leaf nodes have data }
MerkleNode represents a node in the Merkle tree
func NewMerkleNode ¶
func NewMerkleNode(left, right *MerkleNode, data string) *MerkleNode
NewMerkleNode creates a new Merkle node
type MerkleTree ¶
type MerkleTree struct { Root *MerkleNode // contains filtered or unexported fields }
MerkleTree represents a Merkle tree structure for data integrity validation
func (*MerkleTree) AddLeaf ¶
func (mt *MerkleTree) AddLeaf(data string) error
AddLeaf adds a new leaf node to the Merkle tree
func (*MerkleTree) GetRoot ¶
func (mt *MerkleTree) GetRoot() string
GetRoot returns the root hash of the Merkle tree
func (*MerkleTree) VerifyData ¶
func (mt *MerkleTree) VerifyData(data string) bool
VerifyData verifies if data exists in the Merkle tree