@@ -72,16 +72,20 @@ func (cm *ChainstateManager) ReadBlockSpentOutputs(blockTreeEntry *BlockTreeEntr
7272}
7373
7474// ProcessBlock processes and validates the passed in block with the chainstate
75- // manager. More detailed validation information in case of a failure can also
76- // be retrieved through a registered validation interface. If the block fails
77- // to validate the validation interface's BlockChecked callback's BlockValidationState
78- // will contain details.
75+ // manager. Processing first does checks on the block, and if these passed,
76+ // saves it to disk. It then validates the block against the utxo set. If it is
77+ // valid, the chain is extended with it. The ok return value is not indicative of
78+ // the block's validity. Detailed information on the validity of the block can
79+ // be retrieved by registering the block_checked callback in the validation
80+ // interface.
7981//
8082// Parameters:
8183// - block: Block to validate and potentially add to the chain
8284//
8385// Returns ok=true if processing the block was successful (will also return true for valid,
84- // but duplicate blocks) and duplicate=false if this block was not processed before.
86+ // but duplicate blocks) and duplicate=false if this block was not processed before. Note that
87+ // duplicate might also be false if processing was attempted before, but the block was found
88+ // invalid before its data was persisted.
8589func (cm * ChainstateManager ) ProcessBlock (block * Block ) (ok bool , duplicate bool ) {
8690 var newBlock C.int
8791 result := C .btck_chainstate_manager_process_block ((* C .btck_ChainstateManager )(cm .ptr ), (* C .btck_Block )(block .ptr ), & newBlock )
@@ -92,12 +96,11 @@ func (cm *ChainstateManager) ProcessBlock(block *Block) (ok bool, duplicate bool
9296
9397// GetActiveChain returns the currently active best-known chain.
9498//
95- // The chain's lifetime depends on this chainstate manager. State transitions (e.g.,
96- // processing blocks) will change the chain, so data retrieved from it is only consistent
97- // until new data is processed.
98- //
99- // The returned Chain is a non-owned pointer valid for the lifetime of this
100- // chainstate manager.
99+ // The returned Chain can be thought of as a view on a vector of block tree entries
100+ // that form the best chain. The chain's lifetime depends on this chainstate manager.
101+ // State transitions (e.g., processing blocks) will change the chain, so data retrieved
102+ // from it is only consistent until new data is processed. It is the caller's responsibility
103+ // to guard against these inconsistencies.
101104func (cm * ChainstateManager ) GetActiveChain () * Chain {
102105 return & Chain {C .btck_chainstate_manager_get_active_chain ((* C .btck_ChainstateManager )(cm .ptr ))}
103106}
0 commit comments