diff --git a/dbs-write-ops/src/bc.rs b/dbs-write-ops/src/bc.rs index 2c4892f3a7e3281fc5c7bd5cfef93d307a926c7d..968edcf3411321cb74cef790a23d2545cc3cf04a 100644 --- a/dbs-write-ops/src/bc.rs +++ b/dbs-write-ops/src/bc.rs @@ -18,7 +18,7 @@ mod txs; mod uds; use crate::*; -use duniter_dbs::databases::bc_v2::BcV2DbWritable; +use duniter_dbs::{databases::bc_v2::BcV2DbWritable, CurrencyParamsDbV2}; pub fn apply_block<B: Backend>( bc_db: &duniter_dbs::databases::bc_v2::BcV2Db<B>, @@ -36,6 +36,7 @@ pub fn apply_block<B: Backend>( bc_db.uids_index_write(), bc_db.utxos_write(), bc_db.consumed_utxos_write(), + bc_db.currency_params_write(), ) .write( |( @@ -47,7 +48,17 @@ pub fn apply_block<B: Backend>( mut uids_index, mut utxos, mut consumed_utxos, + mut currency_params, )| { + if let Some(params) = block.currency_parameters() { + currency_params.upsert( + (), + CurrencyParamsDbV2 { + currency_name: block.currency_name(), + params, + }, + ); + } blocks_meta.upsert(U32BE(block.number().0), block_meta); identities::update_identities::<B>(&block, &mut identities)?; for idty in block.identities() { @@ -106,6 +117,7 @@ pub fn revert_block<B: Backend>( bc_db.uids_index_write(), bc_db.utxos_write(), bc_db.consumed_utxos_write(), + bc_db.currency_params_write(), ) .write( |( @@ -117,7 +129,11 @@ pub fn revert_block<B: Backend>( mut uids_index, mut utxos, mut consumed_utxos, + mut currency_params, )| { + if block.number() == BlockNumber(0) { + currency_params.remove(()); + } txs::revert_txs::<B>( block.number(), block.transactions(),