Remove the hand-rolled ad-hoc DynArr and DynSet, replace with dlibc vector_t and set_t
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user