Skip to content

Commit

Permalink
funding: setup wallet actor
Browse files Browse the repository at this point in the history
  • Loading branch information
doitian committed Apr 29, 2024
1 parent 343a975 commit 003c13d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
mod config;
pub use config::Config;

pub mod wallet;

pub mod ldk;
pub use ldk::{start_ldk, LdkConfig};
pub mod ckb;
Expand Down
11 changes: 11 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use log::{debug, error, info};
use ractor::Actor;
use tentacle::multiaddr::Multiaddr;
use tokio::sync::mpsc;
use tokio::{select, signal};
Expand All @@ -11,6 +12,7 @@ use ckb_pcn_node::ckb::{NetworkActorCommand, NetworkActorMessage};
use ckb_pcn_node::tasks::{
cancel_tasks_and_wait_for_completion, new_tokio_cancellation_token, new_tokio_task_tracker,
};
use ckb_pcn_node::wallet::WalletActor;
use ckb_pcn_node::{start_cch, start_ckb, start_ldk, start_rpc, Config};

#[tokio::main]
Expand All @@ -29,6 +31,15 @@ pub async fn main() {
let token = new_tokio_cancellation_token();
let root_actor = RootActor::start(tracker, token).await;

let (_wallet_actor, _wallet_handle) = Actor::spawn_linked(
Some("wallet actor".to_string()),
WalletActor {},
(),
root_actor.get_cell(),
)
.await
.expect("start wallet actor");

let ckb_command_sender = match config.ckb {
Some(ckb_config) => {
const CHANNEL_SIZE: usize = 4000;
Expand Down
25 changes: 25 additions & 0 deletions src/wallet/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use ractor::{Actor, ActorProcessingErr, ActorRef};

pub struct WalletActor;

#[derive(Clone, Debug)]
pub struct WalletState;

#[derive(Clone, Debug)]
pub struct WalletMessage;

#[ractor::async_trait]
impl Actor for WalletActor {
type Msg = WalletMessage;
type State = WalletState;
type Arguments = ();

async fn pre_start(
&self,
_myself: ActorRef<Self::Msg>,
_: (),
) -> Result<Self::State, ActorProcessingErr> {
log::debug!("start wallet actor");
Ok(WalletState)
}
}

0 comments on commit 003c13d

Please sign in to comment.