Skip to content

Commit 44f666d

Browse files
committed
plugins(lsps2): simplify actor and session manager
Merge BlockheightProvider into Lsps2PolicyProvider, extract check_cltv_timeout helper in the session FSM, flatten recovery branching in SessionManager, simplify the actor loop with convert_input and tokio::select!, and remove the unused CollectTimeout ActorInput variant.
1 parent 39b2b98 commit 44f666d

8 files changed

Lines changed: 252 additions & 315 deletions

File tree

plugins/lsps-plugin/src/cln_adapters/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ pub mod state;
55
pub mod types;
66

77
pub use rpc::{
8-
ClnActionExecutor, ClnBlockheight, ClnDatastore, ClnPolicyProvider, ClnRecoveryProvider,
8+
ClnActionExecutor, ClnDatastore, ClnPolicyProvider, ClnRecoveryProvider,
99
ClnRpcClient,
1010
};

plugins/lsps-plugin/src/cln_adapters/rpc.rs

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::{
22
core::lsps2::{
33
actor::ActionExecutor,
44
provider::{
5-
Blockheight, BlockheightProvider, ChannelRecoveryInfo, DatastoreProvider,
5+
ChannelRecoveryInfo, DatastoreProvider,
66
ForwardActivity, Lsps2PolicyProvider, RecoveryProvider,
77
},
88
},
@@ -661,23 +661,23 @@ impl DatastoreProvider for ClnDatastore {
661661
}
662662

663663
// ---------------------------------------------------------------------------
664-
// ClnBlockheight — implements BlockheightProvider
664+
// ClnPolicyProvider — implements Lsps2PolicyProvider
665665
// ---------------------------------------------------------------------------
666666

667667
#[derive(Clone)]
668-
pub struct ClnBlockheight {
668+
pub struct ClnPolicyProvider {
669669
rpc: ClnRpcClient,
670670
}
671671

672-
impl ClnBlockheight {
672+
impl ClnPolicyProvider {
673673
pub fn new(rpc: ClnRpcClient) -> Self {
674674
Self { rpc }
675675
}
676676
}
677677

678678
#[async_trait]
679-
impl BlockheightProvider for ClnBlockheight {
680-
async fn get_blockheight(&self) -> Result<Blockheight> {
679+
impl Lsps2PolicyProvider for ClnPolicyProvider {
680+
async fn get_blockheight(&self) -> Result<u32> {
681681
let mut rpc = self.rpc.create_rpc().await?;
682682
let info = rpc
683683
.call_typed(&GetinfoRequest {})
@@ -686,25 +686,7 @@ impl BlockheightProvider for ClnBlockheight {
686686
.with_context(|| "calling getinfo")?;
687687
Ok(info.blockheight)
688688
}
689-
}
690-
691-
// ---------------------------------------------------------------------------
692-
// ClnPolicyProvider — implements Lsps2PolicyProvider
693-
// ---------------------------------------------------------------------------
694-
695-
#[derive(Clone)]
696-
pub struct ClnPolicyProvider {
697-
rpc: ClnRpcClient,
698-
}
699-
700-
impl ClnPolicyProvider {
701-
pub fn new(rpc: ClnRpcClient) -> Self {
702-
Self { rpc }
703-
}
704-
}
705689

706-
#[async_trait]
707-
impl Lsps2PolicyProvider for ClnPolicyProvider {
708690
async fn get_info(
709691
&self,
710692
request: &Lsps2PolicyGetInfoRequest,

0 commit comments

Comments
 (0)