{"content":{"title":"BTC，ETC pow挖矿收益计算","body":"pow挖矿就是在2^256数字中，找到符合current_target条件的hah值，所以每一个block都有一个字段保存current_target,表示hash计算的值要小于current_target,链上为了节省存储，使用nBit(32-bit)来保存target(256-bit)\r\n\r\n##### nBit和current_target转换公式\r\n\r\n~~~go\r\n例如 nBits = 0x180192d4，\r\ncurrent_target = 0x192d4 * 2 ^ {(8 * (0x18 - 3))}\r\n~~~\r\n\r\n已知一个block的current_target，需要计算多少次才能符合条件？\r\n\r\n~~~go\r\nhash次数 = 2^256/current_target\r\n~~~\r\n\r\n##### 比特币难度值Difficulty\r\n\r\n难度值在区块中并不记录，仅仅是为了人类直观感受解题难度而演变出的一个浮点数。\r\n\r\n~~~go\r\ndifficulty = difficulty_1_target/current_target\r\n~~~\r\n\r\n此处的 difficulty_1_target 为一个常数0xffff x 2^208。表示矿池挖矿最大难度。**目标值越小，区块生成难度越大**。\r\n\r\n为找到一个难度为D区块，我们需计算哈希值的次数为\r\n\r\n~~~go\r\nhash次数 = 2^256/current_target = 2^256*D/difficulty_1_target\r\n\t\t\t\t= D*2^32\r\n~~~\r\n\r\n##### 网络算力(每秒的hash rate)\r\n\r\n我们知道了挖取难度为D区块，需要运算的次数为D*2^32, 我们只需要在10分钟内计算这么多次就行\r\n\r\n~~~go\r\n全网算力*10*60 = D*2^32\r\n~~~\r\n\r\n全网算力 = D*2^32/600\r\n\r\n##### 单位算力的收益\r\n\r\n比如1G算力，Block难度为D, 一天能爆几个块？\r\n\r\n\r\n~~~go\r\n(10^9 x 86400) / D*2^32\r\n~~~\r\n\r\n有了这些数据，再结合每个爆快能得到多少个BTC，以及当前的大饼价格，就可以计算出1G算力一天的收益了。\r\n\r\n### ETC挖矿收益计算\r\nETC的挖矿难度，比较直白，指的是难度为D时，理论上 需要 D 次hash运算，可以得到一个合法新区块。\r\n比如1G算力，Block难度为D，一天能挖出多少etc\r\n~~~go\r\n(10^9 x 86400) *blockreward/ D\r\n~~~\r\nblockreward是爆块奖励"},"author":{"user":"https://learnblockchain.cn/people/5744","address":null},"history":"QmSkMVEFA4cLTbncHChQdUDKhmcy6tyyqwLBza5kByto8h","timestamp":1681122747,"version":1}