Wrap Transaction in Arc
This commit is contained in:
parent
b263489af6
commit
9f802cd8dd
|
@ -4,3 +4,5 @@
|
||||||
.firebase/
|
.firebase/
|
||||||
# Emacs detritus
|
# Emacs detritus
|
||||||
*~
|
*~
|
||||||
|
# Vscode detrius
|
||||||
|
.vscode/
|
||||||
|
|
|
@ -6,7 +6,7 @@ mod tests;
|
||||||
|
|
||||||
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
|
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
|
||||||
use chrono::{DateTime, TimeZone, Utc};
|
use chrono::{DateTime, TimeZone, Utc};
|
||||||
use std::{fmt, io};
|
use std::{fmt, io, sync::Arc};
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
use proptest_derive::Arbitrary;
|
use proptest_derive::Arbitrary;
|
||||||
|
@ -205,7 +205,7 @@ pub struct Block {
|
||||||
/// The block header, containing block metadata.
|
/// The block header, containing block metadata.
|
||||||
pub header: BlockHeader,
|
pub header: BlockHeader,
|
||||||
/// The block transactions.
|
/// The block transactions.
|
||||||
pub transactions: Vec<Transaction>,
|
pub transactions: Vec<Arc<Transaction>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Block {
|
impl Block {
|
||||||
|
|
|
@ -2,7 +2,10 @@
|
||||||
//! transaction types, so that all of the serialization logic is in one place.
|
//! transaction types, so that all of the serialization logic is in one place.
|
||||||
|
|
||||||
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
|
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
|
||||||
use std::io::{self, Read};
|
use std::{
|
||||||
|
io::{self, Read},
|
||||||
|
sync::Arc,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::notes;
|
use crate::notes;
|
||||||
use crate::proofs::ZkSnarkProof;
|
use crate::proofs::ZkSnarkProof;
|
||||||
|
@ -564,3 +567,21 @@ impl ZcashDeserialize for Transaction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> ZcashDeserialize for Arc<T>
|
||||||
|
where
|
||||||
|
T: ZcashDeserialize,
|
||||||
|
{
|
||||||
|
fn zcash_deserialize<R: io::Read>(reader: R) -> Result<Self, SerializationError> {
|
||||||
|
Ok(Arc::new(T::zcash_deserialize(reader)?))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> ZcashSerialize for Arc<T>
|
||||||
|
where
|
||||||
|
T: ZcashSerialize,
|
||||||
|
{
|
||||||
|
fn zcash_serialize<W: io::Write>(&self, writer: W) -> Result<(), io::Error> {
|
||||||
|
T::zcash_serialize(self, writer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -236,7 +236,7 @@ pub enum Message {
|
||||||
/// A `tx` message.
|
/// A `tx` message.
|
||||||
///
|
///
|
||||||
/// [Bitcoin reference](https://en.bitcoin.it/wiki/Protocol_documentation#tx)
|
/// [Bitcoin reference](https://en.bitcoin.it/wiki/Protocol_documentation#tx)
|
||||||
Tx(Box<Transaction>),
|
Tx(Arc<Transaction>),
|
||||||
|
|
||||||
/// A `mempool` message.
|
/// A `mempool` message.
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in New Issue