原始文献 / 论坛帖 / New getwork

New getwork

Bitcointalk · 2010-11-23 19:50:12 UTC

AuthorSatoshi Nakamoto
TitleNew getwork
Date2010-11-23 19:50:12 UTC
ForumBitcointalk · 原文

我把 m0mchil 的 getwork 重新设计了一版,上传到 SVN rev 189(31601 版)

m0mchil 的外部比特币矿机想法解决了很多问题。GPU 编程不成熟、编译困难,我也不想给构建再加依赖。getwork 让这些问题可以分开解决,不同的硬件和系统用不同的程序。矿场跑一个比特币节点、其余只跑 getwork 客户端也很方便。

接口有几处改动:

getwork [data]
如果不给 [data],返回格式化好的待计算哈希数据:
"midstate":对前半数据做哈希后预计算的哈希状态
"data":区块数据
"hash1":第二次哈希用的格式化哈希缓冲
"target":小端序哈希目标
如果给了 [data],尝试解这个区块,成功返回 true。[data] 就是 "data” 字段里返回的那 128 字节区块数据,只是 nonce 改了。

注意:
- 提交可能命中的结果时不返回工作,只有不带参数调用时才返回。
- block 字段已拆成 data 和 hash1。
- data 是 128 字节,包含 midstate 已哈希过的前半部分。
- hash1 恒定不变,为方便起见也包含在内。
- "ThreadRPCServer method=getwork” 的日志已关掉,否则日志里垃圾太多。

英文原文

I uploaded a redesign of m0mchil's getwork to SVN rev 189 (version 31601)

m0mchil's external bitcoin miner idea has solved a lot of problems.  GPU programming is immature and hard to compile, and I didn't want to add additional dependencies to the build.  getwork allows these problems to be solved separately, with different programs for different hardware and OSes.  It's also convenient that server farms can run a single Bitcoin node and the rest only run getwork clients.

The interface has a few changes:

getwork [data]
If [data] is not specified, returns formatted hash data to work on:
  "midstate" : precomputed hash state after hashing the first half of the data
  "data" : block data
  "hash1" : formatted hash buffer for second hash
  "target" : little endian hash target
If [data] is specified, tries to solve the block and returns true if it was successful.  [data] is the same 128 byte block data that was returned in the "data" field, but with the nonce changed.

Notes:
- It does not return work when you submit a possible hit, only when called without parameter.
- The block field has been separated into data and hash1.
- data is 128 bytes, which includes the first half that's already hashed by midstate.
- hash1 is always the same, but included for convenience.
- Logging of "ThreadRPCServer method=getwork" is disabled, it would be too much junk in the log.