[][src]Crate networking

This Library provides

  1. a low level implementation of the Bitcoin Wire Protocol (the Message struct combined with BitcoinCodec). (✅ Completed)
  2. a high level system encapsulating 'the rest of the network' as a tower::Service. (🟨 Work in Progress)

Overview

Following Zcash Zebra, we intend to build a stateful Request/Response protocol on top of the existing Wire Protocol and encapsulate the Bitcoin Network into a single service (or small collection of Services). To obtain block and transaction information, a caller (in our case, warpd) simply passes the relevant Service a high-level Request object specifying the information to be fetched (i.e. Blocks, Headers, etc.), and the Services automatically load balance these requests across available peers. Work in this direction in ongoing. For now, users of the library can use the BitcoinCodec to easily turn any TcpStream into a stream of Bitcoin Messages.

Structs

BitcoinCodec

A Codec converting a raw TcpStream into a Sink + Stream of Bitcoin Wire Protocol Messages.

MessageHeader

A Bitcoin Wire Protocol Message Header.

Peer

A tower::Service representing an individual peer.

Enums

Command

A shorthand way of referring to a type of Message. A Command is a single byte, while a Message is about 90 bytes.

Message

An enumeration of all Bitcoin Wire Protocol messages, (i.e. GetHeaders, Version, Verack).

NetworkRequest

NetworkRequest provides the inbound interface to the high level 'the rest of the network' abstraction.

NetworkResponse

NetworkResponse provides the possible responses of the 'rest of the network' abstraction to a 'NetworkRequest'

PeerError

An enumeration of errors that a Peer connection can encounter, including malicious behavior.