Skip to content
Permalink
Browse files

Separate the library and binary roots

  • Loading branch information...
ArtemGr committed Mar 23, 2019
1 parent f4f495f commit d013a7810fc0d032d372708e8d09ab6cb341b0ed
@@ -8,11 +8,12 @@ edition = "2018"

[[bin]]
name = "mm2"
path = "mm2src/mm2.rs"
path = "mm2src/mm2_bin.rs"

[lib]
name = "mm2"
path = "mm2src/mm2.rs"
path = "mm2src/mm2_lib.rs"
crate-type = ["staticlib"]

[profile.dev]
# Enable light optimizations. We want a debuggable version but not a completely dumb one.
@@ -73,7 +73,6 @@ use hyper::header::{ HeaderValue, CONTENT_TYPE };
use hyper::rt::Stream;
use hyper_rustls::HttpsConnector;
use libc::{c_char, c_void, malloc, free};
use secp256k1::*;
use serde_json::{self as json, Value as Json};
use std::env::args;
use std::fmt;
@@ -114,8 +113,6 @@ pub fn sat_to_f(sat: u64) -> f64 { sat as f64 / SATOSHIS as f64 }
/// Created by `void *bitcoin_ctx()`.
pub enum BitcoinCtx {}

pub struct BtcCtxBox(*mut BitcoinCtx);

