Skip to content

Commit 8ddc51e

Browse files
committed
fix unwrap
1 parent d2b93b9 commit 8ddc51e

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lightning-rapid-gossip-sync/src/lib.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,18 @@ pub enum GraphSyncError {
9292
LightningError(LightningError),
9393
}
9494

95-
impl From<lightning::io::Error> for GraphSyncError {
96-
fn from(error: lightning::io::Error) -> Self {
95+
impl From<io::Error> for GraphSyncError {
96+
fn from(error: io::Error) -> Self {
9797
Self::DecodeError(DecodeError::Io(error.kind()))
9898
}
9999
}
100100

101+
impl From<bitcoin::secp256k1::Error> for GraphSyncError {
102+
fn from(_: bitcoin::secp256k1::Error) -> Self {
103+
Self::DecodeError(DecodeError::InvalidValue)
104+
}
105+
}
106+
101107
impl From<DecodeError> for GraphSyncError {
102108
fn from(error: DecodeError) -> Self {
103109
Self::DecodeError(error)

lightning-rapid-gossip-sync/src/processing.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl<NG: Deref<Target=NetworkGraph<L>>, L: Deref> RapidGossipSync<NG, L> where L
127127
let additional_data_marker = (node_detail_flag & (0b11 << 6)) >> 6;
128128
let key_parity = node_detail_flag & 0b_0000_0011;
129129
pubkey_bytes[0] = key_parity;
130-
let current_pubkey = PublicKey::from_slice(&pubkey_bytes).unwrap();
130+
let current_pubkey = PublicKey::from_slice(&pubkey_bytes)?;
131131
let current_node_id = NodeId::from_pubkey(&current_pubkey);
132132
node_ids.push(current_pubkey);
133133

@@ -159,7 +159,7 @@ impl<NG: Deref<Target=NetworkGraph<L>>, L: Deref> RapidGossipSync<NG, L> where L
159159
let current_byte_count: u8 = Readable::read(read_cursor)?;
160160
let mut address_reader = FixedLengthReader::new(&mut read_cursor, current_byte_count as u64);
161161
let mut address_bytes = Vec::new();
162-
address_reader.read_to_end(&mut address_bytes).unwrap();
162+
address_reader.read_to_end(&mut address_bytes)?;
163163

164164
let mut address_cursor = io::Cursor::new(&address_bytes);
165165
if let Ok(current_address) = Readable::read(&mut address_cursor) {

0 commit comments

Comments
 (0)