Skip to content

Commit 08678b5

Browse files
committed
test errorCode lucasjones#3
1 parent 410105d commit 08678b5

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/main.cc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,11 @@ void get_block_id(const Nan::FunctionCallbackInfo<v8::Value>& info) {
139139
blobdata input = std::string(Buffer::Data(target), Buffer::Length(target));
140140
blobdata output = "";
141141

142+
int errorCode = 0;
143+
142144
block b = AUTO_VAL_INIT(b);
143-
if (!parse_and_validate_block_from_blob(input, b, b.major_version >= mergedMiningBlockVersion))
144-
return THROW_ERROR_EXCEPTION("Failed to parse block");
145+
if (!parse_and_validate_block_from_blob(input, b, b.major_version >= mergedMiningBlockVersion, &errorCode))
146+
return THROW_ERROR_EXCEPTION("Failed to parse block" + std::to_string(errorCode));
145147

146148
crypto::hash block_id;
147149
if (!get_block_hash(b, block_id, mergedMiningBlockVersion))
@@ -178,9 +180,11 @@ void construct_block_blob(const Nan::FunctionCallbackInfo<v8::Value>& info) {
178180
blobdata block_template_blob = std::string(Buffer::Data(block_template_buf), Buffer::Length(block_template_buf));
179181
blobdata output = "";
180182

183+
int errorCode = 0;
184+
181185
block b = AUTO_VAL_INIT(b);
182-
if (!parse_and_validate_block_from_blob(block_template_blob, b, b.major_version >= mergedMiningBlockVersion))
183-
return THROW_ERROR_EXCEPTION("Failed to parse block");
186+
if (!parse_and_validate_block_from_blob(block_template_blob, b, b.major_version >= mergedMiningBlockVersion, &errorCode))
187+
return THROW_ERROR_EXCEPTION("Failed to parse block" + std::to_string(errorCode));
184188

185189
b.nonce = nonce;
186190
if (b.major_version == mergedMiningBlockVersion) {

0 commit comments

Comments
 (0)