Split parts of message.rs into constants.rs, types.rs
This commit is contained in:
parent
eeb0ab7c43
commit
1d0517fe56
|
@ -0,0 +1,6 @@
|
||||||
|
//! Definitions of constants.
|
||||||
|
|
||||||
|
use crate::types::*;
|
||||||
|
|
||||||
|
/// The Zcash version used on mainnet.
|
||||||
|
pub const ZCASH_VERSION: Version = Version(170_007);
|
|
@ -3,3 +3,5 @@
|
||||||
#![deny(missing_docs)]
|
#![deny(missing_docs)]
|
||||||
|
|
||||||
pub mod message;
|
pub mod message;
|
||||||
|
pub mod types;
|
||||||
|
mod constants;
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::net::SocketAddr;
|
||||||
|
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
|
|
||||||
use zebra_chain;
|
use crate::types::*;
|
||||||
|
|
||||||
/// A Bitcoin-like network message for the Zcash protocol.
|
/// A Bitcoin-like network message for the Zcash protocol.
|
||||||
///
|
///
|
||||||
|
@ -242,26 +242,10 @@ pub enum Message {
|
||||||
// Q: how do we want to implement serialization, exactly? do we want to have
|
// Q: how do we want to implement serialization, exactly? do we want to have
|
||||||
// something generic over stdlib Read and Write traits, or over async versions
|
// something generic over stdlib Read and Write traits, or over async versions
|
||||||
// of those traits?
|
// of those traits?
|
||||||
|
//
|
||||||
/// A protocol version magic number.
|
// Note: because of the way the message structure is defined (checksum comes
|
||||||
pub struct Version(pub u32);
|
// first) we can't write the message headers before collecting the whole body
|
||||||
|
// into a buffer
|
||||||
/// Bitfield of features to be enabled for this connection.
|
|
||||||
// Tower provides utilities for service discovery, so this might go
|
|
||||||
// away in the future in favor of that.
|
|
||||||
pub struct Services(pub u64);
|
|
||||||
|
|
||||||
/// A network address but with some extra flavor.
|
|
||||||
///
|
|
||||||
/// When a network address is needed somewhere, this structure is
|
|
||||||
/// used. Network addresses are not prefixed with a timestamp in the
|
|
||||||
/// version message.
|
|
||||||
///
|
|
||||||
/// [Bitcoin reference](https://en.bitcoin.it/wiki/Protocol_documentation#Network_address)
|
|
||||||
pub struct NetworkAddress(pub Services, pub SocketAddr);
|
|
||||||
|
|
||||||
/// A nonce used in the networking layer to identify messages.
|
|
||||||
pub struct Nonce(pub u64);
|
|
||||||
|
|
||||||
/// Reject Reason CCodes
|
/// Reject Reason CCodes
|
||||||
///
|
///
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
//! Newtype wrappers assigning semantic meaning to primitive types.
|
||||||
|
|
||||||
|
use std::net::SocketAddr;
|
||||||
|
|
||||||
|
/// A protocol version magic number.
|
||||||
|
pub struct Version(pub u32);
|
||||||
|
|
||||||
|
/// Bitfield of features to be enabled for this connection.
|
||||||
|
// Tower provides utilities for service discovery, so this might go
|
||||||
|
// away in the future in favor of that.
|
||||||
|
pub struct Services(pub u64);
|
||||||
|
|
||||||
|
/// A nonce used in the networking layer to identify messages.
|
||||||
|
pub struct Nonce(pub u64);
|
||||||
|
|
||||||
|
/// A network address but with some extra flavor.
|
||||||
|
///
|
||||||
|
/// When a network address is needed somewhere, this structure is
|
||||||
|
/// used. Network addresses are not prefixed with a timestamp in the
|
||||||
|
/// version message.
|
||||||
|
///
|
||||||
|
/// [Bitcoin reference](https://en.bitcoin.it/wiki/Protocol_documentation#Network_address)
|
||||||
|
// XXX this doesn't quite fit here
|
||||||
|
pub struct NetworkAddress(pub Services, pub SocketAddr);
|
Loading…
Reference in New Issue