mining.subscribe stratum metodo semplici esempi e spiegazioni

Segui e Condividi ora!

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 e 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.

mining.subscribe call:

Suggerimento:

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)

Avviso:

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
}
}

Pubblica qui il tuo commento

L'indirizzo email non verrà pubblicato. i campi richiesti sono contrassegnati *

Demo gratuita!

Registrati ora, il sistema di Crypto Calloway
per ottenere un account demo gratuita:

Join the Calloway Crypto Soft now!

Ora leggi tutto recensione!

Se avete ulteriori domande o inciampare, si prega di e-mail immediato per earnmoneytodayblog@gmail.com oppure utilizzare il semplice Modulo di Contatto.

 

money.today guadagnare sfida riuscita: 1041/2000 trader di successo. Prova ora Sistema crittografico Calloway o sistemi di trading gratis altri verificati e inviarci quanto riuscito siete e quanto profitto si e cosa possiamo fare per voi il diritto.

52%

Ultimo trader di successo:
B. Antje
Essere il prossimo!