extern "C" {
pub fn bitcoin_ctx() -> *mut BitcoinCtx;
fn bitcoin_ctx_destroy (ctx: *mut BitcoinCtx);
@@ -106,8 +106,8 @@ fn test_crash_handling() {
assert! (stderr.contains ("Signal caught!"));
}

assert! (stderr.contains ("] mm2::crash_reports::access_violation"));
assert! (stderr.contains ("] mm2::crash_reports::call_access_violation"));
assert! (stderr.contains ("] mm2::mm2::crash_reports::access_violation"));
assert! (stderr.contains ("] mm2::mm2::crash_reports::call_access_violation"));
} else {
log! ("test_crash_handling] Hi from the child.");
init_crash_reports();
@@ -55,9 +55,9 @@ use std::sync::atomic::{AtomicBool, Ordering};
use std::thread::{self, sleep};
use std::time::Duration;

use crate::lp_network::{lp_command_q_loop, lp_queue_command};
use crate::lp_ordermatch::{lp_trade_command, lp_trades_loop};
use crate::rpc::{self, SINGLE_THREADED_C_LOCK};
use crate::mm2::lp_network::{lp_command_q_loop, lp_queue_command};
use crate::mm2::lp_ordermatch::{lp_trade_command, lp_trades_loop};
use crate::mm2::rpc::{self, SINGLE_THREADED_C_LOCK};

/*
#include <stdio.h>
@@ -29,9 +29,9 @@ use std::fmt;
use std::ptr::null_mut;
use std::time::Duration;

use crate::lp_native_dex::lp_command_process;
use crate::lp_swap::save_stats_swap_status;
use crate::rpc::{dispatcher, DispatcherRes};
use crate::mm2::lp_native_dex::lp_command_process;
use crate::mm2::lp_swap::save_stats_swap_status;
use crate::mm2::rpc::{dispatcher, DispatcherRes};

/*
struct psock
@@ -34,8 +34,8 @@ use std::sync::{Arc, Mutex};
use std::time::Duration;
use std::thread;

use crate::lp_network::lp_queue_command;
use crate::lp_swap::{MakerSwap, run_maker_swap, TakerSwap, run_taker_swap};
use crate::mm2::lp_network::lp_queue_command;
use crate::mm2::lp_swap::{MakerSwap, run_maker_swap, TakerSwap, run_taker_swap};

/// Temporary kludge, improving readability of the not-yet-fully-ported code. Should be removed eventually.
macro_rules! c2s {($cs: expr) => {unwrap!(CStr::from_ptr($cs.as_ptr()).to_str())}}
@@ -55,7 +55,7 @@
// marketmaker
//
use bitcrypto::dhash160;
use btc_rpc::v1::types::{H160 as H160Json, H256 as H256Json, H264 as H264Json};
use rpc::v1::types::{H160 as H160Json, H256 as H256Json, H264 as H264Json};
use coins::{MmCoinEnum, TransactionDetails};
use common::{bits256, dstr, HyRes, rpc_response, Timeout, swap_db_dir, str_to_malloc, lp};
use common::log::{TagParam};
@@ -19,20 +19,6 @@
// Copyright © 2017-2018 SuperNET. All rights reserved.
//

#![feature(non_ascii_idents)]

extern crate rpc as btc_rpc;
#[macro_use] extern crate common;
#[allow(unused_imports)]
#[macro_use] extern crate duct;
#[macro_use] extern crate fomat_macros;
#[macro_use] extern crate gstuff;
#[macro_use] extern crate lazy_static;
#[macro_use] extern crate serde_json;
#[macro_use] extern crate serde_derive;
#[macro_use] extern crate serialization_derive;
#[macro_use] extern crate unwrap;

use common::{bitcoin_priv2wif, lp, os, BitcoinCtx, CJSON, MM_VERSION};
use common::lp::{_bits256 as bits256};
use common::mm_ctx::MmCtx;
@@ -55,6 +41,7 @@ use std::str::from_utf8_unchecked;
use std::slice::from_raw_parts;
use std::str;

#[path = "crash_reports.rs"]
pub mod crash_reports;
use self::crash_reports::init_crash_reports;

@@ -183,7 +170,7 @@ fn help() {
)
}

fn main() {
pub fn mm2_main() {
init_crash_reports();
unsafe {os::OS_init()};
log!({"BarterDEX MarketMaker {}", MM_VERSION});
@@ -0,0 +1,19 @@
#![feature(non_ascii_idents)]

#[macro_use] extern crate common;
#[allow(unused_imports)]
#[macro_use] extern crate duct;
#[macro_use] extern crate fomat_macros;
#[macro_use] extern crate gstuff;
#[macro_use] extern crate lazy_static;
#[macro_use] extern crate serde_json;
#[macro_use] extern crate serde_derive;
#[macro_use] extern crate serialization_derive;
#[macro_use] extern crate unwrap;

#[path = "mm2.rs"]
mod mm2;

fn main() {
mm2::mm2_main()
}
@@ -0,0 +1,20 @@
#![feature(non_ascii_idents)]

#[macro_use] extern crate common;
#[allow(unused_imports)]
#[macro_use] extern crate duct;
#[macro_use] extern crate fomat_macros;
#[macro_use] extern crate gstuff;
#[macro_use] extern crate lazy_static;
#[macro_use] extern crate serde_json;
#[macro_use] extern crate serde_derive;
#[macro_use] extern crate serialization_derive;
#[macro_use] extern crate unwrap;

#[path = "mm2.rs"]
mod mm2;

#[no_mangle]
pub extern fn mm2_main() {
mm2::mm2_main()
}
@@ -44,10 +44,10 @@ use std::sync::Mutex;
use tokio_core::net::TcpListener;
use hex;

use crate::lp_network::lp_queue_command;
use crate::lp_ordermatch::{buy, sell};
use crate::lp_swap::{my_swap_status, stats_swap_status};
use crate::CJSON;
use crate::mm2::lp_network::lp_queue_command;
use crate::mm2::lp_ordermatch::{buy, sell};
use crate::mm2::lp_swap::{my_swap_status, stats_swap_status};
use crate::mm2::CJSON;

mod lp_commands;
use self::lp_commands::*;
@@ -31,7 +31,7 @@ use std::mem::zeroed;
use std::ptr::null_mut;
use std::time::Duration;

use crate::lp_native_dex::lp_passphrase_init;
use crate::mm2::lp_native_dex::lp_passphrase_init;

/*
char *LP_numutxos()

0 comments on commit d013a78

Please sign in to comment.
You can’t perform that action at this time.