forked from ordinals/ord
-
Notifications
You must be signed in to change notification settings - Fork 35
/
sat_point.rs
28 lines (24 loc) Β· 726 Bytes
/
sat_point.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use super::*;
pub(crate) struct SatPoint {
pub(crate) outpoint: OutPoint,
pub(crate) offset: u64,
}
impl Display for SatPoint {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "{}:{}", self.outpoint, self.offset)
}
}
impl Encodable for SatPoint {
fn consensus_encode<S: io::Write>(&self, mut s: S) -> Result<usize, io::Error> {
let len = self.outpoint.consensus_encode(&mut s)?;
Ok(len + self.offset.consensus_encode(s)?)
}
}
impl Decodable for SatPoint {
fn consensus_decode<D: io::Read>(mut d: D) -> Result<Self, bitcoin::consensus::encode::Error> {
Ok(SatPoint {
outpoint: Decodable::consensus_decode(&mut d)?,
offset: Decodable::consensus_decode(d)?,
})
}
}