Skip to content

Commit

Permalink
Merge pull request #8 from Sovenok-Hacker/dev
Browse files Browse the repository at this point in the history
Fix some errors and warnings
  • Loading branch information
YeahNotSewerSide authored Sep 3, 2023
2 parents 73f0c40 + 09c0957 commit 3d6f827
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/encsocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ impl EncSocket {
EncSocket::establish_new_connection(stream, addr, timeout).await
}

#[allow(dead_code)]
pub async fn read_exact(&mut self, buffer: &mut [u8]) -> Result<usize, EncSocketError> {
let mut received_size = 0;
let mut total_read = 0;
Expand Down Expand Up @@ -192,6 +193,7 @@ impl EncSocket {
Ok(total_read)
}

#[allow(dead_code)]
pub async fn recv_raw(&mut self) -> Result<(usize, Vec<u8>), EncSocketError> {
// read size of the packet
let mut recv_buffer = [0u8; 4];
Expand Down Expand Up @@ -252,6 +254,7 @@ impl EncSocket {
Ok(())
}

#[allow(dead_code)]
pub async fn recv<'a, PT: Deserialize<'a>>(&mut self) -> Result<PT, EncSocketError> {
PT::deserialize(&mut Deserializer::new(Cursor::new(
self.recv_raw().await?.1,
Expand Down
1 change: 1 addition & 0 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pub mod node_errors {
#[error("Error recieving packet from {0:?}: {1:?}")]
ReceievePacket(SocketAddr, EncSocketError),

#[allow(dead_code)]
#[error("Error reading propagation channel {0:?}: {1:?}")]
PropagationRead(SocketAddr, RecvError),

Expand Down
4 changes: 1 addition & 3 deletions src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use blockchaintree::{
block::{self, MainChainBlock},
transaction::Transactionable,
};
use num_bigint::BigUint;
use tracing::{debug, error, warn};

use crate::{
Expand Down Expand Up @@ -491,14 +490,13 @@ pub async fn submit_pow_request_handler(
} else if received_timestamp - packet.timestamp > MAX_POW_SUBMIT_DELAY {
return Err(NodeError::TimestampExpired);
}
let pow = BigUint::from_bytes_be(&packet.pow);

// cannot fail
let address: [u8; 33] = unsafe { packet.address.clone().try_into().unwrap_unchecked() };

let new_block = context
.blockchain
.emit_main_chain_block(pow, address, packet.timestamp)
.emit_main_chain_block(&packet.pow, address, packet.timestamp)
.await
.map_err(|e| NodeError::EmitMainChainBlock(e.to_string()))?;

Expand Down
1 change: 1 addition & 0 deletions src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ pub mod packet_models {
}
}

#[allow(dead_code)]
pub fn get_id(&self) -> u64 {
match self {
Packet::Request { id, .. } => *id,
Expand Down

0 comments on commit 3d6f827

Please sign in to comment.