Skip to main content

Crate rabia_banking_example

Crate rabia_banking_example 

Source
Expand description

§Banking SMR Example

A banking ledger implementation that demonstrates how to create a complex State Machine Replication (SMR) application using the Rabia consensus protocol.

This example shows a more sophisticated SMR implementation with:

  • Account management
  • Transfer operations with validation
  • Transaction history
  • Balance tracking
  • Error handling for insufficient funds

§Example Usage

use rabia_banking_example::{BankingSMR, BankingCommand};
use rabia_core::smr::StateMachine;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut bank = BankingSMR::new();
     
    // Create accounts
    let create_cmd = BankingCommand::CreateAccount {
        account_id: "alice".to_string(),
        initial_balance: 1000,
    };
    let response = bank.apply_command(create_cmd).await;
    println!("Account created: {:?}", response);
     
    Ok(())
}

Structs§

Account
Account information
BankingResponse
Response from banking operations
BankingSMR
Banking state machine implementation
BankingState
State of the banking state machine
Transaction
Transaction record

Enums§

BankingCommand
Commands that can be applied to the banking system
BankingData
TransactionType