dcrd/peer
Dave Collins 756eff2fee peer: Refactor peer code into its own package.
Contains the following upstream commits:

- 00bddf7540
- 250228c32f
- f1bd2f8d6e
- cbbe3a8bbe
- aa03d68e1e

In addition to the normal required changes for syncing, the following
changes have been made in order to facilitate integration of the new
package into Decred:

- Removed check in PushRejectMsg against protocol version since all
  peers since the initial version support it
- Fixed leaked timer in `syncMiningStateAfterSync` function
- Add the Decred-specific OnGetMiningState and OnMiningState handlers to
  the new peer package
- Add handler for the new mining state messages to the 'serverPeer' type
  and register them
- Use the new constant for wire.InitialProtocolVersion in the reject
  message instead of hard coded number
- Remove logic specific to the regression network since Decred does not
  have it
2016-05-20 13:58:23 -05:00
..
doc.go peer: Refactor peer code into its own package. 2016-05-20 13:58:23 -05:00
example_test.go peer: Refactor peer code into its own package. 2016-05-20 13:58:23 -05:00
export_test.go peer: Refactor peer code into its own package. 2016-05-20 13:58:23 -05:00
log_test.go peer: Refactor peer code into its own package. 2016-05-20 13:58:23 -05:00
log.go peer: Refactor peer code into its own package. 2016-05-20 13:58:23 -05:00
mruinvmap_test.go peer: Refactor peer code into its own package. 2016-05-20 13:58:23 -05:00
mruinvmap.go peer: Refactor peer code into its own package. 2016-05-20 13:58:23 -05:00
mrunoncemap_test.go peer: Refactor peer code into its own package. 2016-05-20 13:58:23 -05:00
mrunoncemap.go peer: Refactor peer code into its own package. 2016-05-20 13:58:23 -05:00
peer_test.go peer: Refactor peer code into its own package. 2016-05-20 13:58:23 -05:00
peer.go peer: Refactor peer code into its own package. 2016-05-20 13:58:23 -05:00
README.md peer: Improve documentation. 2015-10-23 01:17:12 -05:00

peer

[Build Status] (https://travis-ci.org/btcsuite/btcd) ![ISC License] (http://img.shields.io/badge/license-ISC-blue.svg)

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, bloom filters, 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
  • Proper handling of bloom filter related commands when the caller does not specify the related flag to signal support
    • Disconnects the peer when the protocol version is high enough
    • Does not invoke the related callbacks for older protocol versions
  • 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

Documentation

[GoDoc] (http://godoc.org/github.com/btcsuite/btcd/peer)

Full go doc style documentation for the project can be viewed online without installing this package by using the GoDoc site here: http://godoc.org/github.com/btcsuite/btcd/peer

You can also view the documentation locally once the package is installed with the godoc tool by running godoc -http=":6060" and pointing your browser to http://localhost:6060/pkg/github.com/btcsuite/btcd/peer

Installation and Updating

$ go get -u github.com/btcsuite/btcd/peer

Examples

License

Package peer is licensed under the copyfree ISC License.