Remove the hand-rolled ad-hoc DynArr and DynSet, replace with dlibc vector_t and set_t

This commit is contained in:
2026-09-15 14:30:29 +02:00
parent f40ffaa6f7
commit 099433b9df
16 changed files with 2355 additions and 628 deletions
+2 -2
View File
@@ -3,7 +3,7 @@
#include <stdint.h>
#include <openssl/sha.h>
#include <dynarr.h>
#include <dlibc/vector.h>
#include <block/transaction.h>
#include <stdbool.h>
#include <string.h>
@@ -27,7 +27,7 @@ typedef struct {
typedef struct {
block_header_t header;
DynArr* transactions; // Array of signed_transaction_t, NOTE: Potentially move to a hashmap at some point for quick lookups.
vector_t* transactions; // Vector of signed_transaction_t, NOTE: Potentially move to a hashmap at some point for quick lookups.
} block_t;
// PoW validity is chain-relative: it needs the epoch DAG size and seed. chain.h includes this
+4 -2
View File
@@ -2,7 +2,7 @@
#define CHAIN_H
#include <block/block.h>
#include <dynarr.h>
#include <dlibc/vector.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
@@ -21,7 +21,9 @@ typedef struct {
// Tagged so block.h can forward-declare it: PoW validity depends on the chain (it needs the epoch
// seed), but chain.h includes block.h, so the tag is what breaks the cycle.
typedef struct blockchain {
DynArr* blocks;
// Vector of block_t, stored by value. Each element owns its `transactions` vector, which the
// element destructor frees whenever a block leaves the chain (rollback, clear, destroy).
vector_t* blocks;
size_t size;
/**