Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

Commit

Permalink
common/helpers: fix pow bundle (#831)
Browse files Browse the repository at this point in the history
  • Loading branch information
thibault-martinez authored Feb 19, 2019
1 parent b64e707 commit e63422b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions common/helpers/pow.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ IOTA_EXPORT retcode_t iota_pow_bundle(bundle_transactions_t *const bundle,
flex_trit_t const *const trunk,
flex_trit_t const *const branch,
uint8_t const mwm) {
flex_trit_t txflex[FLEX_TRIT_SIZE_8019];
iota_transaction_t *tx = NULL;
flex_trit_t *nonce = NULL;
flex_trit_t *txflex = NULL;
flex_trit_t *ctrunk = NULL;
size_t cur_idx = 0;

Expand Down Expand Up @@ -124,9 +124,7 @@ IOTA_EXPORT retcode_t iota_pow_bundle(bundle_transactions_t *const bundle,
transaction_set_attachment_timestamp_lower(tx, 0);
transaction_set_attachment_timestamp_upper(tx, 3812798742493LL);

if ((txflex = transaction_serialize(tx)) == NULL) {
return RC_OOM;
}
transaction_serialize_on_flex_trits(tx, txflex);

// Do PoW
if ((nonce = iota_pow_flex(txflex, NUM_TRITS_SERIALIZED_TRANSACTION,
Expand All @@ -140,11 +138,13 @@ IOTA_EXPORT retcode_t iota_pow_bundle(bundle_transactions_t *const bundle,
free(ctrunk);
}

transaction_serialize_on_flex_trits(tx, txflex);

if ((ctrunk = iota_flex_digest(txflex, NUM_TRITS_SERIALIZED_TRANSACTION)) ==
NULL) {
return RC_OOM;
}
free(txflex);

} while (cur_idx != 0);

if (ctrunk != trunk) {
Expand Down

0 comments on commit e63422b

Please sign in to comment.