From 14db7ee9027597e03daede68c1dd512405561501 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Sun, 20 Sep 2015 15:27:12 -0500 Subject: [PATCH] Fix for rustc RFC 1214; also add missing docs --- src/blockdata/constants.rs | 5 +++++ src/network/constants.rs | 3 +++ src/network/encodable.rs | 4 ++-- src/util/iter.rs | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/blockdata/constants.rs b/src/blockdata/constants.rs index 88d026d..a474afa 100644 --- a/src/blockdata/constants.rs +++ b/src/blockdata/constants.rs @@ -31,10 +31,15 @@ use util::misc::hex_bytes; use util::hash::MerkleRoot; use util::uint::Uint256; +/// The maximum allowable sequence number pub static MAX_SEQUENCE: u32 = 0xFFFFFFFF; +/// How many satoshis are in "one bitcoin" pub static COIN_VALUE: u64 = 100_000_000; +/// How many seconds between blocks we expect on average pub static TARGET_BLOCK_SPACING: u32 = 600; +/// How many blocks between diffchanges pub static DIFFCHANGE_INTERVAL: u32 = 2016; +/// How much time on average should occur between diffchanges pub static DIFFCHANGE_TIMESPAN: u32 = 14 * 24 * 3600; /// In Bitcoind this is insanely described as ~((u256)0 >> 32) diff --git a/src/network/constants.rs b/src/network/constants.rs index 213e27d..5cff16e 100644 --- a/src/network/constants.rs +++ b/src/network/constants.rs @@ -32,8 +32,11 @@ user_enum! { } } +/// Version of the protocol as appearing in network message headers pub const PROTOCOL_VERSION: u32 = 70001; +/// Bitfield of services provided by this node pub const SERVICES: u64 = 0; +/// User agent as it appears in the version message pub const USER_AGENT: &'static str = "bitcoin-rust v0.1"; /// Return the network magic bytes, which should be encoded little-endian diff --git a/src/network/encodable.rs b/src/network/encodable.rs index 1ec6928..cc278ea 100644 --- a/src/network/encodable.rs +++ b/src/network/encodable.rs @@ -37,13 +37,13 @@ use util::hash::Sha256dHash; use network::serialize::{SimpleDecoder, SimpleEncoder}; /// Data which can be encoded in a consensus-consistent way -pub trait ConsensusEncodable { +pub trait ConsensusEncodable : Sized { /// Encode an object with a well-defined format fn consensus_encode(&self, e: &mut S) -> Result<(), S::Error>; } /// Data which can be encoded in a consensus-consistent way -pub trait ConsensusDecodable { +pub trait ConsensusDecodable: Sized { /// Decode an object with a well-defined format fn consensus_decode(d: &mut D) -> Result; } diff --git a/src/util/iter.rs b/src/util/iter.rs index 4be55a4..a7b9e83 100644 --- a/src/util/iter.rs +++ b/src/util/iter.rs @@ -63,7 +63,7 @@ impl Pair { } /// Returns an iterator that returns elements of the original iterator 2 at a time -pub trait Pairable { +pub trait Pairable : Sized { /// Returns an iterator that returns elements of the original iterator 2 at a time fn pair(self) -> Pair; }