temoporarily changed DAG size for testing, fix TX loading, move some TX logic to Transaction_Init()
This commit is contained in:
@@ -52,6 +52,10 @@ block_t* Block_Create() {
|
||||
free(block);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Zero out padding
|
||||
memset(block->header.reserved, 0, sizeof(block->header.reserved));
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
|
||||
@@ -521,10 +521,18 @@ bool Chain_LoadFromFile(blockchain_t* chain, const char* dirpath, uint256_t* out
|
||||
}*/ // Transactions are not read, we use the merkle root for validity
|
||||
blk->transactions = NULL;
|
||||
|
||||
Chain_AddBlock(chain, blk);
|
||||
// Loading from disk currently restores headers only. Do not run Chain_AddBlock,
|
||||
// because it enforces transaction presence and mutates balances.
|
||||
if (!DynArr_push_back(chain->blocks, blk)) {
|
||||
fclose(chainFile);
|
||||
fclose(tableFile);
|
||||
Block_Destroy(blk);
|
||||
return false;
|
||||
}
|
||||
chain->size++;
|
||||
|
||||
// Chain_AddBlock stores blocks by value, so the copied block now owns
|
||||
// blk->transactions. Only free the temporary wrapper struct here.
|
||||
// DynArr_push_back stores blocks by value, so the copied block now owns
|
||||
// blk->transactions (NULL in header-only load mode). Free wrapper only.
|
||||
free(blk);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
#include <block/transaction.h>
|
||||
#include <string.h>
|
||||
|
||||
void Transaction_Init(signed_transaction_t* tx) {
|
||||
if (!tx) { return; }
|
||||
// Zero out everything
|
||||
memset(tx, 0, sizeof(signed_transaction_t));
|
||||
|
||||
// NOTE: Other things might be added here
|
||||
}
|
||||
|
||||
void Transaction_CalculateHash(const signed_transaction_t* tx, uint8_t* outHash) {
|
||||
if (!tx || !outHash) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user