Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
之前的代码在mining.configure阶段,version_mask是ffffffff,随后发送mining.set_version_mask将其改为1fffe000,这似乎与翼比特E12不兼容,导致它不能正常挖矿。
所以添加了一个配置项BitcoinDefaultVersionMask,默认与服务器当前配置相同(0x1fffe000),如果服务器配置后续更改,还能在连上矿池后自动更新。因为目前的连接策略是矿池未就绪就把矿机踢下线,所以多用户模式最开始的连接获取不到正确的version mask也没关系,随后等连上矿池并更新version mask之后,矿机才能真正上线。
在进行这项改动后,请求我进行改动的矿工反馈称问题得到解决。备注:与此同时我还设置了
"always_keep_downconn": true
,也许是它解决了问题,我没有深入调查。不过不管怎么说,这个修改的好处还是大于坏处的,因为它让智能代理更加符合 Version Rolling 的协议规范。
为什么 default version mask 是全局的,而不是特定于子账户 /
UpSession
?因为很多矿机的
mining.configure
先于mining.authorize
发送,此时根本不知道子账户是什么。这也是我们之前不得不发送ffffffff
的原因。更新 version mask 时的竟态条件
以下代码没有加锁,确实存在竟态条件(
DownSession
可以在这里写入的同时读取该值)。但是加锁的代价太高了,似乎不太值得。而且只要服务器保持0x1fffe000
不变,就不会触发更新,也就没有竟态条件了。https://github.com/TigerForkGroup/btcagent/blob/70f60d99e5a2738cba3a43a5d15ef3102d822a0f/UpSessionBTC.go#L369-L372
与矿工的聊天记录: