mining.subscribe stratum method easy examples and explanations
mining.subscribe is a in the stratum protocol defined methods for a miner to subscript an encrypted currency mining pool for work:
Function of mining.subscribe:
mining.subscribe is except of the relative new mining.configuration usual the first data, a miner send after build up a TCP connection. It is send like all stratum methods as a JSON map and has a required and an optional parameter. The return value is a complex list structure, containing the initial difficulty, subscription id, Extranonce1 and Extranonce2_size. The Extranonce1 is per-connection unique to protect again repeating work, Extranonce2_size the size of Extranonce2 in bytes. The Nonces are numbers for changing the block headers double SHA-256 hash with the same core data. Many pools answer with a dummy difficulty and send after the answer immediate mining.set_difficulty. The pool starts after that to send work using mining.notify. You get jobs unauthenticated, but you need to send mining.authenticate to get paid for your work. That is usual the next command, the miner send.
Extra line-wrapping for readability. Spaces get ignored but should get filtered out to keep the traffic for miner and pool as low as possible. A call ends with a line feed. (UTF-8 10/0x0A)
The usual id is a for every call with expected return value increasing number, hence 0 or 1, but can be virtually anything. The params list contains a simple text line as personal identifier of the miner software and optional the last Extranonce. The pool may do but don’t need to continue with this.
id contains the same element, the request did. The result is a list. This list contains a list, the Extranonce1 coded as hexadecimal string and the size of Extranonce2 in bytes as number. The inner list contains two lists, each of them contains a property name and a string value. error contains a value to identify a happened error, if any occurred, null otherwise.
Make sure to send always the right data type. “4” is not the same as 4!