Top to bottom pub mod then mod then pub use then use (incl. use crate and use self)

This commit is contained in:
Daniel Karzel 2021-01-21 17:09:53 +11:00
parent 44c4b5dcea
commit 433704e48c
14 changed files with 38 additions and 33 deletions

View File

@ -20,7 +20,6 @@
//! every BLOCK_TIME_SECS seconds.
//!
//! Also provides standalone JSON RPC clients for monerod and monero-wallet-rpc.
pub mod image;
pub mod rpc;

View File

@ -1,7 +1,15 @@
pub mod timelocks;
pub mod transactions;
pub mod wallet;
pub use crate::bitcoin::{
timelocks::Timelock,
transactions::{TxCancel, TxLock, TxPunish, TxRedeem, TxRefund},
};
pub use ::bitcoin::{util::amount::Amount, Address, Network, Transaction, Txid};
pub use ecdsa_fun::{adaptor::EncryptedSignature, fun::Scalar, Signature};
pub use wallet::Wallet;
use crate::{bitcoin::timelocks::BlockHeight, config::Config, ExpiredTimelocks};
use ::bitcoin::{
hashes::{hex::ToHex, Hash},
@ -9,21 +17,14 @@ use ::bitcoin::{
util::psbt::PartiallySignedTransaction,
SigHash,
};
pub use ::bitcoin::{util::amount::Amount, Address, Network, Transaction, Txid};
use anyhow::{anyhow, bail, Result};
use async_trait::async_trait;
use ecdsa_fun::{adaptor::Adaptor, fun::Point, nonce::Deterministic, ECDSA};
pub use ecdsa_fun::{adaptor::EncryptedSignature, fun::Scalar, Signature};
use miniscript::{Descriptor, Segwitv0};
use rand::{CryptoRng, RngCore};
use serde::{Deserialize, Serialize};
use sha2::Sha256;
use std::str::FromStr;
pub use wallet::Wallet;
pub mod timelocks;
pub mod transactions;
pub mod wallet;
// TODO: Configurable tx-fee (note: parties have to agree prior to swapping)
// Current reasoning:

View File

@ -1,4 +1,5 @@
pub mod seed;
use crate::bitcoin::Timelock;
use conquer_once::Lazy;
use std::time::Duration;

View File

@ -1,3 +1,6 @@
pub use alice::Alice;
pub use bob::Bob;
use anyhow::{anyhow, bail, Context, Result};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use std::{fmt::Display, path::Path};
@ -5,8 +8,6 @@ use uuid::Uuid;
mod alice;
mod bob;
pub use alice::Alice;
pub use bob::Bob;
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
pub enum Swap {

View File

@ -16,19 +16,20 @@
missing_copy_implementations
)]
use serde::{Deserialize, Serialize};
use std::fmt::{self, Display};
pub mod bitcoin;
pub mod config;
pub mod database;
mod fs;
pub mod monero;
pub mod network;
pub mod protocol;
pub mod seed;
pub mod trace;
mod fs;
use serde::{Deserialize, Serialize};
use std::fmt::{self, Display};
pub type Never = std::convert::Infallible;
/// XMR/BTC swap amounts.

View File

@ -12,6 +12,7 @@
)]
#![forbid(unsafe_code)]
#![allow(non_snake_case)]
use crate::cli::{Command, Options, Resume};
use anyhow::{Context, Result};
use prettytable::{row, Table};

View File

@ -1,11 +1,13 @@
pub mod wallet;
pub use ::monero::{Network, PrivateKey, PublicKey};
pub use curve25519_dalek::scalar::Scalar;
pub use wallet::Wallet;
use crate::bitcoin;
use ::bitcoin::hashes::core::fmt::Formatter;
pub use ::monero::{Network, PrivateKey, PublicKey};
use anyhow::Result;
use async_trait::async_trait;
pub use curve25519_dalek::scalar::Scalar;
use rand::{CryptoRng, RngCore};
use rust_decimal::{
prelude::{FromPrimitive, ToPrimitive},
@ -17,7 +19,6 @@ use std::{
ops::{Add, Mul, Sub},
str::FromStr,
};
pub use wallet::Wallet;
pub const PICONERO_OFFSET: u64 = 1_000_000_000_000;

View File

@ -1,3 +1,7 @@
pub mod peer_tracker;
pub mod request_response;
pub mod transport;
use crate::seed::SEED_LENGTH;
use bitcoin::hashes::{sha256, Hash, HashEngine};
use futures::prelude::*;
@ -5,10 +9,6 @@ use libp2p::{core::Executor, identity::ed25519};
use std::pin::Pin;
use tokio::runtime::Handle;
pub mod peer_tracker;
pub mod request_response;
pub mod transport;
#[allow(missing_debug_implementations)]
pub struct TokioExecutor {
pub handle: Handle,

View File

@ -1,8 +1,8 @@
pub mod testutils;
use swap::protocol::{alice, bob};
use tokio::join;
pub mod testutils;
/// Run the following tests with RUST_MIN_STACK=10000000
#[tokio::test]

View File

@ -1,7 +1,7 @@
use swap::protocol::{alice, alice::AliceState, bob};
pub mod testutils;
use swap::protocol::{alice, alice::AliceState, bob};
#[tokio::test]
async fn given_alice_restarts_after_encsig_is_learned_resume_swap() {
testutils::setup_test(|mut ctx| async move {

View File

@ -1,7 +1,7 @@
use swap::protocol::{alice, bob, bob::BobState};
pub mod testutils;
use swap::protocol::{alice, bob, bob::BobState};
#[tokio::test]
async fn given_bob_restarts_after_encsig_is_sent_resume_swap() {
testutils::setup_test(|mut ctx| async move {

View File

@ -1,10 +1,10 @@
pub mod testutils;
use swap::protocol::{
alice, bob,
bob::{swap::is_xmr_locked, BobState},
};
pub mod testutils;
#[tokio::test]
async fn given_bob_restarts_after_xmr_is_locked_resume_swap() {
testutils::setup_test(|mut ctx| async move {

View File

@ -1,10 +1,10 @@
pub mod testutils;
use swap::protocol::{
alice, bob,
bob::{swap::is_btc_locked, BobState},
};
pub mod testutils;
/// Bob locks Btc and Alice locks Xmr. Bob does not act; he fails to send Alice
/// the encsig and fail to refund or redeem. Alice punishes.
#[tokio::test]

View File

@ -1,7 +1,7 @@
use swap::protocol::{alice, alice::AliceState, bob};
pub mod testutils;
use swap::protocol::{alice, alice::AliceState, bob};
/// Bob locks btc and Alice locks xmr. Alice fails to act so Bob refunds. Alice
/// then also refunds.
#[tokio::test]