Release v0.3.0

This commit is contained in:
Manu Herrera
2020-11-09 10:05:29 -03:00
parent 4e9aa7a3c5
commit 8107c4478b
1265 changed files with 440488 additions and 107809 deletions

View File

@@ -24,6 +24,7 @@ import (
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/go-socks/socks"
"github.com/davecgh/go-spew/spew"
"github.com/decred/dcrd/lru"
)
const (
@@ -82,7 +83,7 @@ var (
// sentNonces houses the unique nonces that are generated when pushing
// version messages that are used to detect self connections.
sentNonces = newMruNonceMap(50)
sentNonces = lru.NewCache(50)
// allowSelfConns is only used to allow the tests to bypass the self
// connection detecting and disconnect logic since they intentionally
@@ -450,7 +451,7 @@ type Peer struct {
wireEncoding wire.MessageEncoding
knownInventory *mruInventoryMap
knownInventory lru.Cache
prevGetBlocksMtx sync.Mutex
prevGetBlocksBegin *chainhash.Hash
prevGetBlocksStop *chainhash.Hash
@@ -1626,7 +1627,7 @@ out:
// Don't send inventory that became known after
// the initial check.
if p.knownInventory.Exists(iv) {
if p.knownInventory.Contains(iv) {
continue
}
@@ -1832,7 +1833,7 @@ func (p *Peer) QueueMessageWithEncoding(msg wire.Message, doneChan chan<- struct
func (p *Peer) QueueInventory(invVect *wire.InvVect) {
// Don't add the inventory to the send queue if the peer is already
// known to have it.
if p.knownInventory.Exists(invVect) {
if p.knownInventory.Contains(invVect) {
return
}
@@ -1891,7 +1892,7 @@ func (p *Peer) readRemoteVersionMsg() error {
}
// Detect self connections.
if !allowSelfConns && sentNonces.Exists(msg.Nonce) {
if !allowSelfConns && sentNonces.Contains(msg.Nonce) {
return errors.New("disconnecting peer connected to self")
}
@@ -2097,7 +2098,7 @@ func (p *Peer) negotiateInboundProtocol() error {
return p.readRemoteVerAckMsg()
}
// negotiateOutoundProtocol performs the negotiation protocol for an outbound
// negotiateOutboundProtocol performs the negotiation protocol for an outbound
// peer. The events should occur in the following order, otherwise an error is
// returned:
//
@@ -2224,7 +2225,7 @@ func newPeerBase(origCfg *Config, inbound bool) *Peer {
p := Peer{
inbound: inbound,
wireEncoding: wire.BaseEncoding,
knownInventory: newMruInventoryMap(maxKnownInventory),
knownInventory: lru.NewCache(maxKnownInventory),
stallControl: make(chan stallControlMsg, 1), // nonblocking sync
outputQueue: make(chan outMsg, outputBufferSize),
sendQueue: make(chan outMsg, 1), // nonblocking sync