* [NOD-256] Add error log
* [NOD-256] Add error log
* [NOD-256] Fix typo and comment
* [NOD-256] Remove btclog dir
* [NOD-256] Format project
* [NOD-256] Add error log files
* [NOD-256] Add an option to add a log file to write into to an existing backend logger
* [NOD-256] Get rid of redundant logs initialization
* [NOD-256] rename initLogRotators to initLog
* [NOD-256] Get rid ExampleSignTxOutput and convert ExampleBlockDAG_ProcessBlock to a regular test
* [NOD-256] Show error message if os.Exiting from initLog
* [NOD-241] Implement lower resolution peer rendezvous point discovery
* [NOD-241] Implement lower resolution peer rendezvous point discovery
* [NOD-241] Find exact rendezvous point
* [NOD-241] Find exact rendezvous point
* [NOD-241] Fix tests
* [NOD-241] Remove hash stop from MsgBlockLocator and add tests to MsgBlockLocator and MsgGetBlockLocator
* [NOD-241] Change everywhere startHash to hashStart and change comments
* [NOD-241] Fix locateBlockNodes to stop at hashStop
* [NOD-241] Formatted locatorSummary.
* [NOD-241] Fix node reversal
* [NOD-241] Fix hash start and hash stop order, and don't include startNode in dag.blockLocator
* [NOD-241] rename locateBlockNodes -> getBlueBlocksBetween and add a comment to it
* [NOD-241] change hash start to start hash and hash stop to stop hash
* [NOD-241] Move block locator stuff to a different file
* [NOD-241] Rename msggetblocks.go to msggetblockinvs.go
* [NOD-241] Format project
* [NOD-241] Rename rpcserverSyncManager.LocateHeaders to GetBlueBlocksHeadersBetween
* [NOD-241] Move the logic of finding the highest shared block to OnBlockLocator
* [NOD-241] Rename chainHeight -> nextChainHeight
* [NOD-241] Fix typo in comment
* [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
* [DEV-363] Added testnet seeders
* [DEV-363] Prepare BTCD to work with DNS seeder
* [DEV-363] Finished BTCD part of DNS seeder
* [DEV-363] Reverted protocol changes
* [DEV-363] Reverted protocol changes
* [DEV-363] Reverted protocol changes and fixed tests
* [DEV-363] Added tests and refactored
* [DEV-363] Small refactoring of p2p changes
* [DEV-363] Update NeedMoreAddresses function to take into account full peers + small refactoring
* [DEV-363] Removed IsDNSSeederPeer flag
* [DEV-363] Fixed comment
* [DEV-376] Changed any instance of %v in format strings with a more specific format token
* [DEV-376] Fixed some more wrong formatting strings + removed redundant
cast
* [DEV-376] Added fmt.Sprintf where it was missing
* [DEV-376] use %s for util.Amount, to invoke .String()
* [DEV-376] Some more fixes in format strings
* [DEV-376] fixed mruinvmap_test to expect the correct behaviour
* [DEV-82] break down main to packages
* [DEV-82] separate rpcserver and server
* [DEV-82] Fixed Windows-related code that failed to compile.
* [DEV-82] remove params.go and use only dagconfig.Params
* [DEV-82] fix log.go license
This commit modifies the base peer struct to ascertain when a peer is
able to understand the new witness encoding, and specify the peer’s
supported encoding explicitly before/after the version handshake.
The btclog package has been changed to defining its own logging
interface (rather than seelog's) and provides a default implementation
for callers to use.
There are two primary advantages to the new logger implementation.
First, all log messages are created before the call returns. Compared
to seelog, this prevents data races when mutable variables are logged.
Second, the new logger does not implement any kind of artifical rate
limiting (what seelog refers to as "adaptive logging"). Log messages
are outputted as soon as possible and the application will appear to
perform much better when watching standard output.
Because log rotation is not a feature of the btclog logging
implementation, it is handled by the main package by importing a file
rotation package that provides an io.Reader interface for creating
output to a rotating file output. The rotator has been configured
with the same defaults that btcd previously used in the seelog config
(10MB file limits with maximum of 3 rolls) but now compresses newly
created roll files. Due to the high compressibility of log text, the
compressed files typically reduce to around 15-30% of the original
10MB file.
This is mostly a backport of some of the same modifications made in
Decred along with a few additional things cleaned up. In particular,
this updates the code to make use of the new chainhash package.
Also, since this required API changes anyways and the hash algorithm is
no longer tied specifically to SHA, all other functions throughout the
code base which had "Sha" in their name have been changed to Hash so
they are not incorrectly implying the hash algorithm.
The following is an overview of the changes:
- Remove the wire.ShaHash type
- Update all references to wire.ShaHash to the new chainhash.Hash type
- Rename the following functions and update all references:
- wire.BlockHeader.BlockSha -> BlockHash
- wire.MsgBlock.BlockSha -> BlockHash
- wire.MsgBlock.TxShas -> TxHashes
- wire.MsgTx.TxSha -> TxHash
- blockchain.ShaHashToBig -> HashToBig
- peer.ShaFunc -> peer.HashFunc
- Rename all variables that included sha in their name to include hash
instead
- Update for function name changes in other dependent packages such as
btcutil
- Update copyright dates on all modified files
- Update glide.lock file to use the required version of btcutil
This commit introduces package peer which contains peer related features
refactored from peer.go.
The following is an overview of the features the package provides:
- 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
- Automatic periodic keep-alive pinging and pong responses
- Asynchronous message queueing of outbound messages with optional
channel for notification when the message is actually sent
- Inventory message batching and send trickling with known inventory
detection and avoidance
- Ability to wait for shutdown/disconnect
- 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
- 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 for 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
- Full documentation with example usage
- Test coverage
In addition to the addition of the new package, btcd has been refactored
to make use of the new package by extending the basic peer it provides to
work with the blockmanager and server to act as a full node. The
following is a broad overview of the changes to integrate the package:
- The server is responsible for all connection management including
persistent peers and banning
- Callbacks for all messages that are required to implement a full node
are registered
- Logic necessary to serve data and behave as a full node is now in the
callback registered with the peer
Finally, the following peer-related things have been improved as a part
of this refactor:
- Don't log or send reject message due to peer disconnects
- Remove trace logs that aren't particularly helpful
- Finish an old TODO to switch the queue WaitGroup over to a channel
- Improve various comments and fix some code consistency cases
- Improve a few logging bits
- Implement a most-recently-used nonce tracking for detecting self
connections and generate a unique nonce for each peer