global externs refactor, some tcp methods

This commit is contained in:
2026-05-14 17:36:40 +02:00
parent 1e9fc9b024
commit 361ac73e45
9 changed files with 228 additions and 41 deletions

View File

@@ -36,6 +36,7 @@ void Block_AddTransaction(block_t* block, signed_transaction_t* tx);
void Block_RemoveTransaction(block_t* block, uint8_t* txHash);
bool Block_HasValidProofOfWork(const block_t* block);
bool Block_AllTransactionsValid(const block_t* block);
bool Block_IsFullyValid(const block_t* block);
void Block_ShutdownPowContext(void);
void Block_Destroy(block_t* block);
void Block_Print(const block_t* block);

View File

@@ -7,7 +7,7 @@
#include <block/chain.h>
#include <block/block.h>
extern uint64_t currentBlockHeight;
#include <runtime_state.h>
// Nets
#define MAX_CONS 32 // Some baseline for now
@@ -56,11 +56,8 @@ extern uint64_t currentBlockHeight;
static const uint64_t M_CAP = 18446744073709551615ULL; // Max uint64
static const uint64_t TAIL_EMISSION = 750000000000ULL; // 0.75 coins per block floor
static uint64_t currentReward = 750000000000ULL; // Epoch reward cache for phase 3
// No max supply. Instead of halving, it'll follow a more gradual, Monero-like emission curve.
static uint256_t currentSupply = {{0, 0, 0, 0}}; // Global variable to track total supply; updated with each block mined
// Phase 3: update once per effective epoch and keep a fixed per-block reward for that epoch.
static inline uint64_t GetInflationRateReward(uint256_t currentSupply, blockchain_t* chain) {
if (!chain || !chain->blocks) { return 0x00; } // Invalid

View File

@@ -15,6 +15,10 @@
#include <dynarr.h>
#include <block/block.h>
#include <block/chain.h>
#include <block/transaction.h>
typedef struct {
tcp_server_t* server;
tcp_client_t outboundClients[MAX_CONS];

17
include/runtime_state.h Normal file
View File

@@ -0,0 +1,17 @@
#ifndef RUNTIME_STATE_H
#define RUNTIME_STATE_H
#include <stdint.h>
#include <uint256.h>
#include <block/chain.h>
extern uint64_t currentBlockHeight;
extern blockchain_t* currentChain;
extern uint256_t currentSupply;
extern uint64_t currentReward;
extern uint32_t difficultyTarget;
extern const char* chainDataDir;
#endif