Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
Signed-off-by: borngraced <[email protected]>
  • Loading branch information
borngraced committed Jun 1, 2023
1 parent 2906e80 commit 48596c8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
6 changes: 4 additions & 2 deletions mm2src/coins/z_coin/storage/blockdb/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ cfg_native!(
pub enum BlockDbError {
#[cfg(not(target_arch = "wasm32"))]
SqliteError(SqliteClientError),
#[cfg(target_arch = "wasm32")]
IndexedDBError(String),
CorruptedData(String),
}
Expand Down Expand Up @@ -169,14 +170,15 @@ cfg_wasm32!(
db: ConstructibleDb::new(&ctx).into_shared(),
ticker,
})
}
}

#[allow(unused)]
async fn lock_db(&self) -> BlockDbRes<BlockDbInnerLocked<'_>> {
self.db
.get_or_initialize()
.await
.mm_err(|err| BlockDbError::IndexedDBError(err.to_string()))
}
}

pub fn get_latest_block(&self) -> Result<u32, BlockDbError> { todo!() }

Expand Down
6 changes: 2 additions & 4 deletions mm2src/coins/z_coin/storage/walletdb/wallet_idb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,11 @@ impl WalletDbBlocksTable {
/// A **unique** index that consists of the following properties:
/// * ticker
/// * height
/// * txid
pub const TICKER_HEIGHT_INDEX: &str = "ticker_height_index";
/// A **unique** index that consists of the following properties:
/// * ticker
/// * hash
/// * txid
pub const HASH_TICKER_INDEX: &str = "ticker_hash_index";
pub const TICKER_HASH_INDEX: &str = "ticker_hash_index";
}

impl TableSignature for WalletDbBlocksTable {
Expand All @@ -62,7 +60,7 @@ impl TableSignature for WalletDbBlocksTable {
if let (0, 1) = (old_version, new_version) {
let table = upgrader.create_table(Self::table_name())?;
table.create_multi_index(Self::TICKER_HEIGHT_INDEX, &["ticker", "height"], true)?;
table.create_multi_index(Self::HASH_TICKER_INDEX, &["ticker", "hash"], true)?;
table.create_multi_index(Self::TICKER_HASH_INDEX, &["ticker", "hash"], true)?;
table.create_index("ticker", false)?;
}
Ok(())
Expand Down
23 changes: 12 additions & 11 deletions mm2src/coins/z_coin/z_coin_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,20 @@ pub enum UpdateBlocksCacheErr {
ZcashDBError(String),
}

cfg_native!(
impl From<tonic::Status> for UpdateBlocksCacheErr {
fn from(err: tonic::Status) -> Self { UpdateBlocksCacheErr::GrpcError(err) }
}
#[cfg(not(target_arch = "wasm32"))]
impl From<tonic::Status> for UpdateBlocksCacheErr {
fn from(err: tonic::Status) -> Self { UpdateBlocksCacheErr::GrpcError(err) }
}

impl From<SqliteError> for UpdateBlocksCacheErr {
fn from(err: SqliteError) -> Self { UpdateBlocksCacheErr::ZcashDBError(err.to_string()) }
}
#[cfg(not(target_arch = "wasm32"))]
impl From<SqliteError> for UpdateBlocksCacheErr {
fn from(err: SqliteError) -> Self { UpdateBlocksCacheErr::ZcashDBError(err.to_string()) }
}

impl From<SqliteClientError> for UpdateBlocksCacheErr {
fn from(err: SqliteClientError) -> Self { UpdateBlocksCacheErr::ZcashDBError(err.to_string()) }
}
);
#[cfg(not(target_arch = "wasm32"))]
impl From<SqliteClientError> for UpdateBlocksCacheErr {
fn from(err: SqliteClientError) -> Self { UpdateBlocksCacheErr::ZcashDBError(err.to_string()) }
}

impl From<UtxoRpcError> for UpdateBlocksCacheErr {
fn from(err: UtxoRpcError) -> Self { UpdateBlocksCacheErr::UtxoRpcError(err) }
Expand Down

0 comments on commit 48596c8

Please sign in to comment.