another fix since xmr hardfork version increased
parent
81f2e15516
commit
0a259628ad
32
src/main.cc
32
src/main.cc
|
@ -195,6 +195,38 @@ void construct_block_blob(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
|||
blobdata block_template_blob = std::string(Buffer::Data(block_template_buf), Buffer::Length(block_template_buf));
|
||||
blobdata output = "";
|
||||
|
||||
block b = AUTO_VAL_INIT(b);
|
||||
if (!parse_and_validate_block_from_blob(block_template_blob, b))
|
||||
return THROW_ERROR_EXCEPTION("Failed to parse block");
|
||||
|
||||
if (!block_to_blob(b, output))
|
||||
return THROW_ERROR_EXCEPTION("Failed to convert block to blob");
|
||||
|
||||
v8::Local<v8::Value> returnValue = Nan::CopyBuffer((char*)output.data(), output.size()).ToLocalChecked();
|
||||
info.GetReturnValue().Set(
|
||||
returnValue
|
||||
);
|
||||
}
|
||||
|
||||
void construct_block_blob_fa(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
||||
|
||||
if (info.Length() < 2)
|
||||
return THROW_ERROR_EXCEPTION("You must provide two arguments.");
|
||||
|
||||
Local<Object> block_template_buf = info[0]->ToObject();
|
||||
Local<Object> nonce_buf = info[1]->ToObject();
|
||||
|
||||
if (!Buffer::HasInstance(block_template_buf) || !Buffer::HasInstance(nonce_buf))
|
||||
return THROW_ERROR_EXCEPTION("Both arguments should be buffer objects.");
|
||||
|
||||
if (Buffer::Length(nonce_buf) != 4)
|
||||
return THROW_ERROR_EXCEPTION("Nonce buffer has invalid size.");
|
||||
|
||||
uint32_t nonce = *reinterpret_cast<uint32_t*>(Buffer::Data(nonce_buf));
|
||||
|
||||
blobdata block_template_blob = std::string(Buffer::Data(block_template_buf), Buffer::Length(block_template_buf));
|
||||
blobdata output = "";
|
||||
|
||||
block b = AUTO_VAL_INIT(b);
|
||||
if (!parse_and_validate_block_from_blob(block_template_blob, b))
|
||||
return THROW_ERROR_EXCEPTION("Failed to parse block");
|
||||
|
|
Loading…
Reference in New Issue