mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
darkfid: Fix compilation.
This commit is contained in:
@@ -5,7 +5,6 @@ use async_std::sync::{Arc, Mutex};
|
||||
use async_trait::async_trait;
|
||||
use easy_parallel::Parallel;
|
||||
use futures_lite::future;
|
||||
use lazy_init::Lazy;
|
||||
use log::{error, info};
|
||||
use serde_derive::Deserialize;
|
||||
use simplelog::{ColorChoice, TermLogger, TerminalMode};
|
||||
@@ -14,9 +13,7 @@ use structopt_toml::StructOptToml;
|
||||
use url::Url;
|
||||
|
||||
use darkfi::{
|
||||
async_daemonize,
|
||||
blockchain::{NullifierStore, RootStore},
|
||||
cli_desc,
|
||||
async_daemonize, cli_desc,
|
||||
consensus::{
|
||||
proto::{
|
||||
ProtocolParticipant, ProtocolProposal, ProtocolSync, ProtocolSyncConsensus, ProtocolTx,
|
||||
@@ -30,7 +27,7 @@ use darkfi::{
|
||||
crypto::token_list::{DrkTokenList, TokenList},
|
||||
net,
|
||||
net::P2pPtr,
|
||||
node::{Client, State},
|
||||
node::Client,
|
||||
rpc::{
|
||||
jsonrpc,
|
||||
jsonrpc::{
|
||||
@@ -44,7 +41,7 @@ use darkfi::{
|
||||
expand_path,
|
||||
path::get_config_path,
|
||||
},
|
||||
wallet::walletdb::{init_wallet, WalletPtr},
|
||||
wallet::walletdb::init_wallet,
|
||||
Error, Result,
|
||||
};
|
||||
|
||||
@@ -137,11 +134,10 @@ struct Args {
|
||||
|
||||
pub struct Darkfid {
|
||||
synced: Mutex<bool>, // AtomicBool is weird in Arc
|
||||
client: Client,
|
||||
consensus_p2p: Option<P2pPtr>,
|
||||
sync_p2p: Option<P2pPtr>,
|
||||
client: Arc<Client>,
|
||||
validator_state: ValidatorStatePtr,
|
||||
state: Arc<Mutex<State>>,
|
||||
drk_tokenlist: DrkTokenList,
|
||||
btc_tokenlist: TokenList,
|
||||
eth_tokenlist: TokenList,
|
||||
@@ -180,8 +176,6 @@ impl RequestHandler for Darkfid {
|
||||
|
||||
impl Darkfid {
|
||||
pub async fn new(
|
||||
db: &sled::Db,
|
||||
wallet: WalletPtr,
|
||||
validator_state: ValidatorStatePtr,
|
||||
consensus_p2p: Option<P2pPtr>,
|
||||
sync_p2p: Option<P2pPtr>,
|
||||
@@ -195,30 +189,14 @@ impl Darkfid {
|
||||
TokenList::new(include_bytes!("../../../contrib/token/solana_token_list.min.json"))?;
|
||||
let drk_tokenlist = DrkTokenList::new(&sol_tokenlist, ð_tokenlist, &btc_tokenlist)?;
|
||||
|
||||
// Initialize Client
|
||||
let client = Client::new(wallet).await?;
|
||||
let tree = client.get_tree().await?;
|
||||
let merkle_roots = RootStore::new(db)?;
|
||||
let nullifiers = NullifierStore::new(db)?;
|
||||
|
||||
// Initialize State
|
||||
let state = Arc::new(Mutex::new(State {
|
||||
tree,
|
||||
merkle_roots,
|
||||
nullifiers,
|
||||
cashier_pubkeys: vec![],
|
||||
faucet_pubkeys: vec![],
|
||||
mint_vk: Lazy::new(),
|
||||
burn_vk: Lazy::new(),
|
||||
}));
|
||||
let client = validator_state.read().await.client.clone();
|
||||
|
||||
Ok(Self {
|
||||
synced: Mutex::new(false),
|
||||
client,
|
||||
consensus_p2p,
|
||||
sync_p2p,
|
||||
client,
|
||||
validator_state,
|
||||
state,
|
||||
drk_tokenlist,
|
||||
btc_tokenlist,
|
||||
eth_tokenlist,
|
||||
@@ -258,11 +236,12 @@ async fn realmain(args: Args, ex: Arc<Executor<'_>>) -> Result<()> {
|
||||
};
|
||||
|
||||
// TODO: sqldb init cleanup
|
||||
Client::new(wallet.clone()).await?;
|
||||
let address = wallet.get_default_address().await?;
|
||||
// Initialize Client
|
||||
let client = Arc::new(Client::new(wallet).await?);
|
||||
|
||||
// Initialize validator state
|
||||
let state = ValidatorState::new(&sled_db, address, genesis_ts, genesis_data)?;
|
||||
let state =
|
||||
ValidatorState::new(&sled_db, genesis_ts, genesis_data, client, vec![], vec![]).await?;
|
||||
|
||||
let sync_p2p = {
|
||||
info!("Registering block sync P2P protocols...");
|
||||
@@ -357,9 +336,7 @@ async fn realmain(args: Args, ex: Arc<Executor<'_>>) -> Result<()> {
|
||||
};
|
||||
|
||||
// Initialize program state
|
||||
let darkfid =
|
||||
Darkfid::new(&sled_db, wallet, state.clone(), consensus_p2p.clone(), sync_p2p.clone())
|
||||
.await?;
|
||||
let darkfid = Darkfid::new(state.clone(), consensus_p2p.clone(), sync_p2p.clone()).await?;
|
||||
let darkfid = Arc::new(darkfid);
|
||||
|
||||
// JSON-RPC server
|
||||
|
||||
@@ -115,7 +115,7 @@ pub struct ValidatorState {
|
||||
/// Canonical state machine
|
||||
pub state_machine: Arc<Mutex<State>>,
|
||||
/// Client providing wallet access
|
||||
pub client: Client,
|
||||
pub client: Arc<Client>,
|
||||
/// Pending transactions
|
||||
pub unconfirmed_txs: Vec<Tx>,
|
||||
/// Participation flag
|
||||
@@ -128,7 +128,7 @@ impl ValidatorState {
|
||||
db: &sled::Db, // <-- TODO: Avoid this with some wrapping, sled should only be in blockchain
|
||||
genesis_ts: Timestamp,
|
||||
genesis_data: blake3::Hash,
|
||||
client: Client,
|
||||
client: Arc<Client>,
|
||||
cashier_pubkeys: Vec<PublicKey>,
|
||||
faucet_pubkeys: Vec<PublicKey>,
|
||||
) -> Result<ValidatorStatePtr> {
|
||||
|
||||
Reference in New Issue
Block a user