This updates all remaining cases of unwrapped errors in fmt.Errorf calls
to wrap the underlying errors with the %w format verb to ensure they
work nicely with errors.Is and errors.As.
This updates the addrmgr module dependencies and serves as a base for
addrmgr/v2.0.2.
The updated direct dependencies in this commit are as follows:
- github.com/decred/dcrd/chaincfg/chainhash@v1.0.4
- github.com/decred/dcrd/wire@v1.6.0
The updated indirect dependencies in this commit are as follows:
- github.com/decred/dcrd/crypto/blake256@v1.0.1
- github.com/klauspost/cpuid/v2@v2.0.9
- lukechampine.com/blake3 v1.2.1
The full list of updated direct and indirect dependencies since the
previous addrmgr/v2.0.1 release are the same as above.
Finally, all modules in the repository are tidied to ensure they are
updated to use the latest versions hoisted forward as a result.
This updates the (*KnownAddress).chance method in the following ways:
1. Apply a lower limit to the return value. Using 0.01 as this minimum
prevents tiny chance values from causing excessive iterations in
(*AddrManager).GetAddress, currently the only caller.
2. Replace an inefficient loop with a single math.Pow.
These changes are mitigations to excessive CPU use in the GetAddress
method that manifest when the number of attempts for a KnownAddress
becomes large. However, this method and much of addrmgr should be
rewritten in the future since there are some ad hoc and questionable
approaches to candidate address selection.
This adds a missing break statement to the range over the map of
addresses used to select a random entry from the map. Previously
the loop would continue needlessly until the entire map was traversed.
This is a minor optimization.
This modifies the entire repository to use the new formatting of doc
comments in the upcoming Go 1.19 release.
The primary motivating factors for this are:
- Builds check that files are formatted per gofmt and that will no
longer be true as of Go 1.19 without these changes
- Separating all the updates into a single commit ensures these
documentation only formatting changes do not clutter up diffs that
actually change code
For the most part, the changes are just the automated changes suggested
by the Go 1.19 version of gofmt, but there are also a few cases where
the comments were reworded a bit to play nicely with the new formatting
requirements.
For example, the new version of gofmt reformats and collapses nested
lists where as the existing version does not. Thus, instances of nested
lists have been changed to either eliminate them or use mixed markers
which produce expect results.
This bumps the go directive for all of the modules provided by the
repository to 1.17 which will allow the new module graph pruning and
lazy loading capabilities introduced in Go 1.17 to be used once the
updated modules are released.
This means that, as described by the documentation, the go.mod files for
each module now include a separate require block that includes all of
the indirect dependencies
The directory created by `T.TempDir` is automatically removed when the
test and all its subtests complete.
This commit also refactor several cleanup logic by using `t.Cleanup`
instead of `defer`.
Reference: https://pkg.go.dev/testing#T.TempDir
Reference: https://pkg.go.dev/testing#T.Cleanup
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This updates the addrmgr module dependencies, the copyright year in the
files modified since the previous release, and serves as a base for
addrmgr/v2.0.0.
The updated direct dependencies in this commit are as follows:
- github.com/decred/dcrd/chaincfg/chainhash@v1.0.3
- github.com/decred/dcrd/wire@v1.5.0
- github.com/decred/slog@v1.2.0
The full list of updated direct dependencies since the previous
addrmgr/v1.2.0 release are the same as above.
Finally, all modules in the repository are tidied to ensure they are
updated to use the latest versions hoisted forward as a result.
This change removes the wire NetAddress type as a dependency of the address
manager module by introducing a new NetAddress type owned by the address
manager, in preparation for upcoming changes to the wire protocol.
- Introduce a new NetAddress type in the address manager.
- Modify KnownAddress struct to use address manager NetAddress.
- Replace DeserializeNetAddress with newNetAddressFromString.
This commit removes unnecessary tests cases around the test helper
addAddressByIP. Since the values passed to this method are always
valid, there is no need for the error handling around it since that
results in code that serves to test a test helper.
This change increases test coverage within the address manager in
addition to improving comments throughout related code.
- Add tests for method ValidatePeerNa.
- Add tests for method HostToNetAddress.
- Add additional tests for methods Connected, Attempt, and Good.
- Improve coverage around local address handling.
- Improve coverage for internal behavior between tried and new buckets.
This removes the deprecated functions along with the additional code and
tests which are no longer necessary as a result of removing the
functions.
The following is a list of exported types and functions removed along
with what they were replaced by:
- DisableLog -> UseLogger(slog.Disabled)
- FetchLocalAddresses -> LocalAddresses
- IsPeerNaValid -> ValidatePeerNa
Upcoming changes constitute breaking public API changes to the addrmgr
module, therefore, this follows the process for introducing major API
breaks which consists of:
- Bump the major version in the go.mod of the affected module if not
already done since the last release tag
- Add a replacement to the go.mod in the main module if not already done
since the last release tag
- Update all imports in the repo to use the new major version as
necessary
- Make necessary modifications to allow all other modules to use the new
version in the same commit
- Repeat the process for any other modules that require a new major as a
result of consuming the new major(s)
This updates the addrmgr module dependencies, the copyright year in the
files modified since the previous release, and serves as a base for
addrmgr/v1.2.0.
The updated direct dependencies in this commit are as follows:
- github.com/decred/dcrd/wire@v1.4.0
- github.com/decred/slog@v1.1.0
The full list of updated direct dependencies since the previous
addrmgr/v1.1.0 release are as follows:
- github.com/decred/dcrd/wire@v1.4.0
- github.com/decred/slog@v1.1.0
This properly associates ports applicable to discovered
IPs based on the listeners specified and the network
address type of the discovered host. Inbound peers
can now corroborate valid sugmissions from outbound
peer
Submissions are now bounded, address discovery also
accounts for setups using NAT.
This updates the addrmgr module dependencies and serves as a base for
addrmgr/v1.1.0.
The updated direct dependencies in this commit are as follows:
- github.com/decred/dcrd/chaincfg/chainhash@v1.0.2
- github.com/decred/dcrd/wire@v1.3.0
The full list of updated direct dependencies since the previous
addrmgr/v1.0.2 release are as follows:
- github.com/decred/dcrd/chaincfg/chainhash@v1.0.2
- github.com/decred/dcrd/wire@v1.3.0
This discovers the network address(es) of the daemon
through connected outbound peers. The address(es)
discovered are advertised to subsequent connecting peers.
This adds the go 1.11 directive to all of the modules in order to
clearly mark they build and work with that version. Go 1.12 modified
the tools such that tidy will automatically add the new version to
modules that do not already have a directive and that would prevent
builds on Go 1.11 through Go 1.11.3 which is not desirable.
This modifies all of the modules, with the exception of the root module,
to remove all replacement directives from their go.mod files and update
the requirements and module sums accordingly.
While it is nice to be able to build and test directly from each module
directory and have it pull in the latest untagged changes when
developing, having all of the overrides in each module makes it
infeasible to use the module tools to help maintain the modules and thus
makes it quite difficult to ensure they are all independently accurate
for external consumers.
By maintaining all of the overrides in the root module and invoking all
builds and tests from it, the overrides will apply to ensure the latest
code is being built and tested.
This also modifies the tests script used with in CI to run all of the
tests from the root module accordingly.
This bumps the various module versions as follows:
- github.com/decred/dcrd/addrmgr@v1.0.2
- github.com/decred/dcrd/wire@v1.1.0
- github.com/decred/dcrd/chaincfg@v1.1.1
- github.com/decred/dcrd/connmgr@v1.0.1
- github.com/decred/dcrd/dcrutil@v1.1.1
- github.com/decred/dcrd/database@v1.0.1
- github.com/decred/dcrd/hdkeychain@v1.1.0
- github.com/decred/dcrd/txscript@v1.0.1
- github.com/decred/dcrd/blockchain/stake@v1.0.1
- github.com/decred/dcrd/gcs@v1.0.1
- github.com/decred/dcrd/blockchain@v1.0.1
- github.com/decred/dcrd/mining@v1.0.1
- github.com/decred/dcrd/mempool@v1.0.1
- github.com/decred/dcrd/peer@v1.0.1
- github.com/decred/dcrd/rpcclient@v1.0.1
It also updates all of the dependencies for every module accordingly and
adds a few missing overrides for transitive dependencies.
This further refines the modules to add the following new modules
instead of depending on the entire dcrd module:
- github.com/decred/dcrd/dcrjson@v1.0.0
- github.com/decred/dcrd/blockchain@v1.0.0
- github.com/decred/dcrd/blockchain/stake@v1.0.0
- github.com/decred/dcrd/gcs@v1.0.0
- github.com/decred/dcrd/mining@v1.0.0
- github.com/decred/dcrd/mempool@v1.0.0
- github.com/decred/dcrd/peer@v1.0.0
- github.com/decred/dcrd/rpcclient@v1.0.0
Also, it ensures modules that rely on other modules within the repo are
provided replacements to the latest repo code to ensure builds against
master and continuous integration use the latest code.
- github.com/decred/dcrd/addrmgr
- github.com/decred/dcrd/blockchain
- github.com/decred/dcrd/blockchain/stake
- github.com/decred/dcrd/chaincfg
- github.com/decred/dcrd/connmgr
- github.com/decred/dcrd/database
- github.com/decred/dcrd/dcrec/secp256k1
- github.com/decred/dcrd/dcrjson
- github.com/decred/dcrd/dcrutil
- github.com/decred/dcrd/gcs
- github.com/decred/dcrd/hdkeychain
- github.com/decred/dcrd/mempool
- github.com/decred/dcrd/mining
- github.com/decred/dcrd/peer
- github.com/decred/dcrd/rpcclient
- github.com/decred/dcrd/txscript
- github.com/decred/dcrd/wire
This exposes a new method named SetServices to the address manager which
can be used to update the services for a known address. This will be
useful to keep known services up to date.
This modifies the savePeers function in the addrmgr package to lock the
mutex before checking if saving is needed because the flag is accessed
from multiple goroutines.
Now that wire has been defined, update the addrmgr module to only depend
on it instead of the entire dcrd module. Also, since there is no longer
a dep on the entire dcrd module to pick it up transitively, add the slog
dep as well.
This adds module support for the versioned go toolchain. In particular,
the following packages are defined as modules:
* addrmgr
* blockchain
* certgen
* chaincfg
* connmgr
* database
* dcrjson
* dcrutil
* gcs
* hdkeychain
* mempool
* mining
* peer
* rpcclient
* txscript
* wire
It does not update the travis build environment or README since it is
experimental at this point.
This modifies all packages within the repository to the use the Decred
fork of btclog which has been renamed to slog and updates the dependency
files accordingly.
Currently the peers file is (re-)written every ten minutes no matter
what.
Keep track of changes to the address manager state and write the peers
file only if something changed.