From 56dd9795ec8e2ee053f4c8ce9e020bd1e335300d Mon Sep 17 00:00:00 2001 From: librelois <c@elo.tf> Date: Fri, 21 May 2021 01:49:57 +0200 Subject: [PATCH] fix(writer): write col currency_params --- dbs-write-ops/src/bc.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/dbs-write-ops/src/bc.rs b/dbs-write-ops/src/bc.rs index 2c4892f..968edcf 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(), -- GitLab