mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-11-24 06:25:55 +00:00
Add DNSSEEDER environment flag in order to ignore blocks and transactions
This commit is contained in:
parent
6c774c966b
commit
5ae0dfdf50
@ -3,6 +3,8 @@ package common
|
|||||||
import (
|
import (
|
||||||
peerpkg "github.com/kaspanet/kaspad/app/protocol/peer"
|
peerpkg "github.com/kaspanet/kaspad/app/protocol/peer"
|
||||||
routerpkg "github.com/kaspanet/kaspad/infrastructure/network/netadapter/router"
|
routerpkg "github.com/kaspanet/kaspad/infrastructure/network/netadapter/router"
|
||||||
|
"os"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@ -25,3 +27,18 @@ type Flow struct {
|
|||||||
|
|
||||||
// FlowInitializeFunc is a function that is used in order to initialize a flow
|
// FlowInitializeFunc is a function that is used in order to initialize a flow
|
||||||
type FlowInitializeFunc func(route *routerpkg.Route, peer *peerpkg.Peer) error
|
type FlowInitializeFunc func(route *routerpkg.Route, peer *peerpkg.Peer) error
|
||||||
|
|
||||||
|
var isDNSSeeder bool
|
||||||
|
var isDNSSeederOnce sync.Once
|
||||||
|
|
||||||
|
// IsDNSSeeder returns whether this node supports a DNS seeder. If this is the case, the node
|
||||||
|
// doesn't need to actually stay synced, and is mainly used for scanning the p2p network.
|
||||||
|
func IsDNSSeeder() bool {
|
||||||
|
isDNSSeederOnce.Do(func() {
|
||||||
|
isDNSSeederEnv := os.Getenv("DNSSEEDER")
|
||||||
|
if isDNSSeederEnv != "" {
|
||||||
|
isDNSSeeder = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return isDNSSeeder
|
||||||
|
}
|
||||||
|
|||||||
@ -77,6 +77,11 @@ func (flow *handleRelayInvsFlow) start() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if common.IsDNSSeeder() {
|
||||||
|
log.Debugf("IsDNSSeeder=true so skipping block inv")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
log.Debugf("Got relay inv for block %s", inv.Hash)
|
log.Debugf("Got relay inv for block %s", inv.Hash)
|
||||||
|
|
||||||
blockInfo, err := flow.Domain().Consensus().GetBlockInfo(inv.Hash)
|
blockInfo, err := flow.Domain().Consensus().GetBlockInfo(inv.Hash)
|
||||||
|
|||||||
@ -50,6 +50,11 @@ func (flow *handleRelayedTransactionsFlow) start() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if common.IsDNSSeeder() {
|
||||||
|
log.Debugf("IsDNSSeeder=true so skipping tx inv")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
isNearlySynced, err := flow.IsNearlySynced()
|
isNearlySynced, err := flow.IsNearlySynced()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
9
app/protocol/flows/v5/transactionrelay/log.go
Normal file
9
app/protocol/flows/v5/transactionrelay/log.go
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package transactionrelay
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/kaspanet/kaspad/infrastructure/logger"
|
||||||
|
"github.com/kaspanet/kaspad/util/panics"
|
||||||
|
)
|
||||||
|
|
||||||
|
var log = logger.RegisterSubSystem("TXRL")
|
||||||
|
var spawn = panics.GoroutineWrapperFunc(log)
|
||||||
Loading…
x
Reference in New Issue
Block a user