Skip to content

Commit

Permalink
Create index for sorted activity
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Feb 1, 2024
1 parent 05037a6 commit 3548c9f
Show file tree
Hide file tree
Showing 7 changed files with 485 additions and 85 deletions.
14 changes: 11 additions & 3 deletions mutiny-core/src/ldkstorage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::logging::MutinyLogger;
use crate::node::{default_user_config, ChainMonitor};
use crate::node::{NetworkGraph, Router};
use crate::nodemanager::ChannelClosure;
use crate::storage::{MutinyStorage, VersionedValue};
use crate::storage::{IndexItem, MutinyStorage, VersionedValue};
use crate::utils;
use crate::utils::{sleep, spawn};
use crate::{chain::MutinyChain, scorer::HubPreferentialScorer};
Expand Down Expand Up @@ -39,7 +39,7 @@ use std::sync::Arc;
pub const CHANNEL_MANAGER_KEY: &str = "manager";
pub const MONITORS_PREFIX_KEY: &str = "monitors/";
const CHANNEL_OPENING_PARAMS_PREFIX: &str = "chan_open_params/";
const CHANNEL_CLOSURE_PREFIX: &str = "channel_closure/";
pub const CHANNEL_CLOSURE_PREFIX: &str = "channel_closure/";
const FAILED_SPENDABLE_OUTPUT_DESCRIPTOR_KEY: &str = "failed_spendable_outputs";

pub(crate) type PhantomChannelManager<S: MutinyStorage> = LdkChannelManager<
Expand Down Expand Up @@ -367,7 +367,15 @@ impl<S: MutinyStorage> MutinyNodePersister<S> {
"{CHANNEL_CLOSURE_PREFIX}{}",
user_channel_id.to_be_bytes().to_hex()
));
self.storage.set_data(key, closure, None)?;
self.storage.set_data(key.clone(), &closure, None)?;

let index = self.storage.activity_index();
let mut index = index.try_write()?;
index.insert(IndexItem {
timestamp: Some(closure.timestamp),
key,
});

Ok(())
}

Expand Down
Loading

0 comments on commit 3548c9f

Please sign in to comment.