Skip to content

Commit fe8ce45

Browse files
author
Ludo Galabru
committed
fix: allow empty block
1 parent 8477925 commit fe8ce45

File tree

1 file changed

+6
-2
lines changed
  • components/chainhook-event-observer/src/hord/db

1 file changed

+6
-2
lines changed

components/chainhook-event-observer/src/hord/db/mod.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@ pub struct CompactedBlock(
192192
use std::io::{Read, Write};
193193

194194
impl CompactedBlock {
195+
fn empty() -> CompactedBlock {
196+
CompactedBlock((([0, 0, 0, 0], 0), vec![]))
197+
}
198+
195199
pub fn from_full_block(block: &BitcoinBlockFullBreakdown) -> CompactedBlock {
196200
let mut txs = vec![];
197201
let mut coinbase_value = 0;
@@ -258,8 +262,8 @@ impl CompactedBlock {
258262
}
259263

260264
pub fn from_hex_bytes(bytes: &str) -> CompactedBlock {
261-
let bytes = hex_simd::decode_to_vec(&bytes).unwrap();
262-
let value = serde_cbor::from_slice(&bytes[..]).unwrap();
265+
let bytes = hex_simd::decode_to_vec(&bytes).unwrap_or(vec![]);
266+
let value = serde_cbor::from_slice(&bytes[..]).unwrap_or(CompactedBlock::empty());
263267
value
264268
}
265269

0 commit comments

Comments
 (0)