Merge branch 'master' of github.com:gavofyork/ethcore-util into network
This commit is contained in:
@@ -32,7 +32,7 @@
|
||||
|
||||
pub mod rlptraits;
|
||||
pub mod rlperrors;
|
||||
pub mod rlp;
|
||||
pub mod rlpin;
|
||||
pub mod untrusted_rlp;
|
||||
pub mod rlpstream;
|
||||
|
||||
@@ -42,8 +42,8 @@ mod tests;
|
||||
pub use self::rlperrors::DecoderError;
|
||||
pub use self::rlptraits::{Decoder, Decodable, View, Stream, Encodable, Encoder};
|
||||
pub use self::untrusted_rlp::{UntrustedRlp, UntrustedRlpIterator, PayloadInfo, Prototype};
|
||||
pub use self::rlp::{Rlp, RlpIterator};
|
||||
pub use self::rlpstream::{RlpStream};
|
||||
pub use self::rlpin::{Rlp, RlpIterator};
|
||||
pub use self::rlpstream::{RlpStream,RlpStandard};
|
||||
use super::hash::H256;
|
||||
|
||||
pub const NULL_RLP: [u8; 1] = [0x80; 1];
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
use elastic_array::*;
|
||||
use bytes::ToBytes;
|
||||
use bytes::{Bytes, ToBytes};
|
||||
use rlp::{Stream, Encoder, Encodable};
|
||||
use hash::H256;
|
||||
use sha3::*;
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
struct ListInfo {
|
||||
@@ -213,6 +215,20 @@ impl Encoder for BasicEncoder {
|
||||
}
|
||||
}
|
||||
|
||||
pub trait RlpStandard {
|
||||
fn rlp_append(&self, s: &mut RlpStream);
|
||||
|
||||
fn rlp_bytes(&self) -> Bytes {
|
||||
let mut s = RlpStream::new();
|
||||
self.rlp_append(&mut s);
|
||||
s.out()
|
||||
}
|
||||
|
||||
fn rlp_sha3(&self) -> H256 { self.rlp_bytes().sha3() }
|
||||
}
|
||||
|
||||
// @debris TODO: implement Encoder for RlpStandard.
|
||||
|
||||
impl<T> Encodable for T where T: ToBytes {
|
||||
fn encode<E>(&self, encoder: &mut E) where E: Encoder {
|
||||
encoder.emit_value(&self.to_bytes())
|
||||
|
||||
Reference in New Issue
Block a user