Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. json_t *MyObject = json_object();
  2. json_t *json_arr = json_array();
  3. json_object_set_new(MyObject, "id", json_integer(4));
  4. json_object_set_new(MyObject, "method", json_string("mining.submit"));
  5.  
  6. json_array_append(json_arr, json_string(rpc_user));
  7.  
  8. int Err = 0;
  9.  
  10. uchar hexjob_id[4]; // = (uchar*)malloc(4);
  11. hex2bin((uchar*)&hexjob_id, sobid, 4);
  12. // printf("the submitted job id = %s \n",sobid);
  13. free(sobid);
  14.  
  15. json_array_append(json_arr, json_bytes((uchar*)&hexjob_id, 4));
  16. json_array_append(json_arr, json_bytes(work->xnonce2, sizeof(uint64_t*)));
  17. json_array_append(json_arr, json_bytes((uchar*)&ntime, sizeof(uint32_t)));
  18. json_array_append(json_arr, json_bytes((uchar*)&nonce, sizeof(uint32_t)));
  19. json_array_append(json_arr, json_bytes(mtp->MerkleRoot, SizeMerkleRoot));
  20. json_array_append(json_arr, json_bytes((uchar*)mtp->nBlockMTP, SizeBlockMTP));
  21. json_array_append(json_arr, json_bytes(mtp->nProofMTP, SizeProofMTP));
  22.  
  23. json_object_set_new(MyObject, "params", json_arr);
  24.  
  25. json_error_t *boserror = (json_error_t *)malloc(sizeof(json_error_t));
  26. bos_t *serialized = bos_serialize(MyObject, boserror);
  27.  
  28. stratum.sharediff = work->sharediff[0];
  29.  
  30. if (unlikely(!stratum_send_line_bos(&stratum, serialized))) {
  31. applog(LOG_ERR, "submit_upstream_work stratum_send_line failed");
  32. free(boserror);
  33. json_decref(MyObject);
  34. bos_free(serialized);
  35. return false;
  36. }
  37. free(boserror);
  38. json_decref(MyObject);
  39. bos_free(serialized);
  40. // stratum_recv_line_compact(&stratum);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement