Use const values for our traits where we can

This commit is contained in:
Luke Parker
2022-06-03 23:22:08 -04:00
parent b83ca7d666
commit 3617ed4eb7
12 changed files with 72 additions and 113 deletions

View File

@@ -58,7 +58,7 @@ impl Monero {
pub fn new(url: String) -> Monero {
Monero {
rpc: Rpc::new(url),
view: dfg::Scalar::from_hash(view_key::<Monero>(0)).0
view: *view_key::<Monero>(0)
}
}
}
@@ -73,16 +73,16 @@ impl Coin for Monero {
type Address = Address;
fn id() -> &'static [u8] { b"Monero" }
fn confirmations() -> usize { 10 }
const ID: &'static [u8] = b"Monero";
const CONFIRMATIONS: usize = 10;
// Testnet TX bb4d188a4c571f2f0de70dca9d475abc19078c10ffa8def26dd4f63ce1bcfd79 uses 146 inputs
// while using less than 100kb of space, albeit with just 2 outputs (though outputs share a BP)
// The TX size limit is half the contextual median block weight, where said weight is >= 300,000
// This means any TX which fits into 150kb will be accepted by Monero
// 128, even with 16 outputs, should fit into 100kb. Further efficiency by 192 may be viable
// TODO: Get hard numbers and tune
fn max_inputs() -> usize { 128 }
fn max_outputs() -> usize { 16 }
const MAX_INPUTS: usize = 128;
const MAX_OUTPUTS: usize = 16;
async fn get_height(&self) -> Result<usize, CoinError> {
self.rpc.get_height().await.map_err(|_| CoinError::ConnectionError)