Skip to content
Snippets Groups Projects
Commit ce0cb755 authored by Éloïs's avatar Éloïs
Browse files

feat(dbs): add col currency_params in db BcV2

parent ef8d2557
No related branches found
No related tags found
No related merge requests found
Pipeline #12437 passed
...@@ -19,6 +19,7 @@ db_schema!( ...@@ -19,6 +19,7 @@ db_schema!(
BcV2, BcV2,
[ [
["blocks_meta", BlocksMeta, U32BE, BlockMetaV2], ["blocks_meta", BlocksMeta, U32BE, BlockMetaV2],
["currency_params", CurrencyParams, (), CurrencyParamsDbV2],
["identities", Identities, PubKeyKeyV2, IdtyDbV2], ["identities", Identities, PubKeyKeyV2, IdtyDbV2],
["txs_hashs", TxsHashs, HashKeyV2, ()], ["txs_hashs", TxsHashs, HashKeyV2, ()],
["uds", Uds, UdIdV2, ()], ["uds", Uds, UdIdV2, ()],
......
...@@ -71,6 +71,7 @@ pub use values::block_head_db::BlockHeadDbV1; ...@@ -71,6 +71,7 @@ pub use values::block_head_db::BlockHeadDbV1;
pub use values::block_meta::BlockMetaV2; pub use values::block_meta::BlockMetaV2;
pub use values::block_number_array_db::BlockNumberArrayV1; pub use values::block_number_array_db::BlockNumberArrayV1;
pub use values::cindex_db::CIndexDbV1; pub use values::cindex_db::CIndexDbV1;
pub use values::currency_params::CurrencyParamsDbV2;
pub use values::dunp_head::DunpHeadDbV1; pub use values::dunp_head::DunpHeadDbV1;
pub use values::idty_db::IdtyDbV2; pub use values::idty_db::IdtyDbV2;
pub use values::iindex_db::IIndexDbV1; pub use values::iindex_db::IIndexDbV1;
...@@ -97,6 +98,7 @@ pub(crate) use dubp::common::crypto::bases::BaseConversionError; ...@@ -97,6 +98,7 @@ pub(crate) use dubp::common::crypto::bases::BaseConversionError;
pub(crate) use dubp::common::crypto::hashs::Hash; pub(crate) use dubp::common::crypto::hashs::Hash;
pub(crate) use dubp::common::crypto::keys::ed25519::{PublicKey, Signature}; pub(crate) use dubp::common::crypto::keys::ed25519::{PublicKey, Signature};
pub(crate) use dubp::common::crypto::keys::{PublicKey as _, Signature as _}; pub(crate) use dubp::common::crypto::keys::{PublicKey as _, Signature as _};
pub(crate) use dubp::common::currency_params::CurrencyParameters;
pub(crate) use dubp::common::prelude::*; pub(crate) use dubp::common::prelude::*;
pub(crate) use dubp::documents::dubp_wallet::prelude::*; pub(crate) use dubp::documents::dubp_wallet::prelude::*;
pub(crate) use kv_typed::db_schema; pub(crate) use kv_typed::db_schema;
......
...@@ -18,6 +18,7 @@ pub mod block_head_db; ...@@ -18,6 +18,7 @@ pub mod block_head_db;
pub mod block_meta; pub mod block_meta;
pub mod block_number_array_db; pub mod block_number_array_db;
pub mod cindex_db; pub mod cindex_db;
pub mod currency_params;
pub mod dunp_head; pub mod dunp_head;
pub mod idty_db; pub mod idty_db;
pub mod iindex_db; pub mod iindex_db;
......
// Copyright (C) 2020 Éloïs SANCHEZ.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use crate::*;
#[derive(Clone, Copy, Debug, Default, Deserialize, PartialEq, Serialize)]
pub struct CurrencyParamsDbV2(pub CurrencyParameters);
impl AsBytes for CurrencyParamsDbV2 {
fn as_bytes<T, F: FnMut(&[u8]) -> T>(&self, mut f: F) -> T {
f(&bincode_db()
.serialize(&self)
.unwrap_or_else(|_| unreachable!()))
}
}
impl kv_typed::prelude::FromBytes for CurrencyParamsDbV2 {
type Err = bincode::Error;
fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> {
bincode_db().deserialize(bytes)
}
}
impl ToDumpString for CurrencyParamsDbV2 {
fn to_dump_string(&self) -> String {
todo!()
}
}
#[cfg(feature = "explorer")]
impl ExplorableValue for CurrencyParamsDbV2 {
fn from_explorer_str(source: &str) -> Result<Self, FromExplorerValueErr> {
serde_json::from_str(source).map_err(|e| FromExplorerValueErr(e.into()))
}
fn to_explorer_json(&self) -> KvResult<serde_json::Value> {
serde_json::to_value(&self).map_err(|e| KvError::DeserError(e.into()))
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment