Skip to content

Commit 246d25a

Browse files
committed
refactory store services, small tidy
1 parent 22d7f4c commit 246d25a

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

crates/chaincash_store/src/ergo_boxes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ impl TryFrom<&NetworkBox> for NewErgoBox {
3232
}
3333
}
3434

35-
pub struct ErgoBoxService {
35+
pub struct ErgoBoxRepository {
3636
pool: ConnectionPool,
3737
}
3838

39-
impl ErgoBoxService {
39+
impl ErgoBoxRepository {
4040
pub(crate) fn new(pool: ConnectionPool) -> Self {
4141
Self { pool }
4242
}

crates/chaincash_store/src/lib.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ pub mod schema;
77
use diesel::r2d2::{ConnectionManager, Pool};
88
use diesel::SqliteConnection;
99
use diesel_migrations::{embed_migrations, EmbeddedMigrations, MigrationHarness};
10-
use ergo_boxes::ErgoBoxService;
10+
use ergo_boxes::ErgoBoxRepository;
1111
pub use error::Error;
12-
use notes::NoteService;
13-
use reserves::ReserveService;
12+
use notes::NoteRepository;
13+
use reserves::ReserveRepository;
1414
use std::borrow::BorrowMut;
1515

1616
#[derive(serde::Deserialize, Debug)]
@@ -34,7 +34,7 @@ pub struct ChainCashStore {
3434

3535
impl ChainCashStore {
3636
pub fn open<S: Into<String>>(store_url: S) -> Result<Self, Error> {
37-
let manager = ConnectionManager::<SqliteConnection>::new(store_url);
37+
let manager = ConnectionManager::<ConnectionType>::new(store_url);
3838

3939
Ok(Self {
4040
pool: Pool::builder().build(manager)?,
@@ -45,16 +45,16 @@ impl ChainCashStore {
4545
Self::open(":memory:")
4646
}
4747

48-
pub fn notes(&self) -> NoteService {
49-
NoteService::new(self.pool.clone())
48+
pub fn notes(&self) -> NoteRepository {
49+
NoteRepository::new(self.pool.clone())
5050
}
5151

52-
pub fn reserves(&self) -> ReserveService {
53-
ReserveService::new(self.pool.clone())
52+
pub fn reserves(&self) -> ReserveRepository {
53+
ReserveRepository::new(self.pool.clone())
5454
}
5555

56-
pub fn ergo_boxes(&self) -> ErgoBoxService {
57-
ErgoBoxService::new(self.pool.clone())
56+
pub fn ergo_boxes(&self) -> ErgoBoxRepository {
57+
ErgoBoxRepository::new(self.pool.clone())
5858
}
5959
}
6060

crates/chaincash_store/src/notes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ use crate::ConnectionPool;
22

33
pub struct Note {}
44

5-
pub struct NoteService {
5+
pub struct NoteRepository {
66
pool: ConnectionPool,
77
}
88

9-
impl NoteService {
9+
impl NoteRepository {
1010
pub(crate) fn new(pool: ConnectionPool) -> Self {
1111
Self { pool }
1212
}

crates/chaincash_store/src/reserves.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::ergo_boxes::ErgoBoxService;
1+
use crate::ergo_boxes::ErgoBoxRepository;
22
use crate::schema;
33
use crate::ConnectionPool;
44
use crate::Error;
@@ -22,11 +22,11 @@ pub struct NewReserve<'a> {
2222
pub owner: &'a str,
2323
}
2424

25-
pub struct ReserveService {
25+
pub struct ReserveRepository {
2626
pool: ConnectionPool,
2727
}
2828

29-
impl ReserveService {
29+
impl ReserveRepository {
3030
pub(crate) fn new(pool: ConnectionPool) -> Self {
3131
Self { pool }
3232
}
@@ -35,7 +35,7 @@ impl ReserveService {
3535
let reserve_spec = ReserveBoxSpec::try_from(ergo_box)?;
3636
let mut conn = self.pool.get()?;
3737
let created_box =
38-
ErgoBoxService::create_with_conn(conn.borrow_mut(), ergo_box.try_into()?)?;
38+
ErgoBoxRepository::create_with_conn(conn.borrow_mut(), ergo_box.try_into()?)?;
3939
let new_reserve = NewReserve {
4040
box_id: created_box.id,
4141
owner: &reserve_spec.owner.to_string(),

0 commit comments

Comments
 (0)