Github 地址:https://github.com/Bytom/bytom
Gitee 地址:https://gitee.com/BytomBlockchain/bytom
https://service.bitmain.com.cn/support
./bytomd init --chain_id testnet 或 ./bytomd init --chain_id solonetinit/node 初始化 /启动时可以加上 -r "your/directory" 指定数据目录,若目录不存在则会自动新建该目录1、初始化节点先建个账户、地址,不然就挖到空地址
2、矿地址支持自定义,包括 非本地钱包地址
3、API doc
4、矿池向节点 getwork
get-work 得到的 block_header 是动态压缩变长的需要进行解析
"github.com/bytom/protocol/bc/types" 中 block_header.go 中的函数 UnmarshalText"github.com/bytom/protocol/bc/types" 中 block.go 中的函数 UnmarshalText, readFrom, ReadVarintXXX. ReadVarintXXX 需要参考 go 函数 binary.ReadUvarint5、解析完后进行下发
login 和 矿池主动下发, 没走 getjob, 只走 login 和 池主动下发 - 这俩都是用 submit 提交Version, Height, Timestamp, Bits 要转小端 - 关于 target + btc.com 分享了一段 antpool 的代码 ~, 并说 target 用以对 bits 对应的 difficulty 放松难度,用来使矿机在单位时间内能够有提交,然后矿池再验证~ var Diff1 = StringToBig("0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF")
func GetTargetHex(diff int64) string {
padded := make([]byte, 32)
diffBuff := new(big.Int).Div(Diff1, big.NewInt(diff)).Bytes()
copy(padded[32-len(diffBuff):], diffBuff)
buff := padded[0:4]
targetHex := hex.EncodeToString(Reverse(buff))
return targetHex
}
0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) / 一个难度值得出的ffff3f00 对应 1024,c5a70000 对应 1000016、提交完之后矿池需要做验证
"github.com/bytom/protocol/bc/types" 中 types.BlockHeader{} 的 Hash() 使用别的语言的话参考 https://github.com/Bytom/B3-Mimic/blob/master/docs/blhr_hash_V3.gocpp 的 tensority 逻辑在这里,并指出了如何针对 gpu 进行优化的建议,这样矩阵乘法能够跑进 2.5 ms, 整个 tensority 大概 6 ms
7、验证通过后使用 submit-work 接口进行提交
提交的结果 也是 BlockHeader type 的
"github.com/bytom/protocol/bc/types" 中 block_header.go 中的函数 MmarshalText"github.com/bytom/protocol/bc/types" 中 block.go 中的函数 MarshalText, WriteTo, WriteVarintXXX. WriteVarintXXX 需要参考 go 函数 binary.PutUvarint8、retarget
见上面,动态调整使矿机每分钟提交三次
9、收益计算
略