Skip to content

Commit

Permalink
Add MUTXO pruning endpoint to RPC client
Browse files Browse the repository at this point in the history
  • Loading branch information
Sword-Smith committed Jul 24, 2023
1 parent 30cff89 commit fb6c283
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 8 additions & 0 deletions src/bin/neptune-cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ enum Command {
GetReceivingAddress,
MempoolTxCount,
MempoolSize,
PruneAbandonedMonitoredUtxos,
}

#[derive(Debug, Parser)]
Expand Down Expand Up @@ -146,6 +147,13 @@ async fn main() -> Result<()> {
let size_in_bytes: usize = client.get_mempool_size(context::current()).await?;
println!("{} bytes", size_in_bytes);
}

Command::PruneAbandonedMonitoredUtxos => {
let prunt_res_count = client
.prune_abandoned_monitored_utxos(context::current())
.await?;
println!("{prunt_res_count} monitored UTXOs marked as abandoned");
}
}

Ok(())
Expand Down
10 changes: 5 additions & 5 deletions src/rpc_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ pub trait RPC {
async fn restart_miner();

// mark MUTXOs as abandoned
async fn prune_abandoned_monitored_utxos();
async fn prune_abandoned_monitored_utxos() -> usize;
}

#[derive(Clone)]
Expand Down Expand Up @@ -153,7 +153,7 @@ impl RPC for NeptuneRPCServer {
type GetDashboardOverviewDataFut = Ready<DashBoardOverviewDataFromClient>;
type PauseMinerFut = Ready<()>;
type RestartMinerFut = Ready<()>;
type PruneAbandonedMonitoredUtxosFut = Ready<()>;
type PruneAbandonedMonitoredUtxosFut = Ready<usize>;

fn get_network(self, _: context::Context) -> Self::GetNetworkFut {
let network = self.state.cli.network;
Expand Down Expand Up @@ -539,13 +539,13 @@ impl RPC for NeptuneRPCServer {
match prune_count_res {
Ok(prune_count) => {
info!("Marked {prune_count} monitored UTXOs as abandoned");
future::ready(prune_count)
}
Err(err) => {
error!("Pruning monitored UTXOs failed with error: {err}");
future::ready(0)
}
};

future::ready(())
}
}
}

Expand Down

0 comments on commit fb6c283

Please sign in to comment.