Commit Graph

32 Commits

Author SHA1 Message Date
dskloet
e1b2ceca80 addrmgr: Remove unused param from GetAddress()
addrmgr.GetAddress() had a parameter `class string` originally intended
to support looking up addresses according to some type of filter such as
IPv4, IPv6, and only those which support specific wire.ServiceFlags
(full nodes, nodes that support bloom filters, nodes that support
segwit, etc). But currently the parameter is unused and also has an
inappropriate type `string`.

If it would ever be used, it's easy to add back and should then get an
appropriate type such as something that allows bitflags to be set so
that the caller could request combinations such as peers that support
IPv6, are full nodes, and support bloom filters.
2016-11-21 08:56:46 -06:00
David Hill
807d344fe9 Unassign some TODO's 2016-11-15 17:47:33 -06:00
Dave Collins
915fa6639b
multi: Simplify code per gosimple linter.
This simplifies the code based on the recommendations of the gosimple
lint tool.
2016-11-03 13:00:35 -05:00
Dave Collins
af524fb3e7
multi: Remove unnecessary convs found by unconvert.
This removes all unnecessary typecast conversions as found by the
unconvert linter.
2016-11-03 11:59:38 -05:00
Dave Collins
aa53c14a19
addrmgr/btcd: Updates for staticcheck results.
This makes two modifications based on the results of staticcheck.

The first is to use a simplified zero value for the time in the addrmgr
package tests.

The second is check any errors when opening a directory while attempting
to perform old version upgrades.
2016-11-03 11:29:08 -05:00
Dave Collins
e320330d29
multi: Remove unused code found by deadcode. 2016-11-02 17:37:31 -05:00
David Hill
42a4366ba8 addrmgr: Fix AddressCache to not include nils
allAddr was being allocated with counters instead of the actual size
of the address map.  This led to the possibility of including nils
in the returned slice, which resulted in a panic.
2016-09-26 12:16:40 -05:00
Dave Collins
bd4e64d1d4 chainhash: Abstract hash logic to new package. (#729)
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
2016-08-08 14:04:33 -05:00
Dave Collins
eb882f39f8 multi: Fix several misspellings in the comments.
This commit corrects several typos in the comments found by misspell.
2016-02-25 11:17:12 -06:00
Dave Collins
6e402deb35 Relicense to the btcsuite developers.
This commit relicenses all code in this repository to the btcsuite
developers.
2015-05-01 12:00:56 -05:00
Daniel Krawisz
c0b57def7f Added tests for addrmgr.KnownAddress
Adjusted tests in response to redefinition of KnownAddress.chance
2015-04-21 19:10:39 -05:00
David Hill
2cc85ef428 Reduce fingerprinting.
This change reduces fingerprinting via timestamps in addr messages.
Previously, the last seen time for an address was updated when
certain protocol commands were received.  Now, the last seen time
is set when the peer disconnects if the peer had sent a verack
message and was connected for more than 20 minutes.

This mimics Bitcoin Core commit:
9c2737901b5203f267d21d728019d64b46f1d9f3

Also, add additional sanity checking before updating the peer's
timestamp.  These include:

 - Do not mark a peer as connected if we never received
   a version message.
 - Disconnect a peer for sending a verack before btcd
   sent a version
 - Disconnect a peer for sending multiple verack's
2015-04-14 12:38:41 -04:00
David Hill
0eef96e1c8 addrmgr: Always use a 50% chance between tried and new entries.
This change was suggested as Countermeasure 2 in
Eclipse Attacks on Bitcoin's Peer-to-Peer Network, Ethan
Heilman, Alison Kendler, Aviv Zohar, Sharon Goldberg. ePrint Archive
Report 2015/263. March 2015.

This mimics Bitcoin Core commit c6a63ceeb4956933588995bcf01dc3095aaeb1fc
2015-04-14 12:28:45 -04:00
David Hill
320ecea6a0 addrmgr: Do not bias toward fresh addresses.
This change was suggested as Countermeasure 2 in Eclipse Attacks on
Bitcoin's Peer-to-Peer Network, Ethan Heilman, Alison Kendler, Aviv
Zohar, Sharon Goldberg. ePrint Archive Report 2015/263. March 2015.

This mimics Bitcoin Core commit
f68ba3f67bd500a64fb8932c6b41924ddc31d76f
2015-04-14 11:21:57 -04:00
David Hill
c80c8e7fe9 Scale up addrman.
This change was suggested as Countermeasure 6 in
Eclipse Attacks on Bitcoin’s Peer-to-Peer Network, Ethan
Heilman, Alison Kendler, Aviv Zohar, Sharon Goldberg. ePrint Archive
Report 2015/263. March 2015.

This mimics Bitcoin Core commit 1d21ba2f5ecbf03086d0b65c4c4c80a39a94c2ee
2015-04-06 11:45:57 -04:00
Jimmy Song
f54ffd8c76 Added some unit tests to addrmgr. 2015-03-02 12:28:58 -06:00
Dave Collins
03433dad6a Update btcwire path import paths to new location. 2015-02-05 15:16:39 -06:00
Dave Collins
ee403e2abd Address a few things found by golint. 2015-01-28 09:52:53 -06:00
Dave Collins
f9f4d37976 Update btcd import paths to new location. 2015-01-17 00:48:13 -06:00
Dave Collins
54ccb83025 Update btcwire import paths to new location. 2015-01-16 15:13:21 -06:00
Dave Collins
0e8c3b743d Update btclog import paths to new location. 2015-01-16 11:42:25 -06:00
Dave Collins
d9d7f7ce4d Correct address manager test error print. 2015-01-16 10:14:06 -06:00
David Hill
bc46f8273c Add more reserved IP space to address manager. 2014-12-16 13:02:39 -05:00
Dave Collins
9c0db2f7fd Ensure all tickers are explicitly stopped.
As pointed out in #189, according to the Go documentation, a ticker must
be stopped to release associated resources.  This commit adds a defer call
to stop two tickers there were previously not being stopped as well as
changes two others that were being stopped over to use defer so it's more
consistent.

The other ticker in ScheduleShutdown is replaced and already calls Stop
before replacing it, so it has not been modified.

Closes #189.

ok @jrick
2014-12-03 18:43:31 -06:00
Olaoluwa Osuntokun
b97083f882 Fix some typos throughout repo. 2014-09-08 14:54:52 -05:00
David Hill
8774a77d33 Use Errorf when using formatting directives.
Found by go vet.
2014-08-28 11:49:49 -04:00
David Hill
06d2707744 We only care about the peers.json file... 2014-07-10 19:28:30 -05:00
David Hill
d269887c56 Put mutexes in exported functions. 2014-07-10 19:23:31 -05:00
David Hill
36e8b4c82e organize.
no objections from @davecgh
2014-07-10 19:03:34 -05:00
David Hill
3a45ec1058 Change AddAddressByIP to return an error. 2014-07-09 21:24:06 -04:00
David Hill
6f5a43d6c8 First round of address manager package refactor
These changes are a joint effort between myself and @dajohi.

- Separate IP address range/network code into its own file
- Group all of the RFC range declarations together
- Introduces a new unexported function to simplify the range declarations
- Add comments for all exported functions
- Use consistent variable casing in refactored code
- Add initial doc.go package overview
- Bump serialize interval to 10 minutes
- Correct GroupKey to perform as intended
- Make AddLocalAddress return error instead of just a debug message
- Add tests for AddLocalAddress
- Add tests for GroupKey
- Add tests for GetBestLocalAddress
- Use time.Time to improve readability
- Make address manager code golint clean
- Misc cleanup
- Add test coverage reporting
2014-07-07 09:04:22 -05:00
Dave Collins
62f21d3600 Move address manager to its own package.
This commit does just enough to move the address manager into its own
package.  Since it was not originally written as a package, it will
require a bit of refactoring and cleanup to turn it into a robust
package with a friendly API.
2014-07-06 01:06:38 -05:00