lbcd/peer
Roy Lee e323751218 ci: gofmt with go 1.19
Go 1.19 introduces various updates to gofmt.
2022-08-07 23:40:53 -07:00
..
doc.go ci: gofmt with go 1.19 2022-08-07 23:40:53 -07:00
example_test.go [lbry] rename btcd to lbcd 2022-05-23 23:53:30 -07:00
log.go [lbry] rename btcd to lbcd 2022-05-23 23:53:30 -07:00
peer.go ci: gofmt with go 1.19 2022-08-07 23:40:53 -07:00
peer_test.go [lbry] align port settings between lbcd, lbcctl, and lbcwallet 2022-05-24 00:01:46 -07:00
README.md [lbry] docs: update docs for LBRY 2022-05-24 00:01:46 -07:00

peer

ISC License

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

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