Stop accessing inner ScriptBuf field when encoding
In preparation for moving the `ScriptBuf` type to `primitives` stop accessing the inner field when encoding/decoding, use `as_script` and `from_bytes` instead.
This commit is contained in:
parent
8b82363d97
commit
900af453ff
|
@ -616,14 +616,14 @@ impl<'de> serde::Deserialize<'de> for ScriptBuf {
|
||||||
impl Encodable for Script {
|
impl Encodable for Script {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn consensus_encode<W: Write + ?Sized>(&self, w: &mut W) -> Result<usize, io::Error> {
|
fn consensus_encode<W: Write + ?Sized>(&self, w: &mut W) -> Result<usize, io::Error> {
|
||||||
crate::consensus::encode::consensus_encode_with_size(&self.0, w)
|
crate::consensus::encode::consensus_encode_with_size(self.as_bytes(), w)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Encodable for ScriptBuf {
|
impl Encodable for ScriptBuf {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn consensus_encode<W: Write + ?Sized>(&self, w: &mut W) -> Result<usize, io::Error> {
|
fn consensus_encode<W: Write + ?Sized>(&self, w: &mut W) -> Result<usize, io::Error> {
|
||||||
self.0.consensus_encode(w)
|
self.as_script().consensus_encode(w)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -632,7 +632,8 @@ impl Decodable for ScriptBuf {
|
||||||
fn consensus_decode_from_finite_reader<R: BufRead + ?Sized>(
|
fn consensus_decode_from_finite_reader<R: BufRead + ?Sized>(
|
||||||
r: &mut R,
|
r: &mut R,
|
||||||
) -> Result<Self, encode::Error> {
|
) -> Result<Self, encode::Error> {
|
||||||
Ok(ScriptBuf(Decodable::consensus_decode_from_finite_reader(r)?))
|
let v: Vec<u8> = Decodable::consensus_decode_from_finite_reader(r)?;
|
||||||
|
Ok(ScriptBuf::from_bytes(v))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue