//! 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, ContractApiServer, MiningApiServer, NetworkApiServer, SubscriptionApiServer,
    TransactionApiServer, UtxoApiServer,
};
pub use pool::{
    global_pool, init_global_pool, ConnectionPool, ConnectionPoolExt, PoolConfig, PoolError,
    PoolStats, PoolStatsSnapshot, PooledHttpClient, PooledHttpClientGuard, PooledWsClient,
    PooledWsClientGuard,
};
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]
    #[allow(clippy::assertions_on_constants)]
    fn test_constants() {
        assert!(DEFAULT_RPC_PORT > 0);
        assert!(MAX_BATCH_SIZE > 0);
    }
}
