Node Integration Guide

Overview

Node module integrates core Network Layer (libp2p), State Management (RocksDB), RPC Server (JSON-RPC 2.0)

Architecture

┌─────────────────────────────────────────────────┐
│            axionaxNode                           │
│                                                  │
│  ┌──────────────┐  ┌──────────────┐  ┌────────┐│
│  │ NetworkManager│  │   StateDB    │  │  RPC   ││
│  │   (libp2p)   │  │  (RocksDB)   │  │ Server ││
│  └───────┬──────┘  └──────┬───────┘  └───┬────┘│
│          │                │               │     │
│          │    Sync Task   │               │     │
│          └────────────────┘               │     │
│                                           │     │
└───────────────────────────────────────────┼─────┘
                                            │
                                     JSON-RPC API
                                      (port 8545)

axionaxNode Struct

pub struct axionaxNode {
    config: NodeConfig,
    network: Arc>,
    state: Arc,
    stats: Arc>,
    rpc_handle: Option,
    sync_handle: Option>,
}

Node configuration, presets, and statistics available.

Basic Node Setup (Rust API)

use node::{axionaxNode, NodeConfig};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let mut config = NodeConfig::dev();
    config.state_path = "/tmp/axionax-node".to_string();
    config.rpc_addr = "127.0.0.1:8545".parse()?;
    let mut node = axionaxNode::new(config).await?;
    node.start().await?;
    Ok(())
}

Publishing Blocks/Transactions

// Publish block
node.state().store_block(&block)?;
node.publish_block(&block).await?;
// Publish transaction
node.publish_transaction(&tx).await?;

Querying Node State

let stats = node.stats().await;
printf!("Blocks stored: {}", stats.blocks_stored);
printf!("Peers connected: {}", node.peer_count().await);
let height = node.state().get_chain_height()?;
let latest_block = node.state().get_latest_block()?;

RPC Example

# Get block via RPC
curl -X POST http://127.0.0.1:8545 \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["latest",false],"id":1}'

Performance & Resource Usage

Error Handling

All errors returned as JSON-RPC error objects (error code, message, id).

{
  "jsonrpc": "2.0",
  "error": {
    "code": -32001,
    "message": "Block not found"
  },
  "id": 1
}

Future Enhancements

Security Considerations