Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- json_t *MyObject = json_object();
- json_t *json_arr = json_array();
- json_object_set_new(MyObject, "id", json_integer(4));
- json_object_set_new(MyObject, "method", json_string("mining.submit"));
- json_array_append(json_arr, json_string(rpc_user));
- int Err = 0;
- uchar hexjob_id[4]; // = (uchar*)malloc(4);
- hex2bin((uchar*)&hexjob_id, sobid, 4);
- // printf("the submitted job id = %s \n",sobid);
- free(sobid);
- json_array_append(json_arr, json_bytes((uchar*)&hexjob_id, 4));
- json_array_append(json_arr, json_bytes(work->xnonce2, sizeof(uint64_t*)));
- json_array_append(json_arr, json_bytes((uchar*)&ntime, sizeof(uint32_t)));
- json_array_append(json_arr, json_bytes((uchar*)&nonce, sizeof(uint32_t)));
- json_array_append(json_arr, json_bytes(mtp->MerkleRoot, SizeMerkleRoot));
- json_array_append(json_arr, json_bytes((uchar*)mtp->nBlockMTP, SizeBlockMTP));
- json_array_append(json_arr, json_bytes(mtp->nProofMTP, SizeProofMTP));
- json_object_set_new(MyObject, "params", json_arr);
- json_error_t *boserror = (json_error_t *)malloc(sizeof(json_error_t));
- bos_t *serialized = bos_serialize(MyObject, boserror);
- stratum.sharediff = work->sharediff[0];
- if (unlikely(!stratum_send_line_bos(&stratum, serialized))) {
- applog(LOG_ERR, "submit_upstream_work stratum_send_line failed");
- free(boserror);
- json_decref(MyObject);
- bos_free(serialized);
- return false;
- }
- free(boserror);
- json_decref(MyObject);
- bos_free(serialized);
- // stratum_recv_line_compact(&stratum);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement