Documentation
¶
Index ¶
- Constants
- Variables
- func PrefixToString(p byte) string
- type Chain
- func (c *Chain) FindChildren(parentHash crypto.Hash) ([]block.Block, error)
- func (c *Chain) FindHeader(fn func(header block.Header) bool) (block.Header, error)
- func (c *Chain) GetBlock(hash crypto.Hash) (block.Block, error)
- func (c *Chain) GetBlockSequence(startHash crypto.Hash, ascending bool, maxBlocks uint32) ([]block.Block, error)
- func (c *Chain) GetHeader(hash crypto.Hash) (block.Header, error)
- func (c *Chain) PutBlock(b block.Block) error
- func (c *Chain) PutHeader(h block.Header) error
- type KeyValuePair
- type Shards
- func (a *Shards) GetAuditShard(erasureRoot crypto.Hash, shardIndex uint16) ([]byte, error)
- func (a *Shards) GetJustification(erasureRoot crypto.Hash, shardIndex uint16) ([][]byte, error)
- func (a *Shards) GetSegmentsShard(erasureRoot crypto.Hash, shardIndex uint16) ([][]byte, error)
- func (a *Shards) PutAllShardsAndJustifications(erasureRoot crypto.Hash, bundleShards [][]byte, segmentsShards [][][]byte, ...) error
- func (a *Shards) PutShardsAndJustification(erasureRoot crypto.Hash, shardIndex uint16, bundleShard []byte, ...) error
- type Ticket
- func (t *Ticket) DeleteTicket(epoch uint32, hash crypto.BandersnatchOutputHash) error
- func (t *Ticket) DeleteTicketsForEpoch(epoch uint32) error
- func (t *Ticket) GetTicket(epoch uint32, hash crypto.BandersnatchOutputHash) (block.TicketProof, error)
- func (t *Ticket) GetTicketsForEpoch(epoch uint32) ([]block.TicketProof, error)
- func (t *Ticket) PutTicket(epoch uint32, ticket block.TicketProof, hash crypto.BandersnatchOutputHash) error
- type Trie
- func (t *Trie) DecreaseNodeRefCount(hash crypto.Hash) (uint64, error)
- func (t *Trie) DeleteTrie(rootHash crypto.Hash) error
- func (t *Trie) FetchStateTrieRange(rootHash crypto.Hash, startKey, endKey [31]byte, maxSize uint32) (TrieRangeResult, error)
- func (t *Trie) GetNode(hash crypto.Hash) (trie.Node, error)
- func (t *Trie) GetNodeRefCount(hash crypto.Hash) (uint64, error)
- func (t *Trie) GetNodeValue(node trie.Node) ([]byte, error)
- func (t *Trie) IncreaseNodeRefCount(hash crypto.Hash) error
- func (t *Trie) MerklizeAndCommit(pairs [][2][]byte) (crypto.Hash, error)
- func (t *Trie) TrieExists(rootHash crypto.Hash) (bool, error)
- type TrieRangeResult
- type WorkReport
Constants ¶
const (
ErrFailedBatchCommit = "failed to commit batch: %v"
)
const (
ErrNotLeafNode = "not a leaf node"
)
Variables ¶
var ( ErrBlockNotFound = errors.New("block not found") ErrHeaderNotFound = errors.New("header not found") )
var ErrWorkReportNotFound = errors.New("work-report not found")
Functions ¶
func PrefixToString ¶
PrefixToString converts a prefix byte to a string
Types ¶
type Chain ¶
Chain manages blockchain storage using a key-value store
func (*Chain) FindChildren ¶
FindChildren finds all immediate child blocks for a given block hash
func (*Chain) FindHeader ¶
FindHeader searches for a header that matches the given predicate function. Returns the first matching header and nil error if found. Returns zero header and nil error if no match is found. Returns zero header and error if the chain is closed or if database operations fail.
func (*Chain) GetBlockSequence ¶
func (c *Chain) GetBlockSequence(startHash crypto.Hash, ascending bool, maxBlocks uint32) ([]block.Block, error)
GetBlockSequence retrieves a sequence of blocks. If ascending is true, returns children of the start block (exclusive). If ascending is false, returns the start block and its ancestors (inclusive).
type KeyValuePair ¶
KeyValuePair represents a single key-value pair from the trie
type Shards ¶
type Shards struct {
// contains filtered or unexported fields
}
Shards responsible for storing the bundle and segments shards and justifications
func (*Shards) GetAuditShard ¶
GetAuditShard gets an audit shard by erasure root and shard index
func (*Shards) GetJustification ¶
GetJustification gets a justification by erasure root and shard index
func (*Shards) GetSegmentsShard ¶
GetSegmentsShard gets a segment shard by erasure root and shard index
func (*Shards) PutAllShardsAndJustifications ¶
func (a *Shards) PutAllShardsAndJustifications(erasureRoot crypto.Hash, bundleShards [][]byte, segmentsShards [][][]byte, justifications [][][]byte) error
PutAllShardsAndJustifications stores all segment shards, audit bundle shards and justification in one batch for an erasure root we assume that the number of shards is the same for bundleShard, segmentsShard and justifications, this should be checked before calling the method
func (*Shards) PutShardsAndJustification ¶
func (a *Shards) PutShardsAndJustification(erasureRoot crypto.Hash, shardIndex uint16, bundleShard []byte, segmentsShard [][]byte, justification [][]byte) error
PutShardsAndJustification stores segment shards, audit bundle shards and justification in one batch for an erasure root and shard index
type Ticket ¶
func (*Ticket) DeleteTicket ¶
func (t *Ticket) DeleteTicket(epoch uint32, hash crypto.BandersnatchOutputHash) error
DeleteTicket removes a ticket from the ticket store
func (*Ticket) DeleteTicketsForEpoch ¶
DeleteTicketsForEpoch removes all tickets for a given epoch
func (*Ticket) GetTicket ¶
func (t *Ticket) GetTicket(epoch uint32, hash crypto.BandersnatchOutputHash) (block.TicketProof, error)
GetTicket retrieves a ticket from the ticket store
func (*Ticket) GetTicketsForEpoch ¶
func (t *Ticket) GetTicketsForEpoch(epoch uint32) ([]block.TicketProof, error)
GetTicketsForEpoch retrieves all tickets for a given epoch
func (*Ticket) PutTicket ¶
func (t *Ticket) PutTicket(epoch uint32, ticket block.TicketProof, hash crypto.BandersnatchOutputHash) error
PutTicket stores a ticket in the ticket store
type Trie ¶
func (*Trie) DecreaseNodeRefCount ¶
DecreaseNodeRefCount decrements the reference count for a node Returns the new count and any error
func (*Trie) DeleteTrie ¶
DeleteTrie deletes a trie from the database starting from the root hash
func (*Trie) FetchStateTrieRange ¶
func (t *Trie) FetchStateTrieRange(rootHash crypto.Hash, startKey, endKey [31]byte, maxSize uint32) (TrieRangeResult, error)
FetchStateTrieRange retrieves a range of key-value pairs from the trie starting at startKey and ending at or before endKey. It also returns boundary nodes covering the paths from root to the start key and to the last key in the response. The response size is limited to maxSize bytes, unless the response contains only a single key/value pair.
func (*Trie) GetNodeRefCount ¶
GetNodeRefCount returns the reference count for a node /how many nodes links to this one (how many tries)/.
func (*Trie) GetNodeValue ¶
GetNodeValue retrieves the value from a node /regular and embedded leaf/
func (*Trie) IncreaseNodeRefCount ¶
IncreaseNodeRefCount increments the reference count for a node
func (*Trie) MerklizeAndCommit ¶
MerklizeAndCommit writes a series of key-value pairs to the trie
type TrieRangeResult ¶
type TrieRangeResult struct {
Pairs []KeyValuePair // The key-value pairs in the range
BoundaryNodes []trie.Node // Boundary nodes covering the paths from root to the edges
}
TrieRangeResult represents the result of a trie range query
type WorkReport ¶
WorkReport manages work reports storage using a key-value store
func NewWorkReport ¶
func NewWorkReport(db db.KVStore) *WorkReport
NewWorkReport creates a new work report store using KVStore
func (*WorkReport) DeleteWorkReport ¶
func (r *WorkReport) DeleteWorkReport(h crypto.Hash) error
func (*WorkReport) GetWorkReport ¶
func (r *WorkReport) GetWorkReport(h crypto.Hash) (block.WorkReport, error)
GetWorkReport fetches a work-report by hash.
func (*WorkReport) PutWorkReport ¶
func (r *WorkReport) PutWorkReport(report block.WorkReport) error
PutWorkReport stores a work report in the chain store