mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Add init function for BP statics
Considering they take 7 seconds to generate, thanks to #68, the ability to generate them at the start instead of on first BP is greatly appreciated. Also performs minor cleanups regarding BPs.
This commit is contained in:
@@ -9,6 +9,7 @@ use transcript::RecommendedTranscript;
|
||||
use frost::{curve::Ed25519, FrostKeys};
|
||||
|
||||
use monero_serai::{
|
||||
ringct::bulletproofs::Bulletproofs,
|
||||
transaction::Transaction,
|
||||
rpc::Rpc,
|
||||
wallet::{
|
||||
@@ -69,9 +70,15 @@ pub struct Monero {
|
||||
}
|
||||
|
||||
impl Monero {
|
||||
pub fn new(url: String) -> Monero {
|
||||
pub async fn new(url: String) -> Monero {
|
||||
let view = view_key::<Monero>(0).0;
|
||||
Monero { rpc: Rpc::new(url), view }
|
||||
let res = Monero { rpc: Rpc::new(url), view };
|
||||
|
||||
// Initialize Bulletproofs now to prevent the first call from taking several seconds
|
||||
// TODO: Do this for both, unless we're sure we're only working on a single protocol
|
||||
Bulletproofs::init(res.rpc.get_protocol().await.unwrap().bp_plus());
|
||||
|
||||
res
|
||||
}
|
||||
|
||||
fn view_pair(&self, spend: dfg::EdwardsPoint) -> ViewPair {
|
||||
|
||||
@@ -111,7 +111,7 @@ async fn test_send<C: Coin + Clone>(coin: C, fee: C::Fee) {
|
||||
|
||||
#[tokio::test]
|
||||
async fn monero() {
|
||||
let monero = Monero::new("http://127.0.0.1:18081".to_string());
|
||||
let monero = Monero::new("http://127.0.0.1:18081".to_string()).await;
|
||||
let fee = monero.rpc.get_fee().await.unwrap();
|
||||
test_send(monero, fee).await;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user