dcrd/peer
Dave Collins e052b9cbf2
multi: Remove non-root module replacements.
This modifies all of the modules, with the exception of the root module,
to remove all replacement directives from their go.mod files and update
the requirements and module sums accordingly.

While it is nice to be able to build and test directly from each module
directory and have it pull in the latest untagged changes when
developing, having all of the overrides in each module makes it
infeasible to use the module tools to help maintain the modules and thus
makes it quite difficult to ensure they are all independently accurate
for external consumers.

By maintaining all of the overrides in the root module and invoking all
builds and tests from it, the overrides will apply to ensure the latest
code is being built and tested.

This also modifies the tests script used with in CI to run all of the
tests from the root module accordingly.
2019-02-08 18:01:43 -06:00
..
doc.go multi: Replace btclog with slog. 2018-05-23 14:22:10 -05:00
example_test.go peer: Allow OnVersion callback to reject peer. 2018-06-04 15:59:31 -05:00
export_test.go peer: Refactor peer code into its own package. 2016-05-20 13:58:23 -05:00
go.mod multi: Remove non-root module replacements. 2019-02-08 18:01:43 -06:00
go.sum multi: Remove non-root module replacements. 2019-02-08 18:01:43 -06:00
log.go multi: Replace btclog with slog. 2018-05-23 14:22:10 -05:00
lruinvcache_test.go peer: rename inventorymap to inventorycache 2018-02-13 13:56:50 -06:00
lruinvcache.go peer: rename inventorymap to inventorycache 2018-02-13 13:56:50 -06:00
lrunoncecache_test.go peer: rename noncemap to noncecache 2018-02-13 13:56:50 -06:00
lrunoncecache.go peer: rename noncemap to noncecache 2018-02-13 13:56:50 -06:00
peer_test.go multi: Reset testnet and bump to version 3. 2018-08-08 08:09:32 -05:00
peer.go peer: Provide immediate queue inventory func. 2018-09-10 09:57:51 -05:00
README.md multi: Remove everything to do about bloom filters. 2018-05-01 11:43:32 -05:00

peer

Build Status ISC License GoDoc

Package peer provides a common base for creating and managing bitcoin network peers.

This package has intentionally been designed so it can be used as a standalone package for any projects needing a full featured bitcoin peer base to build on.

Overview

This package builds upon the wire package, which provides the fundamental primitives necessary to speak the bitcoin wire protocol, in order to simplify the process of creating fully functional peers. In essence, it provides a common base for creating concurrent safe fully validating nodes, Simplified Payment Verification (SPV) nodes, proxies, etc.

A quick overview of the major features peer provides are as follows:

  • Provides a basic concurrent safe bitcoin peer for handling bitcoin communications via the peer-to-peer protocol
  • Full duplex reading and writing of bitcoin protocol messages
  • Automatic handling of the initial handshake process including protocol version negotiation
  • Asynchronous message queueing of outbound messages with optional channel for notification when the message is actually sent
  • Flexible peer configuration
    • Caller is responsible for creating outgoing connections and listening for incoming connections so they have flexibility to establish connections as they see fit (proxies, etc)
    • User agent name and version
    • Bitcoin network
    • Service support signalling (full nodes, etc)
    • Maximum supported protocol version
    • Ability to register callbacks for handling bitcoin protocol messages
  • Inventory message batching and send trickling with known inventory detection and avoidance
  • Automatic periodic keep-alive pinging and pong responses
  • Random nonce generation and self connection detection
  • Snapshottable peer statistics such as the total number of bytes read and written, the remote address, user agent, and negotiated protocol version
  • Helper functions pushing addresses, getblocks, getheaders, and reject messages
    • These could all be sent manually via the standard message output function, but the helpers provide additional nice functionality such as duplicate filtering and address randomization
  • Ability to wait for shutdown/disconnect
  • Comprehensive test coverage

Installation and Updating

$ go get -u github.com/decred/dcrd/peer

Examples

  • New Outbound Peer Example
    Demonstrates the basic process for initializing and creating an outbound peer. Peers negotiate by exchanging version and verack messages. For demonstration, a simple handler for the version message is attached to the peer.

License

Package peer is licensed under the copyfree ISC License.