First of all, I am very new to Bitcoin mining and using Python to learn Bitcoin mining for educational purpose. I am using AntPool for pool connection.
When I send mining.subscribe
request, it returns success message which is :
{'error': None, 'id': 1, 'result': [[['mining.notify', '000038531'], ['mining.set_difficulty', '000038532']], '00003853', 8]}
And after that I am sending mining.authorize
and keep listening for the response :
response = ''
while True :
response += sock.recv( 4096 ).decode()
print( response )
the response prints as follows :
{"error":null,"id":2,"result":true}
{"id":null,"method":"mining.set_difficulty","params":[65536]}
{"id":null,"method":"mining.notify","params":["1584274","a13ff6cd9afdd2a64ab3feeffd534fd02d18a6f10000d43c0000000000000000","01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff5603116f0c194d696e656420627920416e74506f6f6c20be011400b2123f07fabe6d6d4037b0ffd0265a536d9de256d13b40d383d559c7d3cbb1f237b776b1dbd80a8a0200000000000000","ffffffff04d0e5b1260000000017a9144b09d828dfc8baaba5d04ee77397e04b1050cc73870000000000000000266a24aa21a9edbf56483f00f76579ad2ad040a2f9335ac7ac45a7deea02bc75aaf4adfb69b94000000000000000002f6a2d434f52450164db24a662e20bbdf72d1cc6e973dbb2d12897d55997be5a09d05bb9bac27ec60419d0b373f32b2000000000000000002b6a2952534b424c4f434b3a74865c3658252b5e3c16fb30e325b46de6f6dcb714464f3c457fd723005817dd00000000",["0fb4598fe0ab84d9c79ff84aab9009e9466f3505d11bc609de76f06c0c6e61fb","7c91537fad082b32438a5753ab5873cab8204122c337309b33cf490af8030267","72243530e7290879580fde93614e0dc8edaa357e6abaef67ecf1e515646bfc6a","a7894d16318a2cf53428ed6f8019ef8bca9d9a11d62bc63934c93cecce7e4e4c","c8d5b0dd08916b26e459583a57d817f93db8656768d0d5bd372d04a58ca7cf22","411c13bd9641648aada122415dbab210e13db29df8b955a1045d3c5927bac7fb","d194aabe11ad2b52605b9f4c310076aca522f7879ae71b326ef8e2c7c29f9cc6","815b7d5046cf6bbc9c05d3cee2e4c6bd5339d57fde5acb4afe4b9ac4741bcb21","bf8f7e949153bbad99d72bb2f47b55c289b438cce99c8c0212b92753a19e1917","407eac951a77bceda2f661e9ec4e
{"error":null,"id":2,"result":true}
{"id":null,"method":"mining.set_difficulty","params":[65536]}
{"id":null,"method":"mining.notify","params":["1584274","a13ff6cd9afdd2a64ab3feeffd534fd02d18a6f10000d43c0000000000000000","01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff5603116f0c194d696e656420627920416e74506f6f6c20be011400b2123f07fabe6d6d4037b0ffd0265a536d9de256d13b40d383d559c7d3cbb1f237b776b1dbd80a8a0200000000000000","ffffffff04d0e5b1260000000017a9144b09d828dfc8baaba5d04ee77397e04b1050cc73870000000000000000266a24aa21a9edbf56483f00f76579ad2ad040a2f9335ac7ac45a7deea02bc75aaf4adfb69b94000000000000000002f6a2d434f52450164db24a662e20bbdf72d1cc6e973dbb2d12897d55997be5a09d05bb9bac27ec60419d0b373f32b2000000000000000002b6a2952534b424c4f434b3a74865c3658252b5e3c16fb30e325b46de6f6dcb714464f3c457fd723005817dd00000000",["0fb4598fe0ab84d9c79ff84aab9009e9466f3505d11bc609de76f06c0c6e61fb","7c91537fad082b32438a5753ab5873cab8204122c337309b33cf490af8030267","72243530e7290879580fde93614e0dc8edaa357e6abaef67ecf1e515646bfc6a","a7894d16318a2cf53428ed6f8019ef8bca9d9a11d62bc63934c93cecce7e4e4c","c8d5b0dd08916b26e459583a57d817f93db8656768d0d5bd372d04a58ca7cf22","411c13bd9641648aada122415dbab210e13db29df8b955a1045d3c5927bac7fb","d194aabe11ad2b52605b9f4c310076aca522f7879ae71b326ef8e2c7c29f9cc6","815b7d5046cf6bbc9c05d3cee2e4c6bd5339d57fde5acb4afe4b9ac4741bcb21","bf8f7e949153bbad99d72bb2f47b55c289b438cce99c8c0212b92753a19e1917","407eac951a77bceda2f661e9ec4e4c3e24fcb6eb31a70f050df63d6fb150a628","5f76ab3f47409f96caf884d2ace733b7f23b4fb6b8e5d28cc5c2d7ce155cda7f","93beefdc90073e8e71b4522aeb86e2623d2e924a97e03d45990887b0286feda0"],"20000000","17048194","654290b7",true]}
And when I get the first mining.notify
response that is a job with unique job id provided by the pool, I start creating the block header with random nonce value and finally submit if found with that job id.
And I notice is that it keeps sending new mining.notify
responses, my question is for each new job received from the pool, I start building new block header with that job id. So each job is valid and should be running creating hashes for that or previous job is not valid once new job comes and I should only start generating hashes for new found job and terminate old jobs hash creation?
Is each job can be counted as a new process as async doing it's hash creation and all the jobs are unique and can run in parallel solving it's own nonce?