This commit is contained in:
MoneroOcean
2019-03-31 11:33:21 -07:00
parent 46c038018b
commit 429077e4c7

View File

@@ -245,7 +245,7 @@ NAN_METHOD(get_merged_mining_nonce_size) {
info.GetReturnValue().Set(returnValue);
}
NAN_METHOD(contruct_mm_child_block_blob) { // (shareBuffer, blob_type, childBlockTemplate)
NAN_METHOD(construct_mm_child_block_blob) { // (shareBuffer, blob_type, childBlockTemplate)
if (info.Length() < 3) return THROW_ERROR_EXCEPTION("You must provide three arguments (shareBuffer, blob_type, block2).");
Local<Object> block_template_buf = info[0]->ToObject();
@@ -263,21 +263,21 @@ NAN_METHOD(contruct_mm_child_block_blob) { // (shareBuffer, blob_type, childBloc
block b = AUTO_VAL_INIT(b);
b.set_blob_type(blob_type);
if (!parse_and_validate_block_from_blob(block_template_blob, b)) return THROW_ERROR_EXCEPTION("contruct_mm_child_block_blob: Failed to parse parent block");
if (!parse_and_validate_block_from_blob(block_template_blob, b)) return THROW_ERROR_EXCEPTION("construct_mm_child_block_blob: Failed to parse parent block");
block b2 = AUTO_VAL_INIT(b2);
b2.set_blob_type(BLOB_TYPE_FORKNOTE2);
if (!parse_and_validate_block_from_blob(child_block_template_blob, b2)) return THROW_ERROR_EXCEPTION("contruct_mm_child_block_blob: Failed to parse child block");
if (!parse_and_validate_block_from_blob(child_block_template_blob, b2)) return THROW_ERROR_EXCEPTION("construct_mm_child_block_blob: Failed to parse child block");
if (!mergeBlocks(b, b2, std::vector<crypto::hash>())) return THROW_ERROR_EXCEPTION("contruct_mm_child_block_blob: Failed to postprocess mining block");
if (!mergeBlocks(b, b2, std::vector<crypto::hash>())) return THROW_ERROR_EXCEPTION("construct_mm_child_block_blob: Failed to postprocess mining block");
if (!block_to_blob(b2, output)) return THROW_ERROR_EXCEPTION("contruct_mm_child_block_blob: Failed to convert child block to blob");
if (!block_to_blob(b2, output)) return THROW_ERROR_EXCEPTION("construct_mm_child_block_blob: Failed to convert child block to blob");
v8::Local<v8::Value> returnValue = Nan::CopyBuffer((char*)output.data(), output.size()).ToLocalChecked();
info.GetReturnValue().Set(returnValue);
}
NAN_METHOD(contruct_mm_parent_block_blob) { // (shareBuffer, blob_type, childBlockTemplate)
NAN_METHOD(construct_mm_parent_block_blob) { // (shareBuffer, blob_type, childBlockTemplate)
if (info.Length() < 3) return THROW_ERROR_EXCEPTION("You must provide three arguments (parentBlock, blob_type, childBlock).");
Local<Object> target = info[0]->ToObject();
@@ -294,16 +294,16 @@ NAN_METHOD(contruct_mm_parent_block_blob) { // (shareBuffer, blob_type, childBlo
block b = AUTO_VAL_INIT(b);
b.set_blob_type(blob_type);
if (!parse_and_validate_block_from_blob(input, b)) return THROW_ERROR_EXCEPTION("contruct_mm_parent_block_blob: Failed to parse prent block");
if (!parse_and_validate_block_from_blob(input, b)) return THROW_ERROR_EXCEPTION("construct_mm_parent_block_blob: Failed to parse prent block");
block b2 = AUTO_VAL_INIT(b2);
b2.set_blob_type(BLOB_TYPE_FORKNOTE2);
if (!parse_and_validate_block_from_blob(child_input, b2)) return THROW_ERROR_EXCEPTION("contruct_mm_parent_block_blob: Failed to parse child block");
if (!parse_and_validate_block_from_blob(child_input, b2)) return THROW_ERROR_EXCEPTION("construct_mm_parent_block_blob: Failed to parse child block");
if (!fillExtraMM(b, b2)) return THROW_ERROR_EXCEPTION("contruct_mm_parent_block_blob: Failed to add merged mining tag to parent block extra");
if (!fillExtraMM(b, b2)) return THROW_ERROR_EXCEPTION("construct_mm_parent_block_blob: Failed to add merged mining tag to parent block extra");
blobdata output = "";
if (!block_to_blob(b, output)) return THROW_ERROR_EXCEPTION("contruct_mm_parent_block_blob: Failed to convert parent block to blob");
if (!block_to_blob(b, output)) return THROW_ERROR_EXCEPTION("construct_mm_parent_block_blob: Failed to convert parent block to blob");
v8::Local<v8::Value> returnValue = Nan::CopyBuffer((char*)output.data(), output.size()).ToLocalChecked();
info.GetReturnValue().Set(returnValue);
@@ -316,9 +316,9 @@ NAN_MODULE_INIT(init) {
Nan::Set(target, Nan::New("address_decode").ToLocalChecked(), Nan::GetFunction(Nan::New<FunctionTemplate>(address_decode)).ToLocalChecked());
Nan::Set(target, Nan::New("address_decode_integrated").ToLocalChecked(), Nan::GetFunction(Nan::New<FunctionTemplate>(address_decode_integrated)).ToLocalChecked());
Nan::Set(target, Nan::New("contruct_mm_child_block_blob").ToLocalChecked(), Nan::GetFunction(Nan::New<FunctionTemplate>(contruct_mm_child_block_blob)).ToLocalChecked());
Nan::Set(target, Nan::New("get_merged_mining_nonce_size").ToLocalChecked(), Nan::GetFunction(Nan::New<FunctionTemplate>(get_merged_mining_nonce_size)).ToLocalChecked());
Nan::Set(target, Nan::New("contruct_mm_parent_block_blob").ToLocalChecked(), Nan::GetFunction(Nan::New<FunctionTemplate>(contruct_mm_parent_block_blob)).ToLocalChecked());
Nan::Set(target, Nan::New("construct_mm_child_block_blob").ToLocalChecked(), Nan::GetFunction(Nan::New<FunctionTemplate>(construct_mm_child_block_blob)).ToLocalChecked());
Nan::Set(target, Nan::New("construct_mm_parent_block_blob").ToLocalChecked(), Nan::GetFunction(Nan::New<FunctionTemplate>(construct_mm_parent_block_blob)).ToLocalChecked());
}
NODE_MODULE(cryptoforknote, init)