Skip to content
This repository has been archived by the owner on Mar 23, 2021. It is now read-only.

Commit

Permalink
Create storage submodule http_api
Browse files Browse the repository at this point in the history
Currently in the storage module we have a lot of qualified paths. We
can reduce the noise considerable by observing that the qualified
paths are all because of the load/save `http_api` types.

Create a submodule `http_api` of the storage module and confine to it
all of the load/save implementations for types defined in the main
`http_api` module.
  • Loading branch information
tcharding committed Jun 9, 2020
1 parent 26947e4 commit fa89866
Show file tree
Hide file tree
Showing 3 changed files with 528 additions and 799 deletions.
23 changes: 22 additions & 1 deletion cnd/src/db/tables.rs
@@ -1,5 +1,5 @@
use crate::{
bitcoin,
asset, bitcoin,
db::{
schema::{address_book, halights, hbits, herc20s, secret_hashes, swaps},
wrapper_types::{
Expand Down Expand Up @@ -146,6 +146,15 @@ impl IntoInsertable for herc20::CreatedSwap {
}
}

impl From<Herc20> for asset::Erc20 {
fn from(herc20: Herc20) -> asset::Erc20 {
asset::Erc20 {
quantity: herc20.amount.0.into(),
token_contract: herc20.token_contract.0.into(),
}
}
}

#[derive(Associations, Clone, Debug, Identifiable, Queryable, PartialEq)]
#[belongs_to(Swap)]
#[table_name = "halights"]
Expand Down Expand Up @@ -201,6 +210,12 @@ impl IntoInsertable for halight::CreatedSwap {
}
}

impl From<Halight> for asset::Bitcoin {
fn from(halight: Halight) -> Self {
halight.amount.0.into()
}
}

#[derive(Associations, Clone, Debug, Identifiable, Queryable, PartialEq)]
#[belongs_to(Swap)]
#[table_name = "hbits"]
Expand Down Expand Up @@ -244,6 +259,12 @@ impl IntoInsertable for hbit::CreatedSwap {
}
}

impl From<Hbit> for asset::Bitcoin {
fn from(hbit: Hbit) -> Self {
hbit.amount.0.into()
}
}

impl Insert<InsertableHerc20> for Sqlite {
fn insert(
&self,
Expand Down

0 comments on commit fa89866

Please sign in to comment.