Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deps: Bump to core 0.5.1 #655

Merged
merged 2 commits into from
Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ configure_me = { version = "0.4", optional = true }
dotenv = { version = "0.15", optional = true }
electrum-client = "0.10.0"
env_logger = "0.7"
farcaster_core = "0.5"
farcaster_core = "0.5.1"
uuid = { version = "1.1", features = ["v4", "serde"]}
hex = "^0.4.3"
internet2 = "0.8.3"
lazy_static = "1.4"
Expand Down Expand Up @@ -98,7 +99,7 @@ tonic = "0.7.2"
zmq = { package = "zmq2", version = "0.5.0" }

[build-dependencies]
farcaster_core = "0.5"
farcaster_core = "0.5.1"
anyhow = "1"
serde_yaml = { version = "0.8", optional = true }
toml = { version = "0.5", optional = true }
Expand Down
2 changes: 2 additions & 0 deletions src/cli/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use std::{
time::Duration,
};
use std::{str::FromStr, thread::sleep};
use uuid::Uuid;

use internet2::addr::{InetSocketAddr, NodeAddr};
use microservices::shell::Exec;
Expand Down Expand Up @@ -168,6 +169,7 @@ impl Exec for Command {
return Ok(());
}
let offer = Offer {
uuid: Uuid::new_v4(),
network,
arbitrating_blockchain,
accordant_blockchain,
Expand Down
4 changes: 2 additions & 2 deletions src/databased/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,8 +701,8 @@ fn test_lmdb_state() {
let addrs = database.get_all_monero_addresses().unwrap();
assert!(addrs.contains(&addr.to_string()));

let offer_1 = PublicOffer::from_str("Offer:Cke4ftrP5A71LQM2fvVdFMNR4gmBqNCsR11111uMFuZTAsNgpdK8DiK11111TB9zym113GTvtvqfD1111114A4TUGURtskxM3BUGLBGAdFDhJQVMQmiPUsL5vSTKhyBKw3Lh11111111111111111111111111111111111111111AfZ113XRBuStRU5H").unwrap();
let offer_2 = PublicOffer::from_str("Offer:Cke4ftrP5A71LQM2fvVdFMNR4grq1wi1D11111uMFuZTAsNgpdK8DiK11111TB9zym113GTvtvqfD1111114A4TUGURtskxM3BUGLBGAdFDhJQVMQmiPUsL5vSTKhyBKw3Lh11111111111111111111111111111111111111111AfZ113W5EEpvY61v").unwrap();
let offer_1 = PublicOffer::from_str("Offer:Cke4ftrP5A7MgLMaQZLZUMTC6TfkqUKBu1LQM2fvVdFMNR4gmBqNCsR11111uMFuZTAsNgpdK8DiK11111TB9zym113GTvtvqfD1111114A4TTF4h53Tv4MR6eS9sdDxV5JCH9xZcKejCqKShnphqndeeD11111111111111111111111111111111111111111AfZ113XRBtrLeA3t").unwrap();
let offer_2 = PublicOffer::from_str("Offer:Cke4ftrP5A7Km9Kmc2UDBePio1p7wM56P1LQM2fvVdFMNR4gmBqNCsR11111uMFuZTAsNgpdK8DiK11111TB9zym113GTvtvqfD1111114A4TTF4h53Tv4MR6eS9sdDxV5JCH9xZcKejCqKShnphqndeeD11111111111111111111111111111111111111111AfZ113XRBuLWyw3M").unwrap();

database
.set_offer_status(&offer_1, &OfferStatus::Open)
Expand Down
12 changes: 6 additions & 6 deletions src/farcasterd/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ use std::{
};
use std::{convert::TryFrom, thread::sleep};
use std::{convert::TryInto, ffi::OsStr};
use uuid::Uuid;

use bitcoin::{
hashes::hex::ToHex,
Expand All @@ -67,7 +68,6 @@ use microservices::esb::{self, Handler};

use farcaster_core::{
blockchain::{Blockchain, Network},
negotiation::{OfferId, PublicOfferId},
swap::SwapId,
};

Expand Down Expand Up @@ -155,7 +155,7 @@ pub fn run(

pub struct Runtime {
identity: ServiceId,
listens: HashMap<OfferId, InetSocketAddr>,
listens: HashMap<Uuid, InetSocketAddr>,
started: SystemTime,
connections: HashSet<NodeAddr>,
report_peerd_reconnect: HashMap<NodeAddr, ServiceId>,
Expand All @@ -165,11 +165,11 @@ pub struct Runtime {
taking_swaps: HashMap<ServiceId, (request::InitSwap, Network)>,
pending_swap_init: HashMap<(ServiceId, ServiceId), Vec<(Request, SwapId)>>,
public_offers: HashSet<PublicOffer>,
arb_addrs: HashMap<PublicOfferId, bitcoin::Address>,
acc_addrs: HashMap<PublicOfferId, monero::Address>,
arb_addrs: HashMap<Uuid, bitcoin::Address>,
acc_addrs: HashMap<Uuid, monero::Address>,
consumed_offers: HashMap<PublicOffer, (SwapId, ServiceId)>,
node_ids: HashMap<OfferId, NodeId>, // Only populated by maker. TODO is it possible? HashMap<SwapId, PublicKey>
peerd_ids: HashMap<OfferId, ServiceId>, // Only populated by maker.
node_ids: HashMap<Uuid, NodeId>, // Only populated by maker. TODO is it possible? HashMap<SwapId, PublicKey>
peerd_ids: HashMap<Uuid, ServiceId>, // Only populated by maker.
wallet_token: Token,
pending_requests: HashMap<request::RequestId, (Request, ServiceId)>,
pending_sweep_requests: HashMap<ServiceId, Request>, // TODO: merge this with pending requests eventually
Expand Down
26 changes: 20 additions & 6 deletions src/rpc/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ use crate::{
},
};
use amplify::{Holder, ToYamlString, Wrapper};
use farcaster_core::{
consensus::{Decodable as CoreDecodable, Encodable as CoreEncodable},
negotiation::PublicOfferId,
};
use farcaster_core::consensus::{Decodable as CoreDecodable, Encodable as CoreEncodable};
use internet2::{CreateUnmarshaller, Payload, Unmarshall, Unmarshaller};
use lazy_static::lazy_static;
use monero::consensus::{Decodable as MoneroDecodable, Encodable as MoneroEncodable};
Expand All @@ -46,6 +43,7 @@ use std::{
};
use std::{iter::FromIterator, str::FromStr};
use std::{num::ParseIntError, time::Duration};
use uuid::Uuid;

use bitcoin::{
secp256k1::{
Expand Down Expand Up @@ -1023,18 +1021,34 @@ pub struct OfferInfo {
}

#[cfg_attr(feature = "serde", serde_as)]
#[derive(Clone, PartialEq, Eq, Debug, Display, StrictEncode, StrictDecode)]
#[derive(Clone, PartialEq, Eq, Debug, Display)]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize),
serde(crate = "serde_crate")
)]
#[display(TookOffer::to_yaml_string)]
pub struct TookOffer {
pub offerid: PublicOfferId,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, as mentioned in farcaster-project/farcaster-core#292, we can use [u8; 16] to avoid manual impl. of encoding. (But with manual From/Into calls in code when we want Uuid types)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TookOffer is printed as a yaml string, so I want to preserve the Uuid type. I am not sure how a impl From would help here.

pub offerid: Uuid,
pub message: String,
}

impl StrictEncode for TookOffer {
fn strict_encode<W: std::io::Write>(&self, mut w: W) -> Result<usize, strict_encoding::Error> {
let mut len = self.offerid.to_bytes_le().strict_encode(&mut w)?;
len += self.message.strict_encode(&mut w)?;
Ok(len)
}
}

impl StrictDecode for TookOffer {
fn strict_decode<R: std::io::Read>(mut r: R) -> Result<Self, strict_encoding::Error> {
let offerid = Uuid::from_bytes_le(<[u8; 16]>::strict_decode(&mut r)?);
let message = String::strict_decode(&mut r)?;
Ok(TookOffer { offerid, message })
}
}

#[cfg_attr(feature = "serde", serde_as)]
#[derive(Clone, PartialEq, Eq, Debug, Display, Default, StrictEncode, StrictDecode)]
#[cfg_attr(
Expand Down