Skip to content

Commit

Permalink
add filter
Browse files Browse the repository at this point in the history
  • Loading branch information
jorian committed Nov 2, 2022
1 parent 7bf875b commit 90b5a32
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 9 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ Watches reserves as they change per block.
![](screenshot.png)

You have the choice to watch all reserve currencies and their reserves, based on a selection of coins.
Or select a specific reserve currency from the list.

# Future versions

- add support for mempool scanning
- change PBaaS chains
- select specific currency baskets by their name

# DEV

Have
Run with `RUST_LOG=info LC_ALL=en_US.UTF-8 cargo run --color always >> output.log 2>&1`
image.png

Binary file modified screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use std::sync::mpsc;

use cursive::{
view::{Nameable, Resizable},
views::{DummyView, LinearLayout, Panel, ResizedView},
views::{LinearLayout, Panel, ResizedView},
CursiveRunnable, CursiveRunner,
};
use tracing::debug;
use vrsc_rpc::json::{Currency, ReserveCurrency};
use vrsc_rpc::json::Currency;

use crate::{
controller::ControllerMessage,
Expand Down
2 changes: 1 addition & 1 deletion src/verus.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::HashMap;

use vrsc_rpc::{
json::{vrsc::Address, Currency, ReserveCurrency},
json::{vrsc::Address, Currency},
Auth, Client, RpcApi,
};

Expand Down
2 changes: 1 addition & 1 deletion src/views/filterbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl ViewWrapper for FilterBox {
printer.print((4, 0), &self.currency.currencydefinition.name);
}

fn wrap_required_size(&mut self, req: cursive::Vec2) -> cursive::Vec2 {
fn wrap_required_size(&mut self, _req: cursive::Vec2) -> cursive::Vec2 {
Vec2::new(4 + self.currency.currencydefinition.name.len(), 1)
}
}
19 changes: 16 additions & 3 deletions src/views/reserves.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use cursive::{
reexports::log::debug,
view::{Resizable, ViewWrapper},
views::*,
View,
Expand All @@ -19,16 +20,28 @@ impl Reserves {
}
}

pub fn update(&mut self, baskets: Vec<Basket>, _checked_currencies: Vec<Currency>) {
pub fn update(&mut self, baskets: Vec<Basket>, checked_currencies: Vec<Currency>) {
info!("{} baskets retrieved", baskets.len());

self.view.get_inner_mut().clear();
self.view.get_inner_mut().add_child(
ScrollView::new({
let mut ll = LinearLayout::vertical();

for basket in baskets.into_iter() {
ll.add_child(ReserveTable::new(basket));
// apply the filter:
for mut basket in baskets.into_iter() {
debug!("{:?}", &checked_currencies);
basket.currency_state.reservecurrencies.retain(|rc| {
checked_currencies
.iter()
.any(|cur| cur.currencydefinition.currencyid == rc.currencyid)
|| rc.currencyid.to_string()
== "iJhCezBExJHvtyH3fGhNnt2NhU4Ztkf2yq".to_string()
});
// debug!("{:?}", &basket);
if basket.currency_state.reservecurrencies.len() > 1 {
ll.add_child(ReserveTable::new(basket));
}
}

ll
Expand Down

0 comments on commit 90b5a32

Please sign in to comment.