Documentation ¶
Index ¶
- type MinimumMerkleTree
- type ShardStateManager
- func (state *ShardStateManager) ApplyUpdate(update *Update) error
- func (state *ShardStateManager) GetBlockHeadersToAppend(ledgerInfo *wire.LedgerInfo) ([]*wire.BlockHeader, error)
- func (state *ShardStateManager) GetLedgerRoot() merkle.MerkleHash
- func (state *ShardStateManager) GetShardHeight(shardIndex shard.Index) int64
- func (state *ShardStateManager) GetUpdateWithFullBlock(block *wire.MsgBlock) (*Update, error)
- func (state *ShardStateManager) GetUpdateWithSlimBlock(block *wire.SlimBlock) (*Update, error)
- func (state *ShardStateManager) LedgerInfo() *wire.LedgerInfo
- func (state *ShardStateManager) LocalLedgerInfo() *wire.LedgerInfo
- func (state *ShardStateManager) NewUpdate() (*Update, error)
- type Update
- func (update *Update) AddHeaders(headers ...*wire.BlockHeader) error
- func (update *Update) GetShardDataOutProof(oldOut, newOut *wire.OutState) (*merkle.MerklePath, error)
- func (update *Update) GetShardHeight(shardIdx shard.Index) int64
- func (update *Update) MarkSpentOuts(outPoint *wire.OutPoint, proof *merkle.MerklePath) error
- func (update *Update) UpdateProofs(proofs []merkle.MerklePath) ([]merkle.MerklePath, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MinimumMerkleTree ¶
type MinimumMerkleTree struct { Root merkle.MerkleHash Size int64 LastPath merkle.MerklePath }
MinimumMerkleTree storages a merkleTree's root,size and last path.
func (MinimumMerkleTree) Copy ¶
func (tree MinimumMerkleTree) Copy() MinimumMerkleTree
Copy the MinimumMerkleTree and return a new tree.
type ShardStateManager ¶
type ShardStateManager struct { // A delta merkle tree of the shard ledger, for updating all pending transaction proofs. Tree MinimumMerkleTree // The height of each shard. ShardHeights map[shard.Index]int64 // contains filtered or unexported fields }
ShardStateManager keeps state of the shard ledger.
func NewShardStateManager ¶
func NewShardStateManager(root *merkle.MerkleHash, size int64, latestPath *merkle.MerklePath, ledgerInfo *wire.LedgerInfo, chain iblockchain.BlockChain) *ShardStateManager
NewShardStateManager initialize new ShardStateManager object with necessary info to build a delta merkle tree.
func (*ShardStateManager) ApplyUpdate ¶
func (state *ShardStateManager) ApplyUpdate(update *Update) error
ApplyUpdate Applies a given StateUpdate (mutation).
func (*ShardStateManager) GetBlockHeadersToAppend ¶
func (state *ShardStateManager) GetBlockHeadersToAppend(ledgerInfo *wire.LedgerInfo) ([]*wire.BlockHeader, error)
GetBlockHeadersToAppend retrieve continous block headers in each shard for the range from current ledger info to the given ledger info.
func (*ShardStateManager) GetLedgerRoot ¶
func (state *ShardStateManager) GetLedgerRoot() merkle.MerkleHash
GetLedgerRoot returns the last updated ledger
func (*ShardStateManager) GetShardHeight ¶
func (state *ShardStateManager) GetShardHeight(shardIndex shard.Index) int64
GetShardHeight returns the height of Specified shard
func (*ShardStateManager) GetUpdateWithFullBlock ¶
func (state *ShardStateManager) GetUpdateWithFullBlock(block *wire.MsgBlock) (*Update, error)
GetUpdateWithFullBlock returns a new update instance which update with the given block. 1. marks spent outs in the merkle tree and updates the merkle root; 2. conditionally appends the merkle root of new outs from cached block headers, according to given full block header; 3. update merkle tree according to update action
func (*ShardStateManager) GetUpdateWithSlimBlock ¶
func (state *ShardStateManager) GetUpdateWithSlimBlock(block *wire.SlimBlock) (*Update, error)
GetUpdateWithSlimBlock returns a new update instance which update with the given block. 1. marks spent outs in the merkle tree and updates the merkle root; 2. conditionally appends the merkle root of new outs from cached block headers, according to given full block header; 3. update merkle tree according to update action
func (*ShardStateManager) LedgerInfo ¶
func (state *ShardStateManager) LedgerInfo() *wire.LedgerInfo
LedgerInfo returns all shards' ledgerInfo
func (*ShardStateManager) LocalLedgerInfo ¶
func (state *ShardStateManager) LocalLedgerInfo() *wire.LedgerInfo
LocalLedgerInfo returns the ledgerInfo which blocks in state's chache may not update
func (*ShardStateManager) NewUpdate ¶
func (state *ShardStateManager) NewUpdate() (*Update, error)
NewUpdate Creates a new empty Update (mutation) based on current state.
type Update ¶
type Update struct { DeltaTree *merkle.DeltaMerkleTree // contains filtered or unexported fields }
Update Represents an mutation of the Shard Ledger.
func (*Update) AddHeaders ¶
func (update *Update) AddHeaders(headers ...*wire.BlockHeader) error
AddHeaders Adds new headers in given order into this update. Delta Ledger Tree will be appended with outs tree root in each header. Ledger Info will be update accordingly for each shard.
func (*Update) GetShardDataOutProof ¶
func (update *Update) GetShardDataOutProof(oldOut, newOut *wire.OutState) (*merkle.MerklePath, error)
GetShardDataOutProof returns the proof of shard init data.
func (*Update) GetShardHeight ¶
GetShardHeight returns the shard's height given shardIndex.
func (*Update) MarkSpentOuts ¶
MarkSpentOuts Add a modification of spent Out state to this mutation.
func (*Update) UpdateProofs ¶
func (update *Update) UpdateProofs(proofs []merkle.MerklePath) ([]merkle.MerklePath, error)
UpdateProofs trys to update a slice of input proofs (merkle path) based on this mutation.