Browse Source

Rename `insert_cfd` to `insert_cfd_and_send_to_feed`

`insert_cfd` gives the wrong impression, this function does more than that and the name should show it.
new-http-api
Daniel Karzel 3 years ago
parent
commit
9ed32000ab
No known key found for this signature in database GPG Key ID: 30C3FC2E438ADB6E
  1. 2
      daemon/src/cfd_actors.rs
  2. 4
      daemon/src/db.rs
  3. 4
      daemon/src/maker_cfd.rs
  4. 4
      daemon/src/taker_cfd.rs

2
daemon/src/cfd_actors.rs

@ -6,7 +6,7 @@ use sqlx::pool::PoolConnection;
use sqlx::Sqlite;
use tokio::sync::watch;
pub async fn insert_cfd(
pub async fn insert_cfd_and_send_to_feed(
cfd: &Cfd,
conn: &mut PoolConnection<Sqlite>,
update_sender: &watch::Sender<Vec<Cfd>>,

4
daemon/src/db.rs

@ -569,7 +569,7 @@ mod tests {
let cfd_1 = Cfd::dummy();
db::insert_order(&cfd_1.order, &mut conn).await.unwrap();
cfd_actors::insert_cfd(&cfd_1, &mut conn, &cfd_feed_sender)
cfd_actors::insert_cfd_and_send_to_feed(&cfd_1, &mut conn, &cfd_feed_sender)
.await
.unwrap();
@ -577,7 +577,7 @@ mod tests {
let cfd_2 = Cfd::dummy();
db::insert_order(&cfd_2.order, &mut conn).await.unwrap();
cfd_actors::insert_cfd(&cfd_2, &mut conn, &cfd_feed_sender)
cfd_actors::insert_cfd_and_send_to_feed(&cfd_2, &mut conn, &cfd_feed_sender)
.await
.unwrap();
assert_eq!(cfd_feed_receiver.borrow().clone(), vec![cfd_1, cfd_2]);

4
daemon/src/maker_cfd.rs

@ -1,4 +1,4 @@
use crate::cfd_actors::{self, append_cfd_state, insert_cfd};
use crate::cfd_actors::{self, append_cfd_state, insert_cfd_and_send_to_feed};
use crate::db::{insert_order, load_cfd_by_order_id, load_order_by_id};
use crate::maker_inc_connections::TakerCommand;
use crate::model::cfd::{
@ -453,7 +453,7 @@ where
taker_id,
},
);
insert_cfd(&cfd, &mut conn, &self.cfd_feed_actor_inbox).await?;
insert_cfd_and_send_to_feed(&cfd, &mut conn, &self.cfd_feed_actor_inbox).await?;
// 3. check if order has acceptable amounts
if quantity < current_order.min_quantity || quantity > current_order.max_quantity {

4
daemon/src/taker_cfd.rs

@ -1,4 +1,4 @@
use crate::cfd_actors::{self, append_cfd_state, insert_cfd};
use crate::cfd_actors::{self, append_cfd_state, insert_cfd_and_send_to_feed};
use crate::db::{insert_order, load_cfd_by_order_id, load_order_by_id};
use crate::model::cfd::{
Cfd, CfdState, CfdStateChangeEvent, CfdStateCommon, CollaborativeSettlement, Dlc, Order,
@ -157,7 +157,7 @@ impl<O, M, W> Actor<O, M, W> {
CfdState::outgoing_order_request(),
);
insert_cfd(&cfd, &mut conn, &self.cfd_feed_actor_inbox).await?;
insert_cfd_and_send_to_feed(&cfd, &mut conn, &self.cfd_feed_actor_inbox).await?;
// Cleanup own order feed, after inserting the cfd.
// Due to the 1:1 relationship between order and cfd we can never create another cfd for the

Loading…
Cancel
Save