主要是做序列化工作,为挖矿做最后的准备。
GetHash
对区块下面所有数据进行哈希。主要算法 Keccak256 或者说 keccak
构建过程,根据其数据结构,分几个部分构建,然后合并成一个。
包含:
GetBlockWork
对 BlockWork 进行散列哈希
// see spec here https://cryptonote.org/cns/cns003.txt
// this function gets the block identifier hash
// this has been simplified and varint length has been removed
GetBlockWork
主要由以下 4 部分组成:元数据(除 Proof 外)、Miner_TX、Tips、Tx_hashes
self, hasone, belongstomany, hasmany
输入为 Block_Header(除 Miner_TX 外)数据。
结果固定为 76 个字节,即长度为 146 的字符串。
// converts a block, into a getwork style work, ready for either submitting the block
// or doing Pow Calculations
包含:
getserializedheaderforwork
getserializedheaderforwork
// serialize block header for calculating PoW
包含:
Miner_TX.Serialize
GetTipsHash
GetTXSHash
Miner_TX.Serialize
// write miner tx
GetTipsHash
// get block transactions tree hash
// write tips,, merkle tree should be replaced with something faster
GetTXSHash
// hash of all transactions
// get block transactions
// we have discarded the merkle tree and have shifted to a plain version
GetPoWHash
针对在 GetBlockWork 的结果进行 cryptonight.SlowHash 运算。
// Get PoW hash , this is very slow function
包含:
GetBlockWork
SlowHash
设置 Proof 功能尚未实现,即还不能直接运用此软件进行挖矿。
引入 DAG 后,把原来单一的父块 hash 变成了可有多个父块 hash.
Serialize
序列化,输出字节数据。
Deserialize
反序列化,输入字节数据。