Move p2p::constants::PROTOCOL_VERSION to p2p module
The `PROTOCOL_VERSION` const is a p2p layer constant. It can live in the `mod.rs` file of the `p2p` module. This is a straight code move, the `PROTOCOL_VERSION` replaces the current re-export.
This commit is contained in:
parent
1bac1fd518
commit
4330722d62
|
@ -42,23 +42,6 @@ use crate::error::impl_std_error;
|
|||
use crate::io;
|
||||
use crate::prelude::{String, ToOwned};
|
||||
|
||||
/// Version of the protocol as appearing in network message headers
|
||||
/// This constant is used to signal to other peers which features you support.
|
||||
/// Increasing it implies that your software also supports every feature prior to this version.
|
||||
/// Doing so without support may lead to you incorrectly banning other peers or other peers banning you.
|
||||
/// These are the features required for each version:
|
||||
/// 70016 - Support receiving `wtxidrelay` message between `version` and `verack` message
|
||||
/// 70015 - Support receiving invalid compact blocks from a peer without banning them
|
||||
/// 70014 - Support compact block messages `sendcmpct`, `cmpctblock`, `getblocktxn` and `blocktxn`
|
||||
/// 70013 - Support `feefilter` message
|
||||
/// 70012 - Support `sendheaders` message and announce new blocks via headers rather than inv
|
||||
/// 70011 - Support NODE_BLOOM service flag and don't support bloom filter messages if it is not set
|
||||
/// 70002 - Support `reject` message
|
||||
/// 70001 - Support bloom filter messages `filterload`, `filterclear` `filteradd`, `merkleblock` and FILTERED_BLOCK inventory type
|
||||
/// 60002 - Support `mempool` message
|
||||
/// 60001 - Support `pong` message and nonce in `ping` message
|
||||
pub const PROTOCOL_VERSION: u32 = 70001;
|
||||
|
||||
/// The cryptocurrency network to act on.
|
||||
#[derive(Copy, PartialEq, Eq, PartialOrd, Ord, Clone, Hash, Debug)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
|
|
|
@ -11,9 +11,8 @@ use hashes::{sha256d, Hash as _};
|
|||
use crate::consensus::encode::{self, Decodable, Encodable};
|
||||
use crate::hash_types::{BlockHash, Txid, Wtxid};
|
||||
use crate::internal_macros::impl_consensus_encoding;
|
||||
use crate::io;
|
||||
use crate::p2p::constants;
|
||||
use crate::prelude::*;
|
||||
use crate::{io, p2p};
|
||||
|
||||
/// An inventory item.
|
||||
#[derive(PartialEq, Eq, Clone, Debug, Copy, Hash, PartialOrd, Ord)]
|
||||
|
@ -128,7 +127,7 @@ pub struct GetHeadersMessage {
|
|||
impl GetBlocksMessage {
|
||||
/// Construct a new `getblocks` message
|
||||
pub fn new(locator_hashes: Vec<BlockHash>, stop_hash: BlockHash) -> GetBlocksMessage {
|
||||
GetBlocksMessage { version: constants::PROTOCOL_VERSION, locator_hashes, stop_hash }
|
||||
GetBlocksMessage { version: p2p::PROTOCOL_VERSION, locator_hashes, stop_hash }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,7 +136,7 @@ impl_consensus_encoding!(GetBlocksMessage, version, locator_hashes, stop_hash);
|
|||
impl GetHeadersMessage {
|
||||
/// Construct a new `getheaders` message
|
||||
pub fn new(locator_hashes: Vec<BlockHash>, stop_hash: BlockHash) -> GetHeadersMessage {
|
||||
GetHeadersMessage { version: constants::PROTOCOL_VERSION, locator_hashes, stop_hash }
|
||||
GetHeadersMessage { version: p2p::PROTOCOL_VERSION, locator_hashes, stop_hash }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,10 +10,10 @@ use hashes::sha256d;
|
|||
|
||||
use crate::consensus::{encode, Decodable, Encodable, ReadExt};
|
||||
use crate::internal_macros::impl_consensus_encoding;
|
||||
use crate::io;
|
||||
use crate::p2p::address::Address;
|
||||
use crate::p2p::constants::{self, ServiceFlags};
|
||||
use crate::p2p::constants::ServiceFlags;
|
||||
use crate::prelude::*;
|
||||
use crate::{io, p2p};
|
||||
|
||||
/// Some simple messages
|
||||
|
||||
|
@ -54,7 +54,7 @@ impl VersionMessage {
|
|||
start_height: i32,
|
||||
) -> VersionMessage {
|
||||
VersionMessage {
|
||||
version: constants::PROTOCOL_VERSION,
|
||||
version: p2p::PROTOCOL_VERSION,
|
||||
services,
|
||||
timestamp,
|
||||
receiver,
|
||||
|
|
|
@ -25,3 +25,20 @@ pub mod message_filter;
|
|||
pub mod message_network;
|
||||
|
||||
pub use self::constants::Magic;
|
||||
|
||||
/// Version of the protocol as appearing in network message headers
|
||||
/// This constant is used to signal to other peers which features you support.
|
||||
/// Increasing it implies that your software also supports every feature prior to this version.
|
||||
/// Doing so without support may lead to you incorrectly banning other peers or other peers banning you.
|
||||
/// These are the features required for each version:
|
||||
/// 70016 - Support receiving `wtxidrelay` message between `version` and `verack` message
|
||||
/// 70015 - Support receiving invalid compact blocks from a peer without banning them
|
||||
/// 70014 - Support compact block messages `sendcmpct`, `cmpctblock`, `getblocktxn` and `blocktxn`
|
||||
/// 70013 - Support `feefilter` message
|
||||
/// 70012 - Support `sendheaders` message and announce new blocks via headers rather than inv
|
||||
/// 70011 - Support NODE_BLOOM service flag and don't support bloom filter messages if it is not set
|
||||
/// 70002 - Support `reject` message
|
||||
/// 70001 - Support bloom filter messages `filterload`, `filterclear` `filteradd`, `merkleblock` and FILTERED_BLOCK inventory type
|
||||
/// 60002 - Support `mempool` message
|
||||
/// 60001 - Support `pong` message and nonce in `ping` message
|
||||
pub const PROTOCOL_VERSION: u32 = 70001;
|
||||
|
|
Loading…
Reference in New Issue