github.com/palcoin-project/palcd@v1.0.0/peer/README.md (about)

     1  peer
     2  ====
     3  
     4  [![Build Status](https://github.com/btcsuite/btcd/workflows/Build%20and%20Test/badge.svg)](https://github.com/btcsuite/btcd/actions)
     5  [![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org)
     6  [![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](https://pkg.go.dev/github.com/btcsuite/btcd/peer)
     7  
     8  Package peer provides a common base for creating and managing bitcoin network
     9  peers.
    10  
    11  This package has intentionally been designed so it can be used as a standalone
    12  package for any projects needing a full featured bitcoin peer base to build on.
    13  
    14  ## Overview
    15  
    16  This package builds upon the wire package, which provides the fundamental
    17  primitives necessary to speak the bitcoin wire protocol, in order to simplify
    18  the process of creating fully functional peers.  In essence, it provides a
    19  common base for creating concurrent safe fully validating nodes, Simplified
    20  Payment Verification (SPV) nodes, proxies, etc.
    21  
    22  A quick overview of the major features peer provides are as follows:
    23  
    24   - Provides a basic concurrent safe bitcoin peer for handling bitcoin
    25     communications via the peer-to-peer protocol
    26   - Full duplex reading and writing of bitcoin protocol messages
    27   - Automatic handling of the initial handshake process including protocol
    28     version negotiation
    29   - Asynchronous message queueing of outbound messages with optional channel for
    30     notification when the message is actually sent
    31   - Flexible peer configuration
    32     - Caller is responsible for creating outgoing connections and listening for
    33       incoming connections so they have flexibility to establish connections as
    34       they see fit (proxies, etc)
    35     - User agent name and version
    36     - Bitcoin network
    37     - Service support signalling (full nodes, bloom filters, etc)
    38     - Maximum supported protocol version
    39     - Ability to register callbacks for handling bitcoin protocol messages
    40   - Inventory message batching and send trickling with known inventory detection
    41     and avoidance
    42   - Automatic periodic keep-alive pinging and pong responses
    43   - Random nonce generation and self connection detection
    44   - Proper handling of bloom filter related commands when the caller does not
    45     specify the related flag to signal support
    46     - Disconnects the peer when the protocol version is high enough
    47     - Does not invoke the related callbacks for older protocol versions
    48   - Snapshottable peer statistics such as the total number of bytes read and
    49     written, the remote address, user agent, and negotiated protocol version
    50   - Helper functions pushing addresses, getblocks, getheaders, and reject
    51     messages
    52     - These could all be sent manually via the standard message output function,
    53       but the helpers provide additional nice functionality such as duplicate
    54       filtering and address randomization
    55   - Ability to wait for shutdown/disconnect
    56   - Comprehensive test coverage
    57  
    58  ## Installation and Updating
    59  
    60  ```bash
    61  $ go get -u github.com/btcsuite/btcd/peer
    62  ```
    63  
    64  ## Examples
    65  
    66  * [New Outbound Peer Example](https://pkg.go.dev/github.com/btcsuite/btcd/peer#example-package--NewOutboundPeer)  
    67    Demonstrates the basic process for initializing and creating an outbound peer.
    68    Peers negotiate by exchanging version and verack messages.  For demonstration,
    69    a simple handler for the version message is attached to the peer.
    70  
    71  ## License
    72  
    73  Package peer is licensed under the [copyfree](http://copyfree.org) ISC License.