Skip to content

Commit

Permalink
adds block digest field to get_history() rpc
Browse files Browse the repository at this point in the history
Addresses
 #59 (comment)
  • Loading branch information
dan-da committed Oct 14, 2023
1 parent dc3b4fd commit 5a1f08c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/bin/dashboard_src/history_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl HistoryScreen {
let bh = rpc_client.get_history(context::current()).await.unwrap();
let mut history_builder = Vec::with_capacity(bh.len());
let mut balance = Amount::zero();
for (block_height, timestamp, amount, sign) in bh.iter() {
for (_, block_height, timestamp, amount, sign) in bh.iter() {
match sign {
Sign::NonNegative => { balance = balance + *amount; }
Sign::Negative => {
Expand Down
10 changes: 5 additions & 5 deletions src/rpc_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub trait RPC {
// Get sum of unspent UTXOs.
async fn get_synced_balance() -> Amount;

async fn get_history() -> Vec<(BlockHeight, Duration, Amount, Sign)>;
async fn get_history() -> Vec<(Digest, BlockHeight, Duration, Amount, Sign)>;

async fn get_wallet_status() -> WalletStatus;

Expand Down Expand Up @@ -161,7 +161,7 @@ impl RPC for NeptuneRPCServer {
type GetReceivingAddressFut = Ready<generation_address::ReceivingAddress>;
type GetMempoolTxCountFut = Ready<usize>;
type GetMempoolSizeFut = Ready<usize>;
type GetHistoryFut = Ready<Vec<(BlockHeight, Duration, Amount, Sign)>>;
type GetHistoryFut = Ready<Vec<(Digest, BlockHeight, Duration, Amount, Sign)>>;
type GetDashboardOverviewDataFut = Ready<DashBoardOverviewDataFromClient>;
type PauseMinerFut = Ready<()>;
type RestartMinerFut = Ready<()>;
Expand Down Expand Up @@ -346,11 +346,11 @@ impl RPC for NeptuneRPCServer {
let history = executor::block_on(self.state.get_balance_history());

// sort
let mut display_history: Vec<(BlockHeight, Duration, Amount, Sign)> = history
let mut display_history: Vec<(Digest, BlockHeight, Duration, Amount, Sign)> = history
.iter()
.map(|(_h, t, bh, a, s)| (*bh, *t, *a, *s))
.map(|(h, t, bh, a, s)| (*h, *bh, *t, *a, *s))
.collect::<Vec<_>>();
display_history.sort_by(|a, b| a.0.partial_cmp(&b.0).unwrap());
display_history.sort_by(|a, b| a.1.partial_cmp(&b.1).unwrap());

// return
future::ready(display_history)
Expand Down

0 comments on commit 5a1f08c

Please sign in to comment.