mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00

* [NOD-58] Replace lastBlock with selected tip in version message (#210) * [NOD-58] Replace lastBlock with selected tip in version message * [NOD-58] Fix typo in comment * [NOD-58] Add mutex to SelectedTipHash * [NOD-58] Remove redundant comment * [NOD-58] Remove wantStartingHeight from peerStats * [NOD-58] Remove lock from SelectedTipHash * Nod 53 change getheaders message to handle new block locator (#213) * [NOD-53] Change getheaders message to handle the new block locator mechanism * [NOD-53] Use heap in locateHeaders * [NOD-53] Create a constructor for each heap direction * [NOD-57] Check if a node is synced only by timestamps (#214) * [NOD-60] implement isSyncCandidate (#218) * [NOD-60] Implement isSyncCandidate * [NOD-60] Fix typo * [NOD-65] Fix netsync related tests and remove fields optionality from… (#220) * [NOD-65] Fix netsync related tests and remove fields optionality from msgversion * [NOD-65] gofmt rpcserver.go * [NOD-65] add missing test for verRelayTxFalse * [NOD-62] Change getblocks message to handle the new block locator mechanism (#219) * [NOD-62] Change getblocks message to handle the new block locator mechanism * [NOD-62] Add locateBlockNodes function * [NOD-68] Adjust orphan parents requesting for a DAG (#222) * [NOD-68] Adjust orphan parents requesting for a DAG * [NOD-68] add sendInvsFromRequestedQueue and trigger it when requested blocks slice is empty, or immediatly if we're not in sync mode * [NOD-68] Prevent duplicates from entering to state.requestQueue and add wrapping locks to addBlocksToRequestQueue * [NOD-68] Fix Lock -> Unlock in sendInvsFromRequestedQueue * [NOD-74] Starts syncing again when the current sync peer is done (#225) * [NOD-74] Starts syncing again when the current sync peer is done * [NOD-74] Unlock mtx before netsync is restarted * [NOD-74] Fix name isSyncPeerFree -> isWaitingForBlocks * [NOD-75] fixing netsync bugs (#227) * [NOD-74] Starts syncing again when the current sync peer is done * [NOD-74] Unlock mtx before netsync is restarted * [NOD-75] Fixing netsync bugs * [NOD-80] Request block data from block propagation just after you are… (#231) * [NOD-80] Request block data from block propagation just after you are current * [NOD-80] Fix adding to both queues in addInvToRequestQueue * [NOD-81] Start to mine on top of genesis iff all peers selected tip is genesis (#232) * [NOD-81] Start to mine on top of genesis only if all of your peers' selected tip is genesis * [NOD-81] Explain forAllPeers/forAllOutboundPeers shouldContinue behaviour in comments * [NOD-81] Add forAllInboundPeers and add return values for forAllPeers/forAllOutboundPeers/forAllInboundPeers functions * [NOD-16] Add pushSet to the BlockHeap type * [NOD-16] Fixed syntax error
peer
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
Installation and Updating
$ go get -u github.com/daglabs/btcd/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.