兄弟连区块链入门教程以太坊源码分析hashimoto源码分析(二)

编程入门 行业动态 更新时间:2024-10-15 12:31:28

兄弟连区块链入门教程<a href=https://www.elefans.com/category/jswz/34/1768575.html style=以太坊源码分析hashimoto源码分析(二)"/>

兄弟连区块链入门教程以太坊源码分析hashimoto源码分析(二)

区块链入门教程 以太坊源码分析hashimoto源码分析(二)。
“超级计算机是将计算受限问题转化为I / O约束问题的一种设备。”
Ken Batcher

Instead, an algorithm will have little room to be sped up by new hardware if it acts in a way that commodity computer systems are already optimized for.

相反,如果一种算法以商品计算机系统已经优化的方式运行,那么算法将没有多少空间可以被新硬件加速。

Since I/O bounds are what decades ofcomputing research has gone towards solving, it’s unlikely that the relatively small motivation ofmining a few coins would be able to advance the state ofthe art in cache hierarchies. In the case that advances are made, they will be likely to impact the entire industry of computer hardware.

由于I / O界限是几十年来计算研究已经解决的问题,挖掘一些加密货币的相对较小的动机将不可能提高缓存层次结构的艺术水平。 在取得进展的情况下,可能会影响整个计算机硬件产业。

Fortuitously, all nodes participating in current implementations ofcryptocurrency have a large set of mutually agreed upon data; indeed this “blockchain” is the foundation ofthe currency. Using this large data set can both limit the advantage ofspecialized hardware, and require working nodes to have the entire data set.

幸运的是,参与当前加密货币实施的所有节点都有大量相互同意的数据;实际上,“区块链”是货币的基础。 使用这个大数据集既可以限制专用硬件的优点,又可以让工作节点拥有整个数据集。

Hashimoto is based offBitcoin’s proofofwork2. In Bitcoin’s case, as in Hashimoto, a successful
proofsatisfies the following inequality:

Hashimoto是基于比特币的工作量证明。 在比特币的情况下,和Hashimoto一样,一个成功的证明满足以下不等式:

hash_output < target

For bitcoin, the hash_output is determined by

在比特币中, hash_output是由下面决定的。

hash_output = sha256(prev_hash, merkle_root, nonce)

where prev_hash is the previous block’s hash and cannot be changed. The merkle_root is based on the transactions included in the block, and will be different for each individual node. The nonce is rapidly incremented as hash_outputs are calculated and do not satisfy the inequality. Thus the bottleneck of the proofis the sha256 function, and increasing the speed ofsha256 or parallelizing it is something ASICs can do very effectively.

prev_hash是前一个区块的hash值,而且不能更改。merkle_root是基于区块中的交易生成的,并且对于每个单独的节点将是不同的。我们通过修改nonce的值来让上面的不等式成立。这样整个工作量证明的瓶颈在于sha256方法,而且通过ASIC可以极大增加sha256的计算速度,或者并行的运行它。

Hashimoto uses this hash output as a starting point, which is used to generated inputs for a second hash function. We call the original hash hash_output_A, and the final result of the prooffinal_output.

Hashimoto使用这个hash_output作为一个起点,用来生成第二个hash函数的输入。我们称原始的hash为hash_output_A, 最终的结果为 prooffinal_output.

Hash_output_A can be used to select many transactions from the shared blockchain, which are then used as inputs to the second hash. Instead of organizing transactions into blocks, for this purpose it is simpler to organize all transactions sequentially. For example, the 47th transaction of the 815th block might be termed transaction 141,918. We will use 64 transactions, though higher and lower numbers could work, with different access properties. We define the following functions:

hash_output_a可用于从共享区块链中选择多个事务,然后将其用作第二个散列的输入。 而不是组织交易成块,为此目的是顺序组织所有交易更简单。 例如,第815个区块的第47个交易可能被称为交易141,918。 我们将使用64个交易,尽管更高和更低的数字可以工作,具有不同的访问属性。 我们定义以下功能:

  • nonce 64­bits. A new nonce is created for each attempt.

  • get_txid(T) return the txid (a hash ofa transaction) of transaction number T from block B.

  • block_height the current height ofthe block chain, which increases at each new block

  • nonce 64­bits. 每次尝试会生成一个新的nonce值.

  • get_txid(T) 从block B中通过交易序号来获取交易id

  • block_height 当前的区块高度

Hashimoto chooses transactions by doing the following:

Hashimoto 通过下面的算法来挑选交易:

    hash_output_A = sha256(prev_hash, merkle_root, nonce)for i = 0 to 63 doshifted_A = hash_output_A >> itransaction = shifted_A mod total_transactionstxid[i] = get_txid(transaction) << iend fortxid_mix = txid[0] ⊕ txid[1] … ⊕ txid[63]final_output = txid_mix ⊕ (nonce << 192)
The target is then compared with final_output, and smaller values are accepted as proofs.

如果 final_output 比 target小,那么就会被接受。




来自 “ ITPUB博客 ” ,链接:/,如需转载,请注明出处,否则将追究法律责任。

转载于:/

更多推荐

兄弟连区块链入门教程以太坊源码分析hashimoto源码分析(二)

本文发布于:2024-03-06 02:20:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1714101.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:以太   源码   区块   兄弟连   入门教程

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!