Skip to content

Commit

Permalink
Same as previous commit but for HeaderRow
Browse files Browse the repository at this point in the history
  • Loading branch information
RCasatta committed Jul 21, 2023
1 parent ea93d00 commit 2e13b5d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::convert::TryFrom;

use bitcoin::blockdata::block::Header as BlockHeader;
use bitcoin::{
consensus::encode::{deserialize, serialize, Decodable, Encodable},
consensus::encode::{deserialize, Decodable, Encodable},
hashes::{hash_newtype, sha256, Hash},
OutPoint, Script, Txid,
};
Expand Down Expand Up @@ -170,7 +170,10 @@ impl HeaderRow {
}

pub(crate) fn to_db_row(&self) -> db::Row {
serialize(self).into_boxed_slice()
let mut vec = Vec::with_capacity(80);
let len = self.consensus_encode(&mut vec).expect("in-memory writers don't error");
debug_assert_eq!(len, 80);
vec.into_boxed_slice()
}

pub(crate) fn from_db_row(row: &[u8]) -> Self {
Expand Down

0 comments on commit 2e13b5d

Please sign in to comment.