reorgs, fetch batching (parallel fetch), orphans
This commit is contained in:
10
include/nets/fetch_scheduler.h
Normal file
10
include/nets/fetch_scheduler.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef FETCH_SCHEDULER_H
|
||||
#define FETCH_SCHEDULER_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// Compute penalty in blocks for a delayed/heavy reorg reported by a peer.
|
||||
// Returns the number of penalty blocks to subtract from the peer's advertised work.
|
||||
uint64_t FetchScheduler_ComputeReorgPenaltyBlocks(uint64_t delayBlocks);
|
||||
|
||||
#endif
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
#include <dynarr.h>
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#include <block/block.h>
|
||||
#include <block/chain.h>
|
||||
#include <block/transaction.h>
|
||||
@@ -27,6 +29,10 @@ typedef struct {
|
||||
void (*on_data)(tcp_connection_t* conn, const unsigned char* data, size_t len, void* user);
|
||||
void (*on_disconnect)(tcp_connection_t* conn, void* user);
|
||||
void* callbackUser;
|
||||
// Maintenance thread for periodic tasks (orphan attach, pruning, metrics)
|
||||
pthread_t maintenanceThread;
|
||||
volatile int maintenanceRunning;
|
||||
int maintenanceIntervalMs;
|
||||
} net_node_t;
|
||||
|
||||
net_node_t* Node_Create();
|
||||
|
||||
20
include/nets/orphan_pool.h
Normal file
20
include/nets/orphan_pool.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef ORPHAN_POOL_H
|
||||
#define ORPHAN_POOL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <block/block.h>
|
||||
#include <block/chain.h>
|
||||
|
||||
// Initialize/destroy the global orphan pool
|
||||
void OrphanPool_Init(void);
|
||||
void OrphanPool_Destroy(void);
|
||||
|
||||
// Insert an orphan block into the pool. Ownership of `block` is transferred to the pool.
|
||||
// `height` is the block number from the header.
|
||||
void OrphanPool_Insert(block_t* block, uint64_t height);
|
||||
|
||||
// Attempt to attach any orphans whose parents now exist in `chain`.
|
||||
// Returns the number of blocks successfully attached.
|
||||
size_t OrphanPool_AttemptAttach(blockchain_t* chain);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user