We are trying to deal with the problem
we need normal stratum-mining for this coin. and update for mpos
It is the codes from subscription.py, and it is broadcast the information to the miner,
def on_template(cls, is_new_block):
'''This is called when TemplateRegistry registers
new block which we have to broadcast clients.'''
start = Interfaces.timestamper.time()
clean_jobs = is_new_block
(job_id, prevhash, coinb1, coinb2, merkle_branch, version, nbits, ntime, _, nsuperblock, nroundmask) = \
Interfaces.template_registry.get_last_broadcast_args()
# Push new job to subscribed clients
for subscription in Pubsub.iterate_subscribers(cls.event):
try:
if subscription != None:
session = subscription.connection_ref().get_session()
session.setdefault('authorized', {})
if session['authorized'].keys():
worker_name = session['authorized'].keys()[0]
difficulty = session['difficulty']
work_id = Interfaces.worker_manager.register_work(worker_name, job_id, difficulty)
subscription.emit_single(work_id, prevhash, coinb1, coinb2, merkle_branch, version, nbits, ntime, clean_jobs, nsuperblock, nroundmask)
else:
subscription.emit_single(job_id, prevhash, coinb1, coinb2, merkle_branch, version, nbits, ntime, clean_jobs, nsuperblock, nroundmask)
except Exception as e:
log.exception("Error broadcasting work to client %s" % str(e))
pass
cnt = Pubsub.get_subscription_count(cls.event)
log.info("BROADCASTED to %d connections in %.03f sec" % (cnt, (Interfaces.timestamper.time() - start)))
To keep the compatibility with the other coin, two fields (nsuperblock, nroundmask) are added on the last parameter array,
it is the generated stratum message
{"params": ["3ea", "7fa9003135c9c5a9f28a16e43d7e59cd3c972ac7b6edcf71af36788fe6218d63", "0100000044b35f53010000000000000000000000000000000000000000000000000000000000000 000ffffffff26027f0e062f503253482f0444b35f5308", "0d2f7374726174756d506f6f6c2f000000000100e876481700000023210352c7246a18044e7850f 0b90c97c3bd19a0a5f36134795e435f20d8df73eadc76ac00000000", [], "00000004", "1c060264", "535fb344", true, "00000000", "00000007"], "id": null, "method": "mining.notify"}
"params" is an array format, generally, using 8 items, and, old SGMINER/CGMINER just read those 8 parameters only.
with 8 items, 80 bytes headers will be assembled,
and, extra two 4 bytes variables are superblock and roundmask,
with those addtional, 88 bytes header can be completed,
ex) parse_notify function in UTIL.C(sgminer/cgminer), please check this function from the latest sgminer source code
in our repo.
It is the example of BlockHeader
000000047fa9003135c9c5a9f28a16e43d7e59cd3c972ac7b6edcf71af36788fe6218d6344fd219
06f829a5526ccb7420becc82f9441ece5cf80434844bb683311d789fe535fb3441c060264 00000000 00000000 00000007 000000800000000000000000000000000000000000000000000000000000000000000000c002000
0
If parse_notify function has updated correctly, input block header will be assembled like it,
and, Hashing Function will check the 00000007 to decide the hashing method.
and, Hashing Function will use from 88 bytes for the hashing input.