mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 03:21:08 +03:00
core: move remaining contents of core/ser.rs into ser.rs
This commit is contained in:
parent
82adc54971
commit
4b51610d9a
3 changed files with 28 additions and 56 deletions
|
@ -19,7 +19,6 @@ pub mod hash;
|
||||||
pub mod transaction;
|
pub mod transaction;
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod ser;
|
|
||||||
|
|
||||||
pub use self::block::{Block, BlockHeader};
|
pub use self::block::{Block, BlockHeader};
|
||||||
pub use self::transaction::{Transaction, Input, Output, TxProof};
|
pub use self::transaction::{Transaction, Input, Output, TxProof};
|
||||||
|
|
|
@ -1,55 +0,0 @@
|
||||||
// Copyright 2016 The Grin Developers
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
//! Binary stream serialization and deserialzation for core types from trusted
|
|
||||||
//! Write or Read implementations. Issues like starvation or too big sends are
|
|
||||||
//! expected to be handled upstream.
|
|
||||||
|
|
||||||
use time;
|
|
||||||
|
|
||||||
use std::io::{Write, Read};
|
|
||||||
use core::{self, hash};
|
|
||||||
use ser::*;
|
|
||||||
|
|
||||||
use secp::Signature;
|
|
||||||
use secp::key::SecretKey;
|
|
||||||
use secp::pedersen::{Commitment, RangeProof};
|
|
||||||
|
|
||||||
macro_rules! impl_slice_bytes {
|
|
||||||
($byteable: ty) => {
|
|
||||||
impl AsFixedBytes for $byteable {
|
|
||||||
fn as_fixed_bytes(&self) -> &[u8] {
|
|
||||||
&self[..]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl_slice_bytes!(SecretKey);
|
|
||||||
impl_slice_bytes!(Signature);
|
|
||||||
impl_slice_bytes!(Commitment);
|
|
||||||
impl_slice_bytes!(Vec<u8>);
|
|
||||||
|
|
||||||
impl AsFixedBytes for hash::Hash {
|
|
||||||
fn as_fixed_bytes(&self) -> &[u8] {
|
|
||||||
self.to_slice()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AsFixedBytes for RangeProof {
|
|
||||||
fn as_fixed_bytes(&self) -> &[u8] {
|
|
||||||
&self.bytes()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -170,3 +170,31 @@ impl<'a> Writer for BinWriter<'a> {
|
||||||
self.sink.write_all(bs).err().map(Error::IOErr)
|
self.sink.write_all(bs).err().map(Error::IOErr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
macro_rules! impl_slice_bytes {
|
||||||
|
($byteable: ty) => {
|
||||||
|
impl AsFixedBytes for $byteable {
|
||||||
|
fn as_fixed_bytes(&self) -> &[u8] {
|
||||||
|
&self[..]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl_slice_bytes!(::secp::key::SecretKey);
|
||||||
|
impl_slice_bytes!(::secp::Signature);
|
||||||
|
impl_slice_bytes!(::secp::pedersen::Commitment);
|
||||||
|
impl_slice_bytes!(Vec<u8>);
|
||||||
|
|
||||||
|
impl AsFixedBytes for ::core::hash::Hash {
|
||||||
|
fn as_fixed_bytes(&self) -> &[u8] {
|
||||||
|
self.to_slice()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AsFixedBytes for ::secp::pedersen::RangeProof {
|
||||||
|
fn as_fixed_bytes(&self) -> &[u8] {
|
||||||
|
&self.bytes()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue