@@ -43,9 +43,10 @@ status_t ta_pow(const bundle_transactions_t* bundle,
4343 iota_transaction_t * tx ;
4444 flex_trit_t * ctrunk =
4545 (flex_trit_t * )calloc (FLEX_TRIT_SIZE_243 , sizeof (flex_trit_t ));
46+ flex_trit_t tx_trits [FLEX_TRIT_SIZE_8019 ];
4647 size_t cur_idx = 0 ;
4748
48- tx = (iota_transaction_t * )utarray_front (bundle );
49+ tx = (iota_transaction_t * )utarray_back (bundle );
4950 if (tx == NULL ) {
5051 ret = SC_TA_NULL ;
5152 goto done ;
@@ -55,15 +56,14 @@ status_t ta_pow(const bundle_transactions_t* bundle,
5556
5657 do {
5758 cur_idx -- ;
58-
5959 // set trunk, branch, and attachment timestamp
6060 transaction_set_trunk (tx , ctrunk );
6161 transaction_set_branch (tx , branch );
6262 transaction_set_attachment_timestamp (tx , current_timestamp_ms ());
6363 transaction_set_attachment_timestamp_upper (tx , 3812798742493LL );
6464 transaction_set_attachment_timestamp_lower (tx , 0 );
6565
66- flex_trit_t * tx_trits = transaction_serialize (tx );
66+ transaction_serialize_on_flex_trits (tx , tx_trits );
6767 if (tx_trits == NULL ) {
6868 ret = SC_CCLIENT_INVALID_FLEX_TRITS ;
6969 goto done ;
@@ -78,9 +78,10 @@ status_t ta_pow(const bundle_transactions_t* bundle,
7878 transaction_set_nonce (tx , nonce );
7979
8080 free (ctrunk );
81+ transaction_serialize_on_flex_trits (tx , tx_trits );
8182 ctrunk = iota_flex_digest (tx_trits , NUM_TRITS_SERIALIZED_TRANSACTION );
83+ tx = (iota_transaction_t * )utarray_prev (bundle , tx );
8284 free (nonce );
83- free (tx_trits );
8485 } while (cur_idx != 0 );
8586
8687done :
0 commit comments