mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Remove Protocol::Unsupported
This commit is contained in:
@@ -56,7 +56,6 @@ mod tests;
|
|||||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, Zeroize)]
|
#[derive(Clone, Copy, PartialEq, Eq, Debug, Zeroize)]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub enum Protocol {
|
pub enum Protocol {
|
||||||
Unsupported(usize),
|
|
||||||
v14,
|
v14,
|
||||||
v16,
|
v16,
|
||||||
Custom { ring_len: usize, bp_plus: bool },
|
Custom { ring_len: usize, bp_plus: bool },
|
||||||
@@ -66,7 +65,6 @@ impl Protocol {
|
|||||||
/// Amount of ring members under this protocol version.
|
/// Amount of ring members under this protocol version.
|
||||||
pub fn ring_len(&self) -> usize {
|
pub fn ring_len(&self) -> usize {
|
||||||
match self {
|
match self {
|
||||||
Protocol::Unsupported(_) => panic!("Unsupported protocol version"),
|
|
||||||
Protocol::v14 => 11,
|
Protocol::v14 => 11,
|
||||||
Protocol::v16 => 16,
|
Protocol::v16 => 16,
|
||||||
Protocol::Custom { ring_len, .. } => *ring_len,
|
Protocol::Custom { ring_len, .. } => *ring_len,
|
||||||
@@ -77,7 +75,6 @@ impl Protocol {
|
|||||||
/// This method will likely be reworked when versions not using Bulletproofs at all are added.
|
/// This method will likely be reworked when versions not using Bulletproofs at all are added.
|
||||||
pub fn bp_plus(&self) -> bool {
|
pub fn bp_plus(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Protocol::Unsupported(_) => panic!("Unsupported protocol version"),
|
|
||||||
Protocol::v14 => false,
|
Protocol::v14 => false,
|
||||||
Protocol::v16 => true,
|
Protocol::v16 => true,
|
||||||
Protocol::Custom { bp_plus, .. } => *bp_plus,
|
Protocol::Custom { bp_plus, .. } => *bp_plus,
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ pub enum RpcError {
|
|||||||
ConnectionError,
|
ConnectionError,
|
||||||
#[error("invalid node")]
|
#[error("invalid node")]
|
||||||
InvalidNode,
|
InvalidNode,
|
||||||
|
#[error("unsupported protocol version ({0})")]
|
||||||
|
UnsupportedProtocol(usize),
|
||||||
#[error("transactions not found")]
|
#[error("transactions not found")]
|
||||||
TransactionsNotFound(Vec<[u8; 32]>),
|
TransactionsNotFound(Vec<[u8; 32]>),
|
||||||
#[error("invalid point ({0})")]
|
#[error("invalid point ({0})")]
|
||||||
@@ -211,7 +213,7 @@ impl Rpc {
|
|||||||
{
|
{
|
||||||
13 | 14 => Protocol::v14,
|
13 | 14 => Protocol::v14,
|
||||||
15 | 16 => Protocol::v16,
|
15 | 16 => Protocol::v16,
|
||||||
version => Protocol::Unsupported(version),
|
protocol => Err(RpcError::UnsupportedProtocol(protocol))?,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ use curve25519_dalek::{constants::ED25519_BASEPOINT_TABLE, scalar::Scalar};
|
|||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
|
|
||||||
use monero_serai::{
|
use monero_serai::{
|
||||||
Protocol, random_scalar,
|
random_scalar,
|
||||||
wallet::{
|
wallet::{
|
||||||
ViewPair, Scanner,
|
ViewPair, Scanner,
|
||||||
address::{Network, AddressType, AddressSpec, AddressMeta, MoneroAddress},
|
address::{Network, AddressType, AddressSpec, AddressMeta, MoneroAddress},
|
||||||
@@ -76,6 +76,8 @@ pub async fn get_miner_tx_output(rpc: &Rpc, view: &ViewPair) -> SpendableOutput
|
|||||||
|
|
||||||
pub async fn rpc() -> Rpc {
|
pub async fn rpc() -> Rpc {
|
||||||
let rpc = Rpc::new("http://127.0.0.1:18081".to_string()).unwrap();
|
let rpc = Rpc::new("http://127.0.0.1:18081".to_string()).unwrap();
|
||||||
|
// Make sure we recognize the protocol
|
||||||
|
rpc.get_protocol().await.unwrap();
|
||||||
|
|
||||||
// Only run once
|
// Only run once
|
||||||
if rpc.get_height().await.unwrap() != 1 {
|
if rpc.get_height().await.unwrap() != 1 {
|
||||||
@@ -91,7 +93,6 @@ pub async fn rpc() -> Rpc {
|
|||||||
|
|
||||||
// Mine 40 blocks to ensure decoy availability
|
// Mine 40 blocks to ensure decoy availability
|
||||||
rpc.generate_blocks(&addr, 40).await.unwrap();
|
rpc.generate_blocks(&addr, 40).await.unwrap();
|
||||||
assert!(!matches!(rpc.get_protocol().await.unwrap(), Protocol::Unsupported(_)));
|
|
||||||
|
|
||||||
rpc
|
rpc
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user