BigInts, save/load, will make a calculation for block rewards soon

This commit is contained in:
2026-03-29 22:18:57 +02:00
parent 57bfe61c13
commit 0d7adc39e0
10 changed files with 456 additions and 39 deletions

View File

@@ -10,13 +10,14 @@
#include <randomx/librx_wrapper.h>
typedef struct {
uint8_t version;
uint32_t blockNumber;
uint64_t blockNumber;
uint64_t timestamp;
uint64_t nonce;
uint8_t prevHash[32];
uint8_t merkleRoot[32];
uint64_t timestamp;
uint32_t difficultyTarget; // Encoding: [1 byte exponent][3 byte coefficient]; Target = coefficient * 256^(exponent-3)
uint64_t nonce; // Higher nonce for RandomX
uint8_t version;
uint8_t reserved[3]; // 3 bytes (Explicit padding for 8-byte alignment)
} block_header_t;
typedef struct {

View File

@@ -4,6 +4,9 @@
#include <block/block.h>
#include <dynarr.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
typedef struct {
DynArr* blocks;
@@ -16,5 +19,10 @@ bool Chain_AddBlock(blockchain_t* chain, block_t* block);
block_t* Chain_GetBlock(blockchain_t* chain, size_t index);
size_t Chain_Size(blockchain_t* chain);
bool Chain_IsValid(blockchain_t* chain);
void Chain_Wipe(blockchain_t* chain);
// I/O
bool Chain_SaveToFile(blockchain_t* chain, const char* dirpath);
bool Chain_LoadFromFile(blockchain_t* chain, const char* dirpath);
#endif