Skip to content

回复:新的 getwork ​

原始发布页

打开来源页面
查看 1 个交叉存档

引用 jgarzik 于 2010 年 11 月 24 日 上午 04:47:42 的发言

我怀疑 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]。

引用 DiabloD3 于 2010 年 11 月 24 日 上午 11:31:11 的发言

Satoshi,请修复你的 getwork 实现,使它符合 m0mchill 的规范

这就是新规范。更新你的矿工来使用它应该不难。

改动如下: - 提交一个可能命中的结果时,它不会返回工作,只有不带参数调用时才会返回。 - block 字段已拆分为 data 和 hash1。 - 为保持一致,state 已重命名为 midstate。 - 不需要 extranonce。

英文原文 ​

展开英文原文

Quote from: jgarzik on November 24, 2010, 04:47:42 AM

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].

Quote from: DiabloD3 on November 24, 2010, 11:31:11 AM

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.

为历史保存,为中文读者整理。每篇档案均附来源与英文原文。