lint and fixes that rls missed cuz of the version change
This commit is contained in:
parent
45c5d33130
commit
7bd44b01df
@ -1093,7 +1093,7 @@ impl App {
|
|||||||
.params()
|
.params()
|
||||||
.as_array()
|
.as_array()
|
||||||
.ok_or_else(|| Web3ProxyError::BadRequest("Unable to get array from params".into()))?
|
.ok_or_else(|| Web3ProxyError::BadRequest("Unable to get array from params".into()))?
|
||||||
.get(0)
|
.first()
|
||||||
.ok_or_else(|| Web3ProxyError::BadRequest("Unable to get item 0 from params".into()))?
|
.ok_or_else(|| Web3ProxyError::BadRequest("Unable to get item 0 from params".into()))?
|
||||||
.as_str()
|
.as_str()
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| {
|
||||||
@ -1177,8 +1177,9 @@ impl App {
|
|||||||
// no idea how we got an array here, but lets force this to just the txid
|
// no idea how we got an array here, but lets force this to just the txid
|
||||||
// TODO: think about this more
|
// TODO: think about this more
|
||||||
if value.get().starts_with('[') {
|
if value.get().starts_with('[') {
|
||||||
let backend_rpcs = web3_request
|
let backend_rpcs = web3_request.backend_rpcs_used();
|
||||||
.backend_rpcs_used()
|
|
||||||
|
let backend_rpcs = backend_rpcs
|
||||||
.iter()
|
.iter()
|
||||||
.map(|x| x.name.as_str())
|
.map(|x| x.name.as_str())
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
@ -1584,7 +1585,7 @@ impl App {
|
|||||||
serde_json::Value::Array(params) => {
|
serde_json::Value::Array(params) => {
|
||||||
// TODO: make a struct and use serde conversion to clean this up
|
// TODO: make a struct and use serde conversion to clean this up
|
||||||
if params.len() != 1
|
if params.len() != 1
|
||||||
|| !params.get(0).map(|x| x.is_string()).unwrap_or(false)
|
|| !params.first().map(|x| x.is_string()).unwrap_or(false)
|
||||||
{
|
{
|
||||||
// TODO: what error code?
|
// TODO: what error code?
|
||||||
// TODO: use Web3ProxyError::BadRequest
|
// TODO: use Web3ProxyError::BadRequest
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
//! TODO: script that queries influx and calculates observed relative costs
|
//! TODO: script that queries influx and calculates observed relative costs
|
||||||
|
|
||||||
use migration::sea_orm::prelude::Decimal;
|
use migration::sea_orm::prelude::Decimal;
|
||||||
use std::{ops::Add, str::FromStr};
|
use std::{ops::Add, ops::Mul, str::FromStr};
|
||||||
use tracing::{trace, warn};
|
use tracing::{trace, warn};
|
||||||
|
|
||||||
/// TODO: i don't like how we use this inside the config and also have it available publicly. we should only getting this value from the config
|
/// TODO: i don't like how we use this inside the config and also have it available publicly. we should only getting this value from the config
|
||||||
@ -44,6 +44,17 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> Mul<T> for ComputeUnit
|
||||||
|
where
|
||||||
|
T: Into<Decimal>,
|
||||||
|
{
|
||||||
|
type Output = Self;
|
||||||
|
|
||||||
|
fn mul(self, rhs: T) -> Self::Output {
|
||||||
|
Self(self.0 * rhs.into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl ComputeUnit {
|
impl ComputeUnit {
|
||||||
/// costs can vary widely depending on method and chain
|
/// costs can vary widely depending on method and chain
|
||||||
pub fn new(method: &str, chain_id: u64, response_bytes: u64) -> Self {
|
pub fn new(method: &str, chain_id: u64, response_bytes: u64) -> Self {
|
||||||
@ -155,31 +166,31 @@ impl ComputeUnit {
|
|||||||
(_, "web3_bundlerVersion") => 15,
|
(_, "web3_bundlerVersion") => 15,
|
||||||
(_, "web3_sha3") => 15,
|
(_, "web3_sha3") => 15,
|
||||||
(_, "ots_getInternalOperations") => {
|
(_, "ots_getInternalOperations") => {
|
||||||
return Self::variable_price(chain_id, method, response_bytes) + 100
|
return Self::variable_price(chain_id, method, response_bytes) + 100;
|
||||||
}
|
}
|
||||||
(_, "ots_hasCode") => {
|
(_, "ots_hasCode") => {
|
||||||
return Self::variable_price(chain_id, method, response_bytes) + 100
|
return Self::variable_price(chain_id, method, response_bytes) + 100;
|
||||||
}
|
}
|
||||||
(_, "ots_getTransactionError") => {
|
(_, "ots_getTransactionError") => {
|
||||||
return Self::variable_price(chain_id, method, response_bytes) + 100
|
return Self::variable_price(chain_id, method, response_bytes) + 100;
|
||||||
}
|
}
|
||||||
(_, "ots_traceTransaction") => {
|
(_, "ots_traceTransaction") => {
|
||||||
return Self::variable_price(chain_id, method, response_bytes) + 100
|
return Self::variable_price(chain_id, method, response_bytes) + 100;
|
||||||
}
|
}
|
||||||
(_, "ots_getBlockDetails") => {
|
(_, "ots_getBlockDetails") => {
|
||||||
return Self::variable_price(chain_id, method, response_bytes) + 100
|
return Self::variable_price(chain_id, method, response_bytes) + 100;
|
||||||
}
|
}
|
||||||
(_, "ots_getBlockDetailsByHash") => {
|
(_, "ots_getBlockDetailsByHash") => {
|
||||||
return Self::variable_price(chain_id, method, response_bytes) + 100
|
return Self::variable_price(chain_id, method, response_bytes) + 100;
|
||||||
}
|
}
|
||||||
(_, "ots_getBlockTransactions") => {
|
(_, "ots_getBlockTransactions") => {
|
||||||
return Self::variable_price(chain_id, method, response_bytes) + 100
|
return Self::variable_price(chain_id, method, response_bytes) + 100;
|
||||||
}
|
}
|
||||||
(_, "ots_searchTransactionsBefore") => {
|
(_, "ots_searchTransactionsBefore") => {
|
||||||
return Self::variable_price(chain_id, method, response_bytes) + 100
|
return Self::variable_price(chain_id, method, response_bytes) + 100;
|
||||||
}
|
}
|
||||||
(_, "ots_searchTransactionsAfter") => {
|
(_, "ots_searchTransactionsAfter") => {
|
||||||
return Self::variable_price(chain_id, method, response_bytes) + 100
|
return Self::variable_price(chain_id, method, response_bytes) + 100;
|
||||||
}
|
}
|
||||||
(_, "ots_getTransactionBySenderAndNonce") => 1000,
|
(_, "ots_getTransactionBySenderAndNonce") => 1000,
|
||||||
(_, "ots_getContractCreator") => 1000,
|
(_, "ots_getContractCreator") => 1000,
|
||||||
@ -204,12 +215,12 @@ impl ComputeUnit {
|
|||||||
{
|
{
|
||||||
// maybe charge extra since they are doing things they aren't supposed to
|
// maybe charge extra since they are doing things they aren't supposed to
|
||||||
return Self::unimplemented();
|
return Self::unimplemented();
|
||||||
|
}
|
||||||
|
|
||||||
warn!(%response_bytes, "unknown method {}", method);
|
warn!(%response_bytes, "unknown method {}", method);
|
||||||
return Self::unimplemented()
|
return Self::unimplemented()
|
||||||
+ Self::variable_price(chain_id, method, response_bytes).0;
|
+ Self::variable_price(chain_id, method, response_bytes).0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let cu = Decimal::from(cu);
|
let cu = Decimal::from(cu);
|
||||||
|
Loading…
Reference in New Issue
Block a user