Bitcointalk · New getwork

中本聪,2010 年 11 月 24 日

SN-3644 已核对来源,附原文与上下文。

阅读语言
中文译文

实现已然完成……然而跑不通,先别太兴奋。我怀疑 ByteReverse(或缺少它)有什么古怪。'data' 和 'nonce' 到底要不要字节反转、怎么反转,相当不清楚。

getwork 负责字节反转。midstate、data 和 hash1 已然是大端序,你把 data 按大端序传回去即可,因而你全程用大端序工作,不需要做任何字节反转。它们与传给 ScanHash_ 函数的是同一份数据。你能够把 midstate、data 和 hash1 放进 16 字节对齐的缓冲区,传给 ScanHash_ 函数,譬如 ScanHash(pmidstate, pdata + 64, phash1, nHashesDone)。找到 nonce 后,把它补进 data 再调用 getwork。

我或许理应把 ScanHash_ 函数改成用 pdata 而不是 pdata + 64,如此更一致。

target 是小端序,意图与 m0mchil 的做法一致。(倘若不是,那就理应修正。)这是唯一需要你做字节反转的地方。我猜是这样:if ByteReverse((unsigned int*)hash[6]) < (unsigned int*)target[6]。

中本聪,请修正你的 getwork 实现,使其符合 m0mchill 的规范

这就是新规范。把你的矿工更新到它理应不难。

变化有: - 提交疑似命中时不返回新工作,仅仅不带参数调用时才返回。 - 区块字段已拆分为 data 和 hash1。 - state 改名为 midstate,保持一致性。 - 不再需要 extranonce。

ORIGINAL · 英文原文
I suspect something weird going on with ByteReverse (or lack thereof).  It's quite unclear whether or not 'data' and 'nonce' must be byte-reversed, and in what way.
getwork does the byte-reversing.  midstate, data and hash1 are already big-endian, and you pass data back still big-endian, so you work in big-endian and don't have to do any byte-reversing.  They're the same data that is passed to the ScanHash_ functions.  You can take midstate, data and hash1, put them in 16-byte aligned buffers and pass them to a ScanHash_ function, like ScanHash(pmidstate, pdata + 64, phash1, nHashesDone).  If a nonce is found, patch it into data and call getwork.

I should probably change the ScanHash_ functions to use pdata instead of pdata + 64 so they're consistent.

target is little endian, it's supposed to be the same as how m0mchil's did it.  (if it's not, then it should be fixed)  That's the only case where you would use byte reverse.  I think you do it like: if ByteReverse((unsigned int*)hash[6]) < (unsigned int*)target[6].

Satoshi, please fix your implementation of getwork so it complies with m0mchill's specification
This is the new spec.  It shouldn't be hard to update your miner to use it.

The changes are:
- It does not return work when you submit a possible hit, only when called without parameter.
- The block field has been split into data and hash1.
- state renamed to midstate for consistency.
- extranonce not needed.
来源
Bitcointalk 原始链接 ↗ 记录编号 SN-3644