mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-12 11:38:13 -07:00
types: coinbase lossy format
This commit is contained in:
@@ -39,13 +39,6 @@ impl CoinbaseTag {
|
|||||||
let len = (self.0[0] as usize).min(100);
|
let len = (self.0[0] as usize).min(100);
|
||||||
String::from_utf8_lossy(&self.0[1..1 + len])
|
String::from_utf8_lossy(&self.0[1..1 + len])
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the tag bytes (without length prefix).
|
|
||||||
#[inline]
|
|
||||||
pub fn tag_bytes(&self) -> &[u8] {
|
|
||||||
let len = (self.0[0] as usize).min(100);
|
|
||||||
&self.0[1..1 + len]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&[u8]> for CoinbaseTag {
|
impl From<&[u8]> for CoinbaseTag {
|
||||||
@@ -75,12 +68,12 @@ impl<'de> Deserialize<'de> for CoinbaseTag {
|
|||||||
|
|
||||||
impl Formattable for CoinbaseTag {
|
impl Formattable for CoinbaseTag {
|
||||||
fn write_to(&self, buf: &mut Vec<u8>) {
|
fn write_to(&self, buf: &mut Vec<u8>) {
|
||||||
buf.extend_from_slice(self.tag_bytes());
|
buf.extend_from_slice(self.as_str().as_bytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fmt_json(&self, buf: &mut Vec<u8>) {
|
fn fmt_json(&self, buf: &mut Vec<u8>) {
|
||||||
buf.push(b'"');
|
buf.push(b'"');
|
||||||
buf.extend_from_slice(self.tag_bytes());
|
buf.extend_from_slice(self.as_str().as_bytes());
|
||||||
buf.push(b'"');
|
buf.push(b'"');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user