/** Nodes collect new transactions into a block, hash them into a hash tree,
* and scan through nonce values to make the block's hash satisfy proof-of-work
* requirements. When they solve the proof-of-work, they broadcast the block
* to everyone and the block is added to the block chain. The first transaction
* in the block is a special one that creates a new coin owned by the creator
* of the block.
*/classCBlockHeader
{public:
// headerint32_t nVersion; // 版本号,指定验证规则(indicates which set of block validation rules to follow)
uint256 hashPrevBlock; // 前一区块哈希(实际计算时取得是前一区块头哈希)(a reference to the parent/previous block in the blockchain)
uint256 hashMerkleRoot; // 默克尔根哈希(a hash (root hash) of the merkle tree data structure containing a block's transactions)uint32_t nTime; // 时戳(seconds from Unix Epoch)uint32_t nBits; // 区块难度(aka the difficulty target for this block)uint32_t nNonce; // 工作量证明nonce(value used in proof-of-work)// ...部分代码省略...
}
pubstructTransactionInput {
pub previous_output: OutPoint, //上一笔交易输出pub script_sig: Bytes, //解锁脚本pub sequence: u32, //序列号pub script_witness: Vec<Bytes>, //见证脚本
}
/** An outpoint - a combination of a transaction hash and an index n into its vout */pubstructOutPoint {
pub hash: H256, //交易IDpub index: u32, //输出索引,表明是交易中的第几个输出
}