Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove temp code #6430

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions applications/minotari_merge_mining_proxy/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use std::{
cmp,
convert::TryInto,
future::Future,
panic,
pin::Pin,
sync::{
atomic::{AtomicBool, Ordering},
Expand Down Expand Up @@ -649,18 +648,12 @@ impl InnerService {
.iter()
.position(|x| x == &last_used_url)
.unwrap_or(0);
// replace after rust stable 1.80 release
// let (left, right) = self
// .config
// .monerod_url
// .split_at_checked(pos)
// .ok_or(MmProxyError::ConversionError("Invalid utf 8 url".to_string()))?;
let url = self.config.monerod_url.clone();
let result = panic::catch_unwind(|| url.split_at(pos));
let (left, right) = match result {
Ok((left, right)) => (left, right),
Err(_) => return Err(MmProxyError::ConversionError("Invalid utf 8 url".to_string())),
};

let (left, right) = self
.config
.monerod_url
.split_at_checked(pos)
.ok_or(MmProxyError::ConversionError("Invalid utf 8 url".to_string()))?;
let left = left.to_vec();
let right = right.to_vec();
let iter = right.iter().chain(left.iter()).chain(right.iter()).chain(left.iter());
Expand Down
17 changes: 4 additions & 13 deletions base_layer/common_types/src/tari_address/dual_address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

use std::{convert::TryFrom, panic};
use std::convert::TryFrom;

use serde::{Deserialize, Serialize};
use tari_common::configuration::Network;
Expand Down Expand Up @@ -168,18 +168,9 @@ impl DualAddress {
if hex_str.len() < INTERNAL_DUAL_BASE58_MIN_SIZE || hex_str.len() > INTERNAL_DUAL_BASE58_MAX_SIZE {
return Err(TariAddressError::InvalidSize);
}
let result = panic::catch_unwind(|| hex_str.split_at(2));
let (first, rest) = match result {
Ok((first, rest)) => (first, rest),
Err(_) => return Err(TariAddressError::InvalidCharacter),
};
let result = panic::catch_unwind(|| first.split_at(1));
let (network, features) = match result {
Ok((network, features)) => (network, features),
Err(_) => return Err(TariAddressError::InvalidCharacter),
};
// let (first, rest) = hex_str.split_at_checked(2).ok_or(TariAddressError::InvalidCharacter)?;
// let (network, features) = first.split_at_checked(1).ok_or(TariAddressError::InvalidCharacter)?;

let (first, rest) = hex_str.split_at_checked(2).ok_or(TariAddressError::InvalidCharacter)?;
let (network, features) = first.split_at_checked(1).ok_or(TariAddressError::InvalidCharacter)?;
let mut result = bs58::decode(network)
.into_vec()
.map_err(|_| TariAddressError::CannotRecoverNetwork)?;
Expand Down
17 changes: 3 additions & 14 deletions base_layer/common_types/src/tari_address/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ mod single_address;
use std::{
fmt,
fmt::{Display, Error, Formatter},
panic,
str::FromStr,
};

Expand Down Expand Up @@ -253,19 +252,9 @@ impl TariAddress {
if hex_str.len() < INTERNAL_SINGLE_MIN_BASE58_SIZE {
return Err(TariAddressError::InvalidSize);
}
let result = panic::catch_unwind(|| hex_str.split_at(2));
let (first, rest) = match result {
Ok((first, rest)) => (first, rest),
Err(_) => return Err(TariAddressError::InvalidCharacter),
};
let result = panic::catch_unwind(|| first.split_at(1));
let (network, features) = match result {
Ok((network, features)) => (network, features),
Err(_) => return Err(TariAddressError::InvalidCharacter),
};
// replace this after 1.80 stable
// let (first, rest) = hex_str.split_at_checked(2).ok_or(TariAddressError::InvalidCharacter)?;
// let (network, features) = first.split_at_checked(1).ok_or(TariAddressError::InvalidCharacter)?;

let (first, rest) = hex_str.split_at_checked(2).ok_or(TariAddressError::InvalidCharacter)?;
let (network, features) = first.split_at_checked(1).ok_or(TariAddressError::InvalidCharacter)?;
let mut result = bs58::decode(network)
.into_vec()
.map_err(|_| TariAddressError::CannotRecoverNetwork)?;
Expand Down
17 changes: 4 additions & 13 deletions base_layer/common_types/src/tari_address/single_address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

use std::{convert::TryFrom, panic};
use std::convert::TryFrom;

use serde::{Deserialize, Serialize};
use tari_common::configuration::Network;
Expand Down Expand Up @@ -151,18 +151,9 @@ impl SingleAddress {
if hex_str.len() < INTERNAL_SINGLE_MIN_BASE58_SIZE || hex_str.len() > INTERNAL_SINGLE_MAX_BASE58_SIZE {
return Err(TariAddressError::InvalidSize);
}
let result = panic::catch_unwind(|| hex_str.split_at(2));
let (first, rest) = match result {
Ok((first, rest)) => (first, rest),
Err(_) => return Err(TariAddressError::InvalidCharacter),
};
let result = panic::catch_unwind(|| first.split_at(1));
let (network, features) = match result {
Ok((network, features)) => (network, features),
Err(_) => return Err(TariAddressError::InvalidCharacter),
};
// let (first, rest) = hex_str.split_at_checked(2).ok_or(TariAddressError::InvalidCharacter)?;
// let (network, features) = first.split_at_checked(1).ok_or(TariAddressError::InvalidCharacter)?;

let (first, rest) = hex_str.split_at_checked(2).ok_or(TariAddressError::InvalidCharacter)?;
let (network, features) = first.split_at_checked(1).ok_or(TariAddressError::InvalidCharacter)?;
let mut result = bs58::decode(network)
.into_vec()
.map_err(|_| TariAddressError::CannotRecoverNetwork)?;
Expand Down
17 changes: 5 additions & 12 deletions common/src/build/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use std::{
fmt,
fs,
io::Write,
panic,
path::{Path, PathBuf},
};

Expand Down Expand Up @@ -129,17 +128,11 @@ fn get_commit() -> Result<String, anyhow::Error> {
let repo = git2::Repository::open(git_root)?;
let head = repo.revparse_single("HEAD")?;
let id = format!("{:?}", head.id());
let result = panic::catch_unwind(|| id.split_at(7));
let id = match result {
Ok((first, _)) => first.to_string(),
Err(_) => return Err(anyhow::anyhow!("invalid utf8 in commit id")),
};

// replace after stable 1.80 release
// id.split_at_checked(7)
// .ok_or(anyhow::anyhow!("invalid utf8 in commit id"))?
// .0
// .to_string();

id.split_at_checked(7)
.ok_or(anyhow::anyhow!("invalid utf8 in commit id"))?
.0
.to_string();
Ok(id)
}

Expand Down
Loading