mirror of
https://github.com/mimblewimble/grin.git
synced 2025-02-01 17:01:09 +03:00
core/ser: replace write_vec
with write_bytes
, drop a bunch of clones
This commit is contained in:
parent
bc38016385
commit
630c4eb6fb
2 changed files with 7 additions and 7 deletions
|
@ -41,7 +41,7 @@ pub struct TxProof {
|
||||||
impl Writeable for TxProof {
|
impl Writeable for TxProof {
|
||||||
fn write(&self, writer: &mut Writer) -> Result<(), ser::Error> {
|
fn write(&self, writer: &mut Writer) -> Result<(), ser::Error> {
|
||||||
try!(writer.write_fixed_bytes(&self.remainder));
|
try!(writer.write_fixed_bytes(&self.remainder));
|
||||||
writer.write_vec(&mut self.sig.clone())
|
writer.write_bytes(&self.sig)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ impl Writeable for Transaction {
|
||||||
fn write(&self, writer: &mut Writer) -> Result<(), ser::Error> {
|
fn write(&self, writer: &mut Writer) -> Result<(), ser::Error> {
|
||||||
ser_multiwrite!(writer,
|
ser_multiwrite!(writer,
|
||||||
[write_u64, self.fee],
|
[write_u64, self.fee],
|
||||||
[write_vec, &mut self.zerosig.clone()],
|
[write_bytes, &self.zerosig],
|
||||||
[write_u64, self.inputs.len() as u64],
|
[write_u64, self.inputs.len() as u64],
|
||||||
[write_u64, self.outputs.len() as u64]);
|
[write_u64, self.outputs.len() as u64]);
|
||||||
for inp in &self.inputs {
|
for inp in &self.inputs {
|
||||||
|
@ -304,7 +304,7 @@ pub enum Output {
|
||||||
impl Writeable for Output {
|
impl Writeable for Output {
|
||||||
fn write(&self, writer: &mut Writer) -> Result<(), ser::Error> {
|
fn write(&self, writer: &mut Writer) -> Result<(), ser::Error> {
|
||||||
try!(writer.write_fixed_bytes(&self.commitment().unwrap()));
|
try!(writer.write_fixed_bytes(&self.commitment().unwrap()));
|
||||||
writer.write_vec(&mut self.proof().unwrap().bytes().to_vec())
|
writer.write_bytes(&mut self.proof().unwrap().bytes())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ pub trait Writer {
|
||||||
fn write_i64(&mut self, n: i64) -> Result<(), Error>;
|
fn write_i64(&mut self, n: i64) -> Result<(), Error>;
|
||||||
/// Writes a variable length `Vec`, the length of the `Vec` is encoded as a
|
/// Writes a variable length `Vec`, the length of the `Vec` is encoded as a
|
||||||
/// prefix.
|
/// prefix.
|
||||||
fn write_vec(&mut self, vec: &mut Vec<u8>) -> Result<(), Error>;
|
fn write_bytes(&mut self, data: &[u8]) -> Result<(), Error>;
|
||||||
/// Writes a fixed number of bytes from something that can turn itself into
|
/// Writes a fixed number of bytes from something that can turn itself into
|
||||||
/// a `&[u8]`. The reader is expected to know the actual length on read.
|
/// a `&[u8]`. The reader is expected to know the actual length on read.
|
||||||
fn write_fixed_bytes(&mut self, b32: &AsFixedBytes) -> Result<(), Error>;
|
fn write_fixed_bytes(&mut self, b32: &AsFixedBytes) -> Result<(), Error>;
|
||||||
|
@ -249,9 +249,9 @@ impl<'a> Writer for BinWriter<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn write_vec(&mut self, vec: &mut Vec<u8>) -> Result<(), Error> {
|
fn write_bytes(&mut self, data: &[u8]) -> Result<(), Error> {
|
||||||
try!(self.write_u64(vec.len() as u64));
|
try!(self.write_u64(data.len() as u64));
|
||||||
try!(self.sink.write_all(vec));
|
try!(self.sink.write_all(data));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue