ido incomplete c02

This commit is contained in:
Hossein Zoda 2026-04-25 20:15:15 +03:00
parent ce9dba23cf
commit 0629e168c3
6 changed files with 698 additions and 273 deletions

View file

@ -51,3 +51,9 @@ name = "moria_read_slots"
type = "u32" type = "u32"
doc = "Number of read connection pool slots for the Moria lending database (default: 8)" doc = "Number of read connection pool slots for the Moria lending database (default: 8)"
default = "8" default = "8"
[[param]]
name = "ido_read_slots"
type = "u32"
doc = "Number of read connection pool slots for the Moria lending database (default: 8)"
default = "8"

File diff suppressed because it is too large Load diff

View file

@ -18,6 +18,7 @@ use crate::db::cauldron::tokentoken::create_table as tokentoken_prepare_tables;
use crate::db::crc20::prepare_tables as crc20_prepare_tables; use crate::db::crc20::prepare_tables as crc20_prepare_tables;
use crate::db::moria::prepare_tables as moria_prepare_tables; use crate::db::moria::prepare_tables as moria_prepare_tables;
use crate::db::oracle::prepare_tables as oracle_prepare_tables; use crate::db::oracle::prepare_tables as oracle_prepare_tables;
use crate::db::ido::prepare_tables as ido_prepare_tables;
/// Create read and write database pools for a given database path /// Create read and write database pools for a given database path
async fn create_db_pool(db_path: &str, read_max_size: u32) -> (bool, SqlitePool, SqlitePool) { async fn create_db_pool(db_path: &str, read_max_size: u32) -> (bool, SqlitePool, SqlitePool) {
@ -89,6 +90,7 @@ pub struct ReadSlots {
pub crc20: u32, pub crc20: u32,
pub oracle: u32, pub oracle: u32,
pub moria: u32, pub moria: u32,
pub ido: u32,
} }
/// Initialize all databases and return a DB struct /// Initialize all databases and return a DB struct
@ -135,6 +137,15 @@ pub async fn initialize_databases(network: &str, read_slots: ReadSlots) -> Resul
moria_prepare_tables(&moria_db_write).await; moria_prepare_tables(&moria_db_write).await;
} }
// Initialize ido database
let (db_exists, ido_db_write, ido_db_read) =
create_db_pool(&db_path(db_dir, "ido.db"), read_slots.ido).await;
if !db_exists {
cauldron_prepare_tables(&ido_db_write).await;
} else {
check_db_version(&ido_db_read).await?;
}
Ok(DB { Ok(DB {
cauldron_w: cauldron_db_write, cauldron_w: cauldron_db_write,
cauldron_r: cauldron_db_read, cauldron_r: cauldron_db_read,
@ -146,5 +157,7 @@ pub async fn initialize_databases(network: &str, read_slots: ReadSlots) -> Resul
oracle_r: oracle_db_read, oracle_r: oracle_db_read,
moria_w: moria_db_write, moria_w: moria_db_write,
moria_r: moria_db_read, moria_r: moria_db_read,
ido_r: ido_db_read,
ido_w: ido_db_write,
}) })
} }

View file

@ -35,4 +35,7 @@ pub struct DB {
// moria lending protocol // moria lending protocol
pub moria_w: SqlitePool, pub moria_w: SqlitePool,
pub moria_r: SqlitePool, pub moria_r: SqlitePool,
// ido
pub ido_w: SqlitePool,
pub ido_r: SqlitePool,
} }

View file

@ -449,6 +449,7 @@ pub async fn index_blocks(
&sorted_txs, &sorted_txs,
&blockhash, &blockhash,
mtp as i64, mtp as i64,
block_height as i64,
) )
.await?; .await?;

View file

@ -169,6 +169,7 @@ async fn start_program(
crc20: config.crc20_read_slots, crc20: config.crc20_read_slots,
oracle: config.oracle_read_slots, oracle: config.oracle_read_slots,
moria: config.moria_read_slots, moria: config.moria_read_slots,
ido: config.ido_read_slots,
}, },
) )
.await?; .await?;