mirror of
https://github.com/FlipsideCrypto/dcrd.git
synced 2026-02-06 10:56:47 +00:00
config: New option --blocksonly
Upstream commit d1e493f4ee.
Since Decred has supported the ability to disable transaction relaying
since the first version, this removes the additional checks which dealt
with only disconnecting peers that were at a high enough protocol
version to always disconnect when peers are announcing transactions when
they were instructed not to.
This commit is contained in:
commit
4e878a85fd
@ -142,6 +142,7 @@ type config struct {
|
||||
AllowOldVotes bool `long:"allowoldvotes" description:"Enable the addition of very old votes to the mempool"`
|
||||
NoPeerBloomFilters bool `long:"nopeerbloomfilters" description:"Disable bloom filtering support."`
|
||||
SigCacheMaxSize uint `long:"sigcachemaxsize" description:"The maximum number of entries in the signature verification cache."`
|
||||
BlocksOnly bool `long:"blocksonly" description:"Do not accept transactions from remote peers."`
|
||||
onionlookup func(string) ([]net.IP, error)
|
||||
lookup func(string) ([]net.IP, error)
|
||||
oniondial func(string, string) (net.Conn, error)
|
||||
|
||||
1
doc.go
1
doc.go
@ -112,6 +112,7 @@ Application Options:
|
||||
--nopeerbloomfilters Disable bloom filtering support.
|
||||
--sigcachemaxsize= The maximum number of entries in the signature
|
||||
verification cache.
|
||||
--blocksonly Do not accept transactions from remote peers.
|
||||
|
||||
Help Options:
|
||||
-h, --help Show this help message
|
||||
|
||||
@ -1629,8 +1629,8 @@ out:
|
||||
}
|
||||
|
||||
default:
|
||||
log.Debugf("Received unhandled message of type %v:",
|
||||
rmsg.Command())
|
||||
log.Debugf("Received unhandled message of type %v "+
|
||||
"from %v", rmsg.Command(), p)
|
||||
}
|
||||
p.stallControl <- stallControlMsg{sccHandlerDone, rmsg}
|
||||
|
||||
|
||||
@ -225,6 +225,17 @@
|
||||
; Limit orphan transaction pool to 1000 transactions.
|
||||
; maxorphantx=1000
|
||||
|
||||
; Do not accept transactions from remote peers.
|
||||
; blocksonly=1
|
||||
|
||||
; ------------------------------------------------------------------------------
|
||||
; Optional Transaction Indexes
|
||||
; ------------------------------------------------------------------------------
|
||||
|
||||
; Build and maintain a full address-based transaction index.
|
||||
; addrindex=1
|
||||
; Delete the entire address index on start up, then exit.
|
||||
; dropaddrindex=0
|
||||
|
||||
; ------------------------------------------------------------------------------
|
||||
; Signature Verification Cache
|
||||
|
||||
34
server.go
34
server.go
@ -565,6 +565,12 @@ func (sp *serverPeer) OnMiningState(p *peer.Peer, msg *wire.MsgMiningState) {
|
||||
// serialize all transactions through a single thread transactions don't rely on
|
||||
// the previous one in a linear fashion like blocks.
|
||||
func (sp *serverPeer) OnTx(p *peer.Peer, msg *wire.MsgTx) {
|
||||
if cfg.BlocksOnly {
|
||||
peerLog.Tracef("Ignoring tx %v from %v - blocksonly enabled",
|
||||
msg.TxSha(), p)
|
||||
return
|
||||
}
|
||||
|
||||
// Add the transaction to the known inventory for the peer.
|
||||
// Convert the raw MsgTx to a dcrutil.Tx which provides some convenience
|
||||
// methods and things such as hash caching.
|
||||
@ -610,7 +616,31 @@ func (sp *serverPeer) OnBlock(p *peer.Peer, msg *wire.MsgBlock, buf []byte) {
|
||||
// accordingly. We pass the message down to blockmanager which will call
|
||||
// QueueMessage with any appropriate responses.
|
||||
func (sp *serverPeer) OnInv(p *peer.Peer, msg *wire.MsgInv) {
|
||||
sp.server.blockManager.QueueInv(msg, sp)
|
||||
if !cfg.BlocksOnly {
|
||||
if len(msg.InvList) > 0 {
|
||||
sp.server.blockManager.QueueInv(msg, sp)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
newInv := wire.NewMsgInvSizeHint(uint(len(msg.InvList)))
|
||||
for _, invVect := range msg.InvList {
|
||||
if invVect.Type == wire.InvTypeTx {
|
||||
peerLog.Infof("Peer %v is announcing transactions -- "+
|
||||
"disconnecting", p)
|
||||
p.Disconnect()
|
||||
return
|
||||
}
|
||||
err := newInv.AddInvVect(invVect)
|
||||
if err != nil {
|
||||
peerLog.Errorf("Failed to add inventory vector: %v", err)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if len(newInv.InvList) > 0 {
|
||||
sp.server.blockManager.QueueInv(newInv, sp)
|
||||
}
|
||||
}
|
||||
|
||||
// OnHeaders is invoked when a peer receives a headers wire message. The
|
||||
@ -1591,7 +1621,7 @@ func newPeerConfig(sp *serverPeer) *peer.Config {
|
||||
UserAgentVersion: userAgentVersion,
|
||||
ChainParams: sp.server.chainParams,
|
||||
Services: sp.server.services,
|
||||
DisableRelayTx: false,
|
||||
DisableRelayTx: cfg.BlocksOnly,
|
||||
ProtocolVersion: wire.BIP0111Version,
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user