mining.subscribe stratum method easy examples and explanations

Volgen en delen nu!

mijnbouw. abonneren is a in the stratum protocol defined methods for a miner to subscript an encrypted currency mining pool for work:

Function of mining.subscribe:

mijnbouw. abonneren 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 en 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 mijnbouw. 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.

mining.subscribe call:

Hint:

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)

Description:

{
"id": <Number>,
"method": "mining.subscribe",
"params": [ <String>, <Number> ]
}
(\n)

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.

Example:

{
"id": 0,
"method": "mining.subscribe",
"params": [ "cgminer/4.11.1" ]
}
(\n)

mining.subscribe response:

Description:

{
"id": 0,
"result": [ [ [ "mining.set_difficulty", "1" ], [ "mining.notify", "1" ] ], "066507045fcae8", 4 ],
"error": null
}
(\n)

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.

Example:

{
"id": 0,
"result": [ [ [ "mining.set_difficulty", "1" ], [ "mining.notify", "1" ] ], "066507045fcae8", 4 ],
"error": null
}
(\n)

Warning:

Make sure to send always the right data type. “4” is not the same as 4!

Java example implementation:

public final class StratumSender {
private static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
private static final String STRATUM_REQUEST_BASE =
"{\"id\":%s,\"method\":\"%s\",\"params\":[%s]}\n";
private final OutputStream out;
public StratumSender(final OutputStream out) {
if(out == null) {
throw new IllegalArgumentException("out == null");
}
this.out = out;
}
public void subscribe(final int id, final String identifier) {
if(identifier == null) {
throw new IllegalArgumentException("identifier == null");
}
final String f = String.format(STRATUM_REQUEST_BASE, id,
"mining.subscribe", identifier);
write(f);
}
public void subscribe(final int id, final String identifier,
final int extranonce) {
if(identifier == null) {
throw new IllegalArgumentException("identifier == null");
}
final String f = String.format(STRATUM_REQUEST_BASE, id,
"mining.subscribe", (identifier + "," + extranonce));
write(f);
}
public void write(final String s) {
write(s.getBytes(DEFAULT_CHARSET));
}
public void write(final byte[] bs) {
if(bs == null) {
throw new IllegalArgumentException("bs == null");
}
try {
out.write(bs);
} catch (final IOException e) {
throw new RuntimeException(e);
}// don't forget to flush the output
}
}

Plaats uw reactie hier

Uw e-mailadres wordt niet gepubliceerd. Verplichte velden zijn gemarkeerd *

Gratis Demo!

Toetreden tot het Calloway Crypto systeem nu,
om een gratis demo-account:

Join the Calloway Crypto Soft now!

Lees nu de hele beoordeling!

Hebt u aanvullende vragen of struikelen, stuur een email naar direct naar earnmoneytodayblog@gmail.com of gebruik de simpele Contact Formulier.

 

verdienen-money.today succesvolle uitdaging: 1041/2000 succesvolle handelaar. Test nu Calloway Crypto systeem of andere geverifieerde handelssystemen kostenloos en stuur ons hoe succesvol je bent en hoeveel winst je gemaakt, en kan wat wij voor u kunnen doen.

52%

Laatste succesvolle handelaar:
Antje B.
Worden de volgende!