Read_output_index
RPC 服务接口用到它。
// this will read the output index data but will not deserialize it
// this is exposed for rpcserver giving access to wallet
Find_TX_Output_Index
RPC 服务接口用到它。
// this function finds output index for the tx
// first find a block index , and get the start offset
// then loop the index till you find the key in the result
// if something is not right, we return 0
先找到区块所在索引,然后交易迭代寻找里面各个输出的索引。
write_output_index
被 blockchain Add_Complete_Block 调用。
针对 Index_Data
和 TX_Output_Data
的写操作只有此一入口,简单的存储数据。
// this function writes or overwrites the data related to outputs
// the following data is collected from each output
// the secret key,
// the commitment ( for miner tx the commitment is created from scratch
// 8 bytes blockheight to which this output belongs
// this function should always succeed or panic showing something is not correct
// NOTE: this function should only be called after all the tx and the block has been stored to DB
“输出索引”只不过是个引子,“交易输出数据”才是真实要想存储的数据。
“交易输出数据”有3个来源:挖矿交易、普通转账交易、合约里的对外转账交易。
load_output_index
被 blockchain Expand_Transaction_v2 调用。
// this will load the index data for specific index
// this should be done while holding the chain lock,
// since during reorganisation we might give out wrong keys,
// to avoid that pitfall take the chain lock
// NOTE: this function is now for internal use only by the blockchain itself