Skip to content

Commit 14a845d

Browse files
committed
refactor: share bitcoind aliases, LexeNode -> UserNode
1 parent 5176736 commit 14a845d

File tree

9 files changed

+37
-30
lines changed

9 files changed

+37
-30
lines changed

lexe-ln/src/alias.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
use crate::bitcoind::LexeBitcoind;
2+
3+
pub type WalletType = LexeBitcoind;
4+
pub type BlockSourceType = LexeBitcoind;
5+
pub type BroadcasterType = LexeBitcoind;
6+
pub type FeeEstimatorType = LexeBitcoind;

lexe-ln/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
// Enforce disallowed methods clippy lint
55
#![deny(clippy::disallowed_methods)]
66

7+
/// Type aliases.
8+
pub mod alias;
9+
/// BitcoinD client.
710
pub mod bitcoind;
11+
/// Keys manager
812
pub mod keys_manager;
13+
/// LDK + SGX compatible logger
914
pub mod logger;

node/src/cli/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use common::enclave;
77
use common::rng::SysRng;
88

99
use crate::api::LexeApiClient;
10-
use crate::init::LexeNode;
10+
use crate::init::UserNode;
1111
use crate::provision::provision;
1212

1313
/// the Lexe node CLI
@@ -27,7 +27,7 @@ impl Args {
2727
.expect("Failed to build Tokio runtime");
2828
let mut rng = SysRng::new();
2929
rt.block_on(async {
30-
let node = LexeNode::init(&mut rng, args).await?;
30+
let node = UserNode::init(&mut rng, args).await?;
3131
node.run().await
3232
})
3333
.context("Error running node")

node/src/command/test/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use common::rng::SysRng;
1414
use lexe_ln::logger;
1515

1616
use crate::command::owner;
17-
use crate::init::LexeNode;
17+
use crate::init::UserNode;
1818
use crate::lexe::channel_manager::NodeChannelManager;
1919
use crate::lexe::peer_manager::{ChannelPeer, NodePeerManager};
2020
use crate::lexe::persister::NodePersister;
@@ -84,7 +84,7 @@ fn bitcoind_exe_path() -> String {
8484

8585
struct CommandTestHarness {
8686
bitcoind: BitcoinD,
87-
node: LexeNode,
87+
node: UserNode,
8888
}
8989

9090
impl CommandTestHarness {
@@ -107,7 +107,7 @@ impl CommandTestHarness {
107107

108108
// Init node
109109
let mut rng = SysRng::new();
110-
let node = LexeNode::init(&mut rng, args)
110+
let node = UserNode::init(&mut rng, args)
111111
.await
112112
.expect("Error during init");
113113

node/src/init.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ use common::rng::Crng;
1818
use common::shutdown::ShutdownChannel;
1919
use common::task::LxTask;
2020
use futures::future;
21+
use lexe_ln::alias::{
22+
BlockSourceType, BroadcasterType, FeeEstimatorType, WalletType,
23+
};
2124
use lexe_ln::bitcoind::LexeBitcoind;
2225
use lexe_ln::keys_manager::LexeKeysManager;
2326
use lexe_ln::logger::LexeTracingLogger;
@@ -44,9 +47,8 @@ use crate::lexe::peer_manager::NodePeerManager;
4447
use crate::lexe::persister::NodePersister;
4548
use crate::lexe::sync::SyncedChainListeners;
4649
use crate::types::{
47-
ApiClientType, BlockSourceType, BroadcasterType, ChainMonitorType,
48-
ChannelMonitorType, FeeEstimatorType, InvoicePayerType, NetworkGraphType,
49-
P2PGossipSyncType, PaymentInfoStorageType, WalletType,
50+
ApiClientType, ChainMonitorType, ChannelMonitorType, InvoicePayerType,
51+
NetworkGraphType, P2PGossipSyncType, PaymentInfoStorageType,
5052
};
5153
use crate::{api, command};
5254

@@ -55,9 +57,7 @@ pub const DEFAULT_CHANNEL_SIZE: usize = 256;
5557
const P2P_RECONNECT_INTERVAL: Duration = Duration::from_secs(60);
5658
const SHUTDOWN_JOIN_TIMEOUT: Duration = Duration::from_secs(15);
5759

58-
// TODO: Remove once keys_manager, persister, invoice_payer are read in SGX
59-
#[allow(dead_code)]
60-
pub struct LexeNode {
60+
pub struct UserNode {
6161
// --- General --- //
6262
args: RunArgs,
6363
pub peer_port: Port,
@@ -70,11 +70,12 @@ pub struct LexeNode {
7070
pub persister: NodePersister,
7171
chain_monitor: Arc<ChainMonitorType>,
7272
pub network_graph: Arc<NetworkGraphType>,
73+
#[allow(dead_code)]
7374
invoice_payer: Arc<InvoicePayerType>,
7475
pub wallet: Arc<WalletType>,
7576
block_source: Arc<BlockSourceType>,
76-
fee_estimator: Arc<FeeEstimatorType>,
7777
broadcaster: Arc<BroadcasterType>,
78+
fee_estimator: Arc<FeeEstimatorType>,
7879
logger: LexeTracingLogger,
7980
inactivity_timer: InactivityTimer,
8081

@@ -84,12 +85,14 @@ pub struct LexeNode {
8485
channel_manager_blockhash: BlockHash,
8586

8687
// --- Run --- //
88+
#[allow(dead_code)]
8789
inbound_payments: PaymentInfoStorageType,
90+
#[allow(dead_code)]
8891
outbound_payments: PaymentInfoStorageType,
8992
shutdown: ShutdownChannel,
9093
}
9194

92-
impl LexeNode {
95+
impl UserNode {
9396
#[instrument(skip_all)]
9497
pub async fn init<R: Crng>(
9598
rng: &mut R,
@@ -340,8 +343,8 @@ impl LexeNode {
340343
shutdown.clone(),
341344
);
342345

343-
// Build and return the LexeNode
344-
let node = LexeNode {
346+
// Build and return the UserNode
347+
let node = UserNode {
345348
// General
346349
args,
347350
peer_port,

node/src/lexe/channel_manager/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use anyhow::{anyhow, Context};
55
use bitcoin::BlockHash;
66
use common::cli::RunArgs;
77
use common::ln::channel::LxOutPoint;
8+
use lexe_ln::alias::{BlockSourceType, BroadcasterType, FeeEstimatorType};
89
use lexe_ln::keys_manager::LexeKeysManager;
910
use lexe_ln::logger::LexeTracingLogger;
1011
use lightning::chain::chainmonitor::MonitorUpdateId;
@@ -19,10 +20,7 @@ use tracing::{debug, info};
1920

2021
use crate::lexe::peer_manager::{ChannelPeer, NodePeerManager};
2122
use crate::lexe::persister::NodePersister;
22-
use crate::types::{
23-
BlockSourceType, BroadcasterType, ChainMonitorType, ChannelManagerType,
24-
ChannelMonitorType, FeeEstimatorType,
25-
};
23+
use crate::types::{ChainMonitorType, ChannelManagerType, ChannelMonitorType};
2624

2725
/// NOTE: Important security parameter!!
2826
///

node/src/lexe/persister.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use common::enclave::Measurement;
1111
use common::ln::channel::LxOutPoint;
1212
use common::shutdown::ShutdownChannel;
1313
use common::task::LxTask;
14+
use lexe_ln::alias::{BroadcasterType, FeeEstimatorType};
1415
use lexe_ln::keys_manager::LexeKeysManager;
1516
use lexe_ln::logger::LexeTracingLogger;
1617
use lightning::chain::chainmonitor::{MonitorUpdateId, Persist};
@@ -29,9 +30,8 @@ use tracing::{debug, error};
2930
use crate::lexe::channel_manager::{LxChannelMonitorUpdate, USER_CONFIG};
3031
use crate::lexe::peer_manager::ChannelPeer;
3132
use crate::types::{
32-
ApiClientType, BroadcasterType, ChainMonitorType, ChannelManagerType,
33-
ChannelMonitorType, FeeEstimatorType, LoggerType, NetworkGraphType,
34-
ProbabilisticScorerType, SignerType,
33+
ApiClientType, ChainMonitorType, ChannelManagerType, ChannelMonitorType,
34+
LoggerType, NetworkGraphType, ProbabilisticScorerType, SignerType,
3535
};
3636

3737
// Singleton objects use SINGLETON_DIRECTORY with a fixed filename

node/src/lexe/sync.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use bitcoin::BlockHash;
77
use common::cli::Network;
88
use common::shutdown::ShutdownChannel;
99
use common::task::LxTask;
10+
use lexe_ln::alias::{BlockSourceType, BroadcasterType, FeeEstimatorType};
1011
use lexe_ln::logger::LexeTracingLogger;
1112
use lightning::chain::transaction::OutPoint;
1213
use lightning::chain::{Listen, Watch};
@@ -17,8 +18,7 @@ use tracing::{info, warn};
1718

1819
use crate::lexe::channel_manager::NodeChannelManager;
1920
use crate::types::{
20-
BlockSourceType, BroadcasterType, ChainMonitorType,
21-
ChannelMonitorListenerType, ChannelMonitorType, FeeEstimatorType,
21+
ChainMonitorType, ChannelMonitorListenerType, ChannelMonitorType,
2222
};
2323

2424
/// How often the SpvClient client polls for an updated chain tip

node/src/types/alias.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::collections::HashMap;
22
use std::sync::{Arc, Mutex};
33

4-
use lexe_ln::bitcoind::LexeBitcoind;
4+
use lexe_ln::alias::{BroadcasterType, FeeEstimatorType};
55
use lexe_ln::keys_manager::LexeKeysManager;
66
use lexe_ln::logger::LexeTracingLogger;
77
use lightning::chain::chainmonitor::ChainMonitor;
@@ -82,9 +82,4 @@ pub type NetworkGraphType = NetworkGraph<LoggerType>;
8282

8383
pub type ChainAccessType = dyn Access + Send + Sync;
8484

85-
pub type WalletType = LexeBitcoind;
86-
pub type BlockSourceType = LexeBitcoind;
87-
pub type BroadcasterType = LexeBitcoind;
88-
pub type FeeEstimatorType = LexeBitcoind;
89-
9085
pub type LoggerType = LexeTracingLogger;

0 commit comments

Comments
 (0)