Documentation ¶
Index ¶
- Constants
- Variables
- func CleanTestLedger(t *testing.T)
- func MakeTestLedgerGenesis(t *testing.T)
- func NewLedgerConfig(vp *viper.Viper) *ledgerConfig
- func SetDefaultLedger(l *Ledger)
- func UpgradeLedger(odb *db.OpenchainDB, checkonly bool) error
- func UseLegacyModeOnLedger()
- type BlockChainAccessor
- type BlockChainModifier
- type BlockChainUtil
- type BlockCommit
- type Error
- type ErrorType
- type Ledger
- func (ledger *Ledger) AddGlobalState(parent []byte, state []byte) error
- func (ledger *Ledger) ApplyStateDelta(id interface{}, delta *statemgmt.StateDelta) error
- func (ledger *Ledger) ApplyStateDeltaDirect(delta *statemgmt.StateDelta)
- func (ledger *Ledger) BeginTxBatch(id interface{}) error
- func (ledger *Ledger) CommitAndIndexStateDelta(id interface{}, blockNumber uint64) error
- func (ledger *Ledger) CommitStateDelta(id interface{}) error
- func (ledger *Ledger) CommitTransactions(txids []string, blockNum uint64) error
- func (ledger *Ledger) CommitTxBatch(id interface{}, transactions []*protos.Transaction, ...) error
- func (ledger *Ledger) CopyState(sourceChaincodeID string, destChaincodeID string) error
- func (ledger *Ledger) CreateSnapshot() (*LedgerSnapshot, uint64)
- func (ledger *Ledger) CreateSyncingSnapshot(shash []byte) (*LedgerSnapshot, error)
- func (ledger *Ledger) DeleteALLStateKeysAndValues() error
- func (ledger *Ledger) DeleteState(chaincodeID string, key string) error
- func (ledger *Ledger) EmptyState() error
- func (ledger *Ledger) GetBlockByNumber(blockNumber uint64) (*protos.Block, error)
- func (ledger *Ledger) GetBlockNumberByState(hash []byte) (uint64, error)
- func (ledger *Ledger) GetBlockNumberByTxid(txID string) (uint64, uint64, error)
- func (ledger *Ledger) GetBlockchainInfo() (*protos.BlockchainInfo, error)
- func (ledger *Ledger) GetBlockchainSize() uint64
- func (ledger *Ledger) GetCommitedTransaction(txID string) (*protos.Transaction, error)
- func (ledger *Ledger) GetCurrentStateHash() (stateHash []byte, err error)
- func (ledger *Ledger) GetLedgerInfo() (*LedgerInfo, error)
- func (ledger *Ledger) GetLedgerStatus() *protos.LedgerState
- func (ledger *Ledger) GetRawBlockByNumber(blockNumber uint64) (*protos.Block, error)
- func (ledger *Ledger) GetSnapshotState(chaincodeID string, key string, blknum uint64) ([]byte, uint64, error)
- func (ledger *Ledger) GetStableSyncingState() *protos.StateFilter
- func (ledger *Ledger) GetState(chaincodeID string, key string, committed bool) ([]byte, error)
- func (ledger *Ledger) GetStateDelta(blockNumber uint64) (*statemgmt.StateDelta, error)
- func (ledger *Ledger) GetStateRangeScanIterator(chaincodeID string, startKey string, endKey string, committed bool) (statemgmt.RangeScanIterator, error)
- func (ledger *Ledger) GetStateSnapshot() (*state.StateSnapshot, error)
- func (ledger *Ledger) GetTXBatchPreviewBlockInfo(id interface{}, transactions []*protos.Transaction, metadata []byte) (*protos.BlockchainInfo, error)
- func (ledger *Ledger) GetTempStateHash() ([]byte, error)
- func (ledger *Ledger) GetTempStateHashWithTxDeltaStateHashes() ([]byte, map[string][]byte, error)
- func (ledger *Ledger) GetTransactionsByRange(statehash []byte, beg int, end int) ([]*protos.Transaction, error)
- func (*Ledger) HashBlock(block *protos.Block) ([]byte, error)
- func (ledger *Ledger) LedgerStateInfo() (height uint64, hash []byte, avaliable bool)
- func (ledger *Ledger) PutBlock(blockNumber uint64, block *protos.Block) error
- func (ledger *Ledger) PutRawBlock(block *protos.Block, blockNumber uint64) error
- func (ledger *Ledger) RollbackStateDelta(id interface{}) error
- func (ledger *Ledger) RollbackTxBatch(id interface{}) error
- func (ledger *Ledger) SetState(chaincodeID string, key string, value []byte) error
- func (ledger *Ledger) SetStateMultipleKeys(chaincodeID string, kvs map[string][]byte) error
- func (ledger *Ledger) SubScribeNewBlock(f ...LedgerNewBlockNotify)
- func (ledger *Ledger) SubScribeNewState(f ...LedgerNewStateNotify)
- func (ledger *Ledger) Tag() string
- func (ledger *Ledger) TestContinuouslBlockRange() (ret uint64)
- func (ledger *Ledger) TestExistedBlockRange(blockNumber uint64) uint64
- func (ledger *Ledger) TxBegin(txID string)
- func (ledger *Ledger) TxFinished(txID string, txSuccessful bool)
- func (ledger *Ledger) UnderlyingDB() *db.OpenchainDB
- func (ledger *Ledger) VerifyBlockchain(highBlock, lowBlock uint64) (uint64, error)
- func (ledger *Ledger) VerifyChain(highBlock, lowBlock uint64) (uint64, error)
- type LedgerGlobal
- func (ledger *LedgerGlobal) AddCommitHook(hf func([]string, uint64))
- func (ledger *LedgerGlobal) AddGlobalState(parent []byte, state []byte) error
- func (ledger *LedgerGlobal) GetConsensusData(statehash []byte) []byte
- func (ledger *LedgerGlobal) GetGlobalState(statehash []byte) *protos.GlobalState
- func (ledger *LedgerGlobal) GetPooledTxCount() int
- func (ledger *LedgerGlobal) GetTransactionByID(txID string) (*protos.Transaction, error)
- func (ledger *LedgerGlobal) GetTransactionsByID(txIDs []string) []*protos.Transaction
- func (ledger *LedgerGlobal) GetTransactionsByIDAligned(txIDs []string) []*protos.Transaction
- func (ledger *LedgerGlobal) GetTxForExecution(txIDs []string, preh protos.TxPreHandler) ([]*protos.TransactionHandlingContext, []string)
- func (ledger *LedgerGlobal) IteratePooledTransactions(ctx context.Context) (chan *protos.TransactionHandlingContext, error)
- func (ledger *LedgerGlobal) MustGetTransactionByID(txID string) *protos.Transaction
- func (ledger *LedgerGlobal) PoolTransaction(txe *protos.TransactionHandlingContext)
- func (ledger *LedgerGlobal) PruneTransactions(txs []*protos.Transaction)
- func (ledger *LedgerGlobal) PutTransactions(txs []*protos.Transaction) error
- type LedgerInfo
- type LedgerNewBlockNotify
- type LedgerNewStateNotify
- type LedgerSnapshot
- func (sledger *LedgerSnapshot) GetBlockByNumber(blockNumber uint64) (*protos.Block, error)
- func (sledger *LedgerSnapshot) GetBlockNumberByState(hash []byte) (uint64, error)
- func (sledger *LedgerSnapshot) GetBlockchainSize() (uint64, error)
- func (sledger *LedgerSnapshot) GetParitalRangeIterator() (statemgmt.PartialRangeIterator, error)
- func (sledger *LedgerSnapshot) GetRawBlockByNumber(blockNumber uint64) (*protos.Block, error)
- func (sledger *LedgerSnapshot) GetStateDelta(blockNumber uint64) (*statemgmt.StateDelta, error)
- func (sledger *LedgerSnapshot) GetStateSnapshot() (*state.StateSnapshot, error)
- func (sledger *LedgerSnapshot) TestContinuouslBlockRange() (uint64, error)
- type PartialSync
- type StateAccessor
- type StateManager
- type TxEvaluateAndCommit
- func (tec *TxEvaluateAndCommit) AddExecResult(txRes *protos.TransactionResult)
- func (tec *TxEvaluateAndCommit) AddExecSuccessResult(s TxExecStates, txRes *protos.TransactionResult)
- func (tec *TxEvaluateAndCommit) AssignExecRT() TxExecStates
- func (tec *TxEvaluateAndCommit) FullCommit(metadata []byte, transactions []*protos.Transaction) error
- func (tec *TxEvaluateAndCommit) LastCommitPosition() uint64
- func (tec *TxEvaluateAndCommit) LastCommitState() []byte
- func (tec *TxEvaluateAndCommit) Ledger() *Ledger
- func (tec *TxEvaluateAndCommit) MergeExec(s TxExecStates)
- func (tec *TxEvaluateAndCommit) PreviewBlock(position uint64, blk *protos.Block) (*protos.Block, error)
- func (tec *TxEvaluateAndCommit) StateCommitOne(refBlockNumber uint64, refBlock *protos.Block) error
- type TxExecStates
- func (s TxExecStates) AppyInvokingResult(l *Ledger)
- func (s TxExecStates) Get(chaincodeID string, key string, l *Ledger) (ret []byte, err error)
- func (s TxExecStates) GetRangeScanIterator(chaincodeID string, startKey string, endKey string, l *Ledger) (statemgmt.RangeScanIterator, error)
- func (s *TxExecStates) InitForInvoking(l *Ledger)
- func (s *TxExecStates) InitForQuerying(l *Ledger)
- func (s TxExecStates) IsEmpty() bool
- func (s TxExecStates) Uninited() bool
Constants ¶
const ( //ErrorTypeInvalidArgument used to indicate the invalid input to ledger method ErrorTypeInvalidArgument = ErrorType("InvalidArgument") //ErrorTypeOutOfBounds used to indicate that a request is out of bounds ErrorTypeOutOfBounds = ErrorType("OutOfBounds") //ErrorTypeResourceNotFound used to indicate if a resource is not found ErrorTypeResourceNotFound = ErrorType("ResourceNotFound") //ErrorTypeBlockNotFound used to indicate if a block is not found when looked up by it's hash ErrorTypeBlockNotFound = ErrorType("ErrorTypeBlockNotFound") //ErrorTypeFatalCommit used to indicate fatal error in commit: we obtain unexpected different //result (hashes) from different source (e.g.: by local execution and incoming block) ErrorTypeFatalCommit = ErrorType("ErrorTypeFatalError") )
Variables ¶
var ( ErrNormalEnd = newLedgerError(ErrorType("None"), "ledger: normal end") // ErrOutOfBounds is returned if a request is out of bounds ErrOutOfBounds = newLedgerError(ErrorTypeOutOfBounds, "ledger: out of bounds") // ErrResourceNotFound is returned if a resource is not found ErrResourceNotFound = newLedgerError(ErrorTypeResourceNotFound, "ledger: resource not found") )
var BuildPreviewBlock = buildBlock
Functions ¶
func CleanTestLedger ¶
func MakeTestLedgerGenesis ¶
func NewLedgerConfig ¶
func SetDefaultLedger ¶
func SetDefaultLedger(l *Ledger)
func UpgradeLedger ¶
func UpgradeLedger(odb *db.OpenchainDB, checkonly bool) error
func UseLegacyModeOnLedger ¶
func UseLegacyModeOnLedger()
Types ¶
type BlockChainAccessor ¶
type BlockChainAccessor interface { GetBlockByNumber(blockNumber uint64) (*protos.Block, error) GetBlockchainSize() uint64 GetCurrentStateHash() (stateHash []byte, err error) }
BlockChainAccessor interface for retreiving blocks by block number
type BlockChainModifier ¶
type BlockChainModifier interface { ApplyStateDelta(id interface{}, delta *statemgmt.StateDelta) error RollbackStateDelta(id interface{}) error CommitStateDelta(id interface{}) error EmptyState() error PutBlock(blockNumber uint64, block *protos.Block) error }
BlockChainModifier interface for applying changes to the block chain
type BlockChainUtil ¶
type BlockChainUtil interface { HashBlock(block *protos.Block) ([]byte, error) VerifyBlockchain(start, finish uint64) (uint64, error) }
BlockChainUtil interface for interrogating the block chain
type BlockCommit ¶
type BlockCommit struct {
// contains filtered or unexported fields
}
commit blocks, can work concurrent with mutiple block commiter, or state commiter
func NewBlockAgent ¶
func NewBlockAgent(ledger *Ledger) *BlockCommit
func (BlockCommit) LastCommit ¶
func (blkc BlockCommit) LastCommit() []byte
func (*BlockCommit) SyncCommitBlock ¶
func (blkc *BlockCommit) SyncCommitBlock(blkn uint64, block *protos.Block) (err error)
commit a block in specified position, it make a "full" commit (including persistent index and transactions), notice it can not be concurrent with mutiple block commitings becasue the db written must be in sequence
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error can be used for throwing an error from ledger code.
type Ledger ¶
type Ledger struct { *LedgerGlobal // contains filtered or unexported fields }
Ledger - the struct for openchain ledger Threadsafy: we purpose ledger is a read-safe object for multi-thread but NOT write-safe
func GetNewLedger ¶
func GetNewLedger(db *db.OpenchainDB, config *ledgerConfig) (*Ledger, error)
GetNewLedger - gives a reference to a new ledger TODO need better approach
func InitSecondaryTestLedger ¶
func InitSoleTestLedger ¶
func InitTestLedger ¶
InitTestLedger provides a ledger for testing. This method creates a fresh db and constructs a ledger instance on that.
func (*Ledger) AddGlobalState ¶
overload AddGlobalState in ledgerGlobal
func (*Ledger) ApplyStateDelta ¶
func (ledger *Ledger) ApplyStateDelta(id interface{}, delta *statemgmt.StateDelta) error
ApplyStateDelta applies a state delta to the current state. This is an in memory change only. You must call ledger.CommitStateDelta to persist the change to the DB. This should only be used as part of state synchronization. State deltas can be retrieved from another peer though the Ledger.GetStateDelta function or by creating state deltas with keys retrieved from Ledger.GetStateSnapshot(). For an example, see TestSetRawState in ledger_test.go Note that there is no order checking in this function and it is up to the caller to ensure that deltas are applied in the correct order. For example, if you are currently at block 8 and call this function with a delta retrieved from Ledger.GetStateDelta(10), you would now be in a bad state because you did not apply the delta for block 9. It's possible to roll the state forwards or backwards using stateDelta.RollBackwards. By default, a delta retrieved for block 3 can be used to roll forwards from state at block 2 to state at block 3. If stateDelta.RollBackwards=false, the delta retrieved for block 3 can be used to roll backwards from the state at block 3 to the state at block 2.
func (*Ledger) ApplyStateDeltaDirect ¶
func (ledger *Ledger) ApplyStateDeltaDirect(delta *statemgmt.StateDelta)
func (*Ledger) BeginTxBatch ¶
BeginTxBatch - gets invoked when next round of transaction-batch execution begins
func (*Ledger) CommitAndIndexStateDelta ¶
CommitStateDelta will commit the state delta passed to ledger.ApplyStateDelta to the DB and persist it will the specified index (blockNumber)
func (*Ledger) CommitStateDelta ¶
----- Will be deprecated ---- CommitStateDelta will commit the state delta passed to ledger.ApplyStateDelta to the DB
func (*Ledger) CommitTransactions ¶
func (*Ledger) CommitTxBatch ¶
func (ledger *Ledger) CommitTxBatch(id interface{}, transactions []*protos.Transaction, transactionResults []*protos.TransactionResult, metadata []byte) error
CommitTxBatch - gets invoked when the current transaction-batch needs to be committed This function returns successfully iff the transactions details and state changes (that may have happened during execution of this transaction-batch) have been committed to permanent storage
func (*Ledger) CopyState ¶
CopyState copies all the key-values from sourceChaincodeID to destChaincodeID
func (*Ledger) CreateSnapshot ¶
func (ledger *Ledger) CreateSnapshot() (*LedgerSnapshot, uint64)
create a snapshot wrapper for current db, the corresponding blocknumber is also returned for verifing this snapshot is not enusred to sync with state and should be only used for block syncing and indexing should be avoiding used
func (*Ledger) CreateSyncingSnapshot ¶
func (ledger *Ledger) CreateSyncingSnapshot(shash []byte) (*LedgerSnapshot, error)
func (*Ledger) DeleteALLStateKeysAndValues ¶
DeleteALLStateKeysAndValues deletes all keys and values from the state. This is generally only used during state synchronization when creating a new state from a snapshot.
func (*Ledger) DeleteState ¶
DeleteState tracks the deletion of state for chaincodeID and key. Does not immediately writes to DB
func (*Ledger) EmptyState ¶
alias of DeleteALLStateKeysAndValues
func (*Ledger) GetBlockByNumber ¶
GetBlockByNumber return block given the number of the block on blockchain. Lowest block on chain is block number zero
func (*Ledger) GetBlockNumberByState ¶
GetBlockNumberByState return given block nuber from a state, also used to check states
func (*Ledger) GetBlockNumberByTxid ¶
func (*Ledger) GetBlockchainInfo ¶
func (ledger *Ledger) GetBlockchainInfo() (*protos.BlockchainInfo, error)
GetBlockchainInfo returns information about the blockchain ledger such as height, current block hash, and previous block hash.
func (*Ledger) GetBlockchainSize ¶
GetBlockchainSize returns number of blocks in blockchain
func (*Ledger) GetCommitedTransaction ¶
func (ledger *Ledger) GetCommitedTransaction(txID string) (*protos.Transaction, error)
func (*Ledger) GetCurrentStateHash ¶
GetCurrentStateHash returns the current non-committed hash of the in memory state
func (*Ledger) GetLedgerInfo ¶
func (ledger *Ledger) GetLedgerInfo() (*LedgerInfo, error)
func (*Ledger) GetLedgerStatus ¶
func (ledger *Ledger) GetLedgerStatus() *protos.LedgerState
func (*Ledger) GetRawBlockByNumber ¶
func (*Ledger) GetSnapshotState ¶
func (*Ledger) GetStableSyncingState ¶
func (ledger *Ledger) GetStableSyncingState() *protos.StateFilter
TODO: use snapshot manager for syncing is not complete correct beacuse syncer may lost their available state because all nodes have trunced the target state, (consider a node is syncing some state A from another node B and B is off-line in the process, and time has passed so no other nodes will keep the state which A wish to sync) later we should use checkpoint for state syncing and a long hold node should be provided for alleviating this problem
func (*Ledger) GetState ¶
GetState get state for chaincodeID and key. If committed is false, this first looks in memory and if missing, pulls from db. If committed is true, this pulls from the db only.
func (*Ledger) GetStateDelta ¶
func (ledger *Ledger) GetStateDelta(blockNumber uint64) (*statemgmt.StateDelta, error)
GetStateDelta will return the state delta for the specified block if available. If not available because it has been discarded, returns nil,nil.
func (*Ledger) GetStateRangeScanIterator ¶
func (ledger *Ledger) GetStateRangeScanIterator(chaincodeID string, startKey string, endKey string, committed bool) (statemgmt.RangeScanIterator, error)
GetStateRangeScanIterator returns an iterator to get all the keys (and values) between startKey and endKey (assuming lexical order of the keys) for a chaincodeID. If committed is true, the key-values are retrieved only from the db. If committed is false, the results from db are mergerd with the results in memory (giving preference to in-memory data) The key-values in the returned iterator are not guaranteed to be in any specific order
func (*Ledger) GetStateSnapshot ¶
func (ledger *Ledger) GetStateSnapshot() (*state.StateSnapshot, error)
----- will be deprecated ----- GetStateSnapshot returns a point-in-time view of the global state for the current block. This should be used when transferring the state from one peer to another peer. You must call stateSnapshot.Release() once you are done with the snapshot to free up resources.
func (*Ledger) GetTXBatchPreviewBlockInfo ¶
func (ledger *Ledger) GetTXBatchPreviewBlockInfo(id interface{}, transactions []*protos.Transaction, metadata []byte) (*protos.BlockchainInfo, error)
GetTXBatchPreviewBlockInfo returns a preview block info that will contain the same information as GetBlockchainInfo will return after ledger.CommitTxBatch is called with the same parameters. If the state is modified by a transaction between these two calls, the contained hash will be different.
func (*Ledger) GetTempStateHash ¶
GetTempStateHash - Computes state hash by taking into account the state changes that may have taken place during the execution of current transaction-batch
func (*Ledger) GetTempStateHashWithTxDeltaStateHashes ¶
GetTempStateHashWithTxDeltaStateHashes - In addition to the state hash (as defined in method GetTempStateHash), this method returns a map [txUuid of Tx --> cryptoHash(stateChangesMadeByTx)] Only successful txs appear in this map
func (*Ledger) GetTransactionsByRange ¶
func (ledger *Ledger) GetTransactionsByRange(statehash []byte, beg int, end int) ([]*protos.Transaction, error)
GetTransactionByID return transaction by it's txId
func (*Ledger) LedgerStateInfo ¶
func (*Ledger) PutBlock ¶
PutBlock put a raw block on the chain and also commit the corresponding transactions
func (*Ledger) PutRawBlock ¶
PutRawBlock just puts a raw block on the chain without handling the tx
func (*Ledger) RollbackStateDelta ¶
RollbackStateDelta will discard the state delta passed to ledger.ApplyStateDelta
func (*Ledger) RollbackTxBatch ¶
RollbackTxBatch - Discards all the state changes that may have taken place during the execution of current transaction-batch
func (*Ledger) SetState ¶
SetState sets state to given value for chaincodeID and key. Does not immideatly writes to DB
func (*Ledger) SetStateMultipleKeys ¶
SetStateMultipleKeys sets the values for the multiple keys. This method is mainly to amortize the cost of grpc communication between chaincode shim peer
func (*Ledger) SubScribeNewBlock ¶
func (ledger *Ledger) SubScribeNewBlock(f ...LedgerNewBlockNotify)
func (*Ledger) SubScribeNewState ¶
func (ledger *Ledger) SubScribeNewState(f ...LedgerNewStateNotify)
func (*Ledger) TestContinuouslBlockRange ¶
test how height the blocks we have obtained continuously, return the FINAL block number (not the height)
func (*Ledger) TestExistedBlockRange ¶
func (*Ledger) TxFinished ¶
TxFinished - Marks the finish of the on-going transaction. If txSuccessful is false, the state changes made by the transaction are discarded
func (*Ledger) UnderlyingDB ¶
func (ledger *Ledger) UnderlyingDB() *db.OpenchainDB
func (*Ledger) VerifyBlockchain ¶
alias of verifychain
func (*Ledger) VerifyChain ¶
VerifyChain will verify the integrity of the blockchain. This is accomplished by ensuring that the previous block hash stored in each block matches the actual hash of the previous block in the chain. The return value is the block number of lowest block in the range which can be verified as valid. The first block is assumed to be valid, and an error is only returned if the first block does not exist, or some other sort of irrecoverable ledger error such as the first block failing to hash is encountered. For example, if VerifyChain(0, 99) is called and previous hash values stored in blocks 8, 32, and 42 do not match the actual hashes of respective previous block 42 would be the return value from this function. highBlock is the high block in the chain to include in verification. If you wish to verify the entire chain, use ledger.GetBlockchainSize() - 1. lowBlock is the low block in the chain to include in verification. If you wish to verify the entire chain, use 0 for the genesis block.
type LedgerGlobal ¶
type LedgerGlobal struct {
// contains filtered or unexported fields
}
Ledger - the struct for openchain ledger
func GetLedgerGlobal ¶
func GetLedgerGlobal() (*LedgerGlobal, error)
GetLedger - gives a reference to a 'singleton' global ledger, it was the only singleton part (the ledger singleton is just for compatible)
func (*LedgerGlobal) AddCommitHook ¶
func (ledger *LedgerGlobal) AddCommitHook(hf func([]string, uint64))
func (*LedgerGlobal) AddGlobalState ¶
func (ledger *LedgerGlobal) AddGlobalState(parent []byte, state []byte) error
func (*LedgerGlobal) GetConsensusData ¶
func (ledger *LedgerGlobal) GetConsensusData(statehash []byte) []byte
func (*LedgerGlobal) GetGlobalState ¶
func (ledger *LedgerGlobal) GetGlobalState(statehash []byte) *protos.GlobalState
///////////////// global state related methods /////////////////////////////////////
func (*LedgerGlobal) GetPooledTxCount ¶
func (ledger *LedgerGlobal) GetPooledTxCount() int
func (*LedgerGlobal) GetTransactionByID ¶
func (ledger *LedgerGlobal) GetTransactionByID(txID string) (*protos.Transaction, error)
GetTransactionByID return transaction by it's txId
func (*LedgerGlobal) GetTransactionsByID ¶
func (ledger *LedgerGlobal) GetTransactionsByID(txIDs []string) []*protos.Transaction
only return array of avaliable txs
func (*LedgerGlobal) GetTransactionsByIDAligned ¶
func (ledger *LedgerGlobal) GetTransactionsByIDAligned(txIDs []string) []*protos.Transaction
func (*LedgerGlobal) GetTxForExecution ¶
func (ledger *LedgerGlobal) GetTxForExecution(txIDs []string, preh protos.TxPreHandler) ([]*protos.TransactionHandlingContext, []string)
return tx arrays, has same lens of the incoming txIDs, for any id unavaliable, nil is returned
func (*LedgerGlobal) IteratePooledTransactions ¶
func (ledger *LedgerGlobal) IteratePooledTransactions(ctx context.Context) (chan *protos.TransactionHandlingContext, error)
func (*LedgerGlobal) MustGetTransactionByID ¶
func (ledger *LedgerGlobal) MustGetTransactionByID(txID string) *protos.Transaction
func (*LedgerGlobal) PoolTransaction ¶
func (ledger *LedgerGlobal) PoolTransaction(txe *protos.TransactionHandlingContext)
func (*LedgerGlobal) PruneTransactions ¶
func (ledger *LedgerGlobal) PruneTransactions(txs []*protos.Transaction)
func (*LedgerGlobal) PutTransactions ¶
func (ledger *LedgerGlobal) PutTransactions(txs []*protos.Transaction) error
type LedgerInfo ¶
type LedgerInfo struct { //base info *protos.BlockchainInfo //NOTICE following integer fields are all "HEIGHT" of //the chain, that is, the final block number PLUS 1 //the queryable height for main modules, //the height of states decide the height //in base info Avaliable struct { Blocks uint64 States uint64 Indexes uint64 } //the persisted height for main modules, //any state above this heigh can be easily //rollback to //notice some of the fields may higher than //current active height, according to the commit //strategy it was applied to Persisted struct { Blocks uint64 States uint64 Indexes uint64 } States struct { //can query state current Avaliable bool //states's most available hash, if avaliable is false, it shows the //targethash it is syncing to, or it has the persisted statehash AvaliableHash []byte } }
type LedgerNewBlockNotify ¶
only the "raw" block (i.e. without transactions) is notified
type LedgerNewStateNotify ¶
type LedgerSnapshot ¶
type LedgerSnapshot struct { *db.DBSnapshot // contains filtered or unexported fields }
func (*LedgerSnapshot) GetBlockByNumber ¶
func (sledger *LedgerSnapshot) GetBlockByNumber(blockNumber uint64) (*protos.Block, error)
func (*LedgerSnapshot) GetBlockNumberByState ¶
func (sledger *LedgerSnapshot) GetBlockNumberByState(hash []byte) (uint64, error)
notice the indexs in snapshot is not ensured to be latest (e.g. in the asyncindexers)
func (*LedgerSnapshot) GetBlockchainSize ¶
func (sledger *LedgerSnapshot) GetBlockchainSize() (uint64, error)
func (*LedgerSnapshot) GetParitalRangeIterator ¶
func (sledger *LedgerSnapshot) GetParitalRangeIterator() (statemgmt.PartialRangeIterator, error)
func (*LedgerSnapshot) GetRawBlockByNumber ¶
func (sledger *LedgerSnapshot) GetRawBlockByNumber(blockNumber uint64) (*protos.Block, error)
func (*LedgerSnapshot) GetStateDelta ¶
func (sledger *LedgerSnapshot) GetStateDelta(blockNumber uint64) (*statemgmt.StateDelta, error)
func (*LedgerSnapshot) GetStateSnapshot ¶
func (sledger *LedgerSnapshot) GetStateSnapshot() (*state.StateSnapshot, error)
func (*LedgerSnapshot) TestContinuouslBlockRange ¶
func (sledger *LedgerSnapshot) TestContinuouslBlockRange() (uint64, error)
test how height the blocks we have obtained continuously
type PartialSync ¶
type PartialSync struct {
// contains filtered or unexported fields
}
state syncing commiter
func AssignSyncAgent ¶
func AssignSyncAgent(ledger *Ledger) (PartialSync, error)
func NewSyncAgent ¶
func NewSyncAgent(ledger *Ledger, blkn uint64, stateHash []byte) (PartialSync, error)
func (PartialSync) ApplySyncData ¶
func (syncer PartialSync) ApplySyncData(data *protos.SyncStateChunk) error
func (PartialSync) AssignTasks ¶
func (syncer PartialSync) AssignTasks() ([]*protos.SyncOffset, error)
func (PartialSync) CleanTask ¶
func (syncer PartialSync) CleanTask()
func (PartialSync) FinishTask ¶
func (syncer PartialSync) FinishTask() error
func (PartialSync) GetTarget ¶
func (syncer PartialSync) GetTarget() []byte
type StateAccessor ¶
type StateAccessor interface { GetStateSnapshot() (*state.StateSnapshot, error) GetStateDelta(blockNumber uint64) (*statemgmt.StateDelta, error) GetGlobalState(statehash []byte) *protos.GlobalState }
StateAccessor interface for query states of current history and global
type StateManager ¶
StateManager interface for manage history view and global states
type TxEvaluateAndCommit ¶
type TxEvaluateAndCommit struct {
// contains filtered or unexported fields
}
full tx commiter, to build new block and corresponding state on top of current chain from the execution results of a bunch of txs. CANNOT concurrent with other commiter
func NewTxEvaluatingAgent ¶
func NewTxEvaluatingAgent(ledger *Ledger) (*TxEvaluateAndCommit, error)
func (*TxEvaluateAndCommit) AddExecResult ¶
func (tec *TxEvaluateAndCommit) AddExecResult(txRes *protos.TransactionResult)
func (*TxEvaluateAndCommit) AddExecSuccessResult ¶
func (tec *TxEvaluateAndCommit) AddExecSuccessResult(s TxExecStates, txRes *protos.TransactionResult)
func (*TxEvaluateAndCommit) AssignExecRT ¶
func (tec *TxEvaluateAndCommit) AssignExecRT() TxExecStates
func (*TxEvaluateAndCommit) FullCommit ¶
func (tec *TxEvaluateAndCommit) FullCommit(metadata []byte, transactions []*protos.Transaction) error
commit current results and persist them
func (*TxEvaluateAndCommit) LastCommitPosition ¶
func (tec *TxEvaluateAndCommit) LastCommitPosition() uint64
func (*TxEvaluateAndCommit) LastCommitState ¶
func (tec *TxEvaluateAndCommit) LastCommitState() []byte
func (*TxEvaluateAndCommit) Ledger ¶
func (tec *TxEvaluateAndCommit) Ledger() *Ledger
func (*TxEvaluateAndCommit) MergeExec ¶
func (tec *TxEvaluateAndCommit) MergeExec(s TxExecStates)
func (*TxEvaluateAndCommit) PreviewBlock ¶
func (tec *TxEvaluateAndCommit) PreviewBlock(position uint64, blk *protos.Block) (*protos.Block, error)
preview build required part of a block for commiting
func (*TxEvaluateAndCommit) StateCommitOne ¶
func (tec *TxEvaluateAndCommit) StateCommitOne(refBlockNumber uint64, refBlock *protos.Block) error
push state forward one, refblock can be used for verify the expected state
type TxExecStates ¶
type TxExecStates struct {
*state.TxExecStates
}
func NewQueryExecState ¶
func NewQueryExecState(l *Ledger) TxExecStates
func (TxExecStates) AppyInvokingResult ¶
func (s TxExecStates) AppyInvokingResult(l *Ledger)
func (TxExecStates) GetRangeScanIterator ¶
func (s TxExecStates) GetRangeScanIterator(chaincodeID string, startKey string, endKey string, l *Ledger) (statemgmt.RangeScanIterator, error)
func (*TxExecStates) InitForInvoking ¶
func (s *TxExecStates) InitForInvoking(l *Ledger)
----------- leagacy API following ------------
func (*TxExecStates) InitForQuerying ¶
func (s *TxExecStates) InitForQuerying(l *Ledger)
func (TxExecStates) IsEmpty ¶
func (s TxExecStates) IsEmpty() bool
func (TxExecStates) Uninited ¶
func (s TxExecStates) Uninited() bool
Source Files ¶
- api_deprecated.go
- blockchain.go
- blockchain_indexes.go
- blockchain_indexes_async_deprecated.go
- blockchain_indexes_base.go
- ledger.go
- ledger_commit.go
- ledger_commit_sync.go
- ledger_config.go
- ledger_global.go
- ledger_info.go
- ledger_notification.go
- ledger_snapshot.go
- ledger_test_exports.go
- ledger_upbrade.go
- state.go
- transaction.go