A complete blockchain implementation featuring: - synord: Full node with GHOSTDAG consensus - explorer-web: Modern React blockchain explorer with 3D DAG visualization - CLI wallet and tools - Smart contract SDK and example contracts (DEX, NFT, token) - WASM crypto library for browser/mobile
89 lines
4.1 KiB
Rust
89 lines
4.1 KiB
Rust
//! JSON-RPC API for Synor blockchain node.
|
|
//!
|
|
//! Provides HTTP and WebSocket endpoints for:
|
|
//! - Block and transaction queries
|
|
//! - UTXO management
|
|
//! - Mining operations
|
|
//! - Network information
|
|
//! - Smart contract interaction
|
|
//!
|
|
//! # Architecture
|
|
//!
|
|
//! ```text
|
|
//! ┌─────────────────────────────────────────────────────────────────┐
|
|
//! │ RPC SERVER │
|
|
//! ├─────────────────────────────────────────────────────────────────┤
|
|
//! │ │
|
|
//! │ ┌──────────────┐ ┌──────────────┐ ┌──────────────────────┐ │
|
|
//! │ │ HTTP │ │ WebSocket │ │ Methods │ │
|
|
//! │ │ Server │ │ Server │ │ (JSON-RPC 2.0) │ │
|
|
//! │ └──────┬───────┘ └──────┬───────┘ └──────────┬───────────┘ │
|
|
//! │ │ │ │ │
|
|
//! │ └─────────────────┼──────────────────────┘ │
|
|
//! │ │ │
|
|
//! │ ┌────────────────────────▼─────────────────────────────────┐ │
|
|
//! │ │ API Handlers │ │
|
|
//! │ ├───────────┬───────────┬───────────┬───────────┬──────────┤ │
|
|
//! │ │ Blocks │ Txns │ Mining │ Network │ Contracts│ │
|
|
//! │ └───────────┴───────────┴───────────┴───────────┴──────────┘ │
|
|
//! │ │
|
|
//! └─────────────────────────────────────────────────────────────────┘
|
|
//! ```
|
|
|
|
#![allow(dead_code)]
|
|
|
|
pub mod api;
|
|
pub mod pool;
|
|
pub mod server;
|
|
pub mod types;
|
|
|
|
pub use api::{
|
|
BlockApiServer, MiningApiServer, NetworkApiServer, TransactionApiServer, UtxoApiServer,
|
|
ContractApiServer, SubscriptionApiServer,
|
|
};
|
|
pub use pool::{
|
|
ConnectionPool, ConnectionPoolExt, PoolConfig, PoolError, PoolStats, PoolStatsSnapshot,
|
|
PooledHttpClient, PooledHttpClientGuard, PooledWsClient, PooledWsClientGuard,
|
|
global_pool, init_global_pool,
|
|
};
|
|
pub use server::{RpcConfig, RpcServer};
|
|
pub use types::*;
|
|
|
|
/// Default RPC port.
|
|
pub const DEFAULT_RPC_PORT: u16 = 16110;
|
|
|
|
/// Default WebSocket port.
|
|
pub const DEFAULT_WS_PORT: u16 = 16111;
|
|
|
|
/// Maximum batch request size.
|
|
pub const MAX_BATCH_SIZE: usize = 100;
|
|
|
|
/// Maximum response size (10 MB).
|
|
pub const MAX_RESPONSE_SIZE: usize = 10 * 1024 * 1024;
|
|
|
|
/// RPC method namespaces.
|
|
pub mod namespaces {
|
|
/// Block-related methods.
|
|
pub const BLOCK: &str = "synor";
|
|
/// Transaction methods.
|
|
pub const TX: &str = "synor";
|
|
/// UTXO methods.
|
|
pub const UTXO: &str = "synor";
|
|
/// Mining methods.
|
|
pub const MINING: &str = "synor";
|
|
/// Network methods.
|
|
pub const NET: &str = "net";
|
|
/// Contract methods.
|
|
pub const CONTRACT: &str = "contract";
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn test_constants() {
|
|
assert!(DEFAULT_RPC_PORT > 0);
|
|
assert!(MAX_BATCH_SIZE > 0);
|
|
}
|
|
}
|