Skip to content

Commit

Permalink
fix:optimize SnapTimeout
Browse files Browse the repository at this point in the history
  • Loading branch information
lochjin committed Dec 12, 2024
1 parent 828454b commit a9bcdf4
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ type Config struct {
// TODO: It will soon be discarded in the near future
DevSnapSync bool `long:"devsnapsync" description:"Enable snap sync for P2P that only exist in development mode"`

SnapTimeout int `long:"snaptimeout" description:"During the IBD phase, if no peer node with snap-sync service enabled is found after the timeout (seconds), the node will switch to using the normal sync method."`
NoSnapSyncPeerTimeout int `long:"nosnapsyncpeertimeout" description:"During the IBD phase, if no peer node with snap-sync service enabled is found after the timeout (seconds), the node will switch to using the normal sync method."`
}

func (c *Config) GetMinningAddrs() []types.Address {
Expand Down
2 changes: 1 addition & 1 deletion p2p/synch/snapsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (ps *PeerSync) startSnapSync() bool {
return false
}
if !isValidSnapPeer(bestPeer) {
snapPeer, change := ps.getSnapSyncPeer(ps.sy.p2p.Consensus().Config().SnapTimeout)
snapPeer, change := ps.getSnapSyncPeer(ps.sy.p2p.Consensus().Config().NoSnapSyncPeerTimeout)
if snapPeer == nil {
if change {
return false
Expand Down
68 changes: 34 additions & 34 deletions services/common/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,47 +652,47 @@ var (
Destination: &cfg.GenerateNoDevGap,
},
&cli.IntFlag{
Name: "snaptimeout",
Name: "nosnapsyncpeertimeout",
Usage: "During the IBD phase, if no peer node with snap-sync service enabled is found after the timeout (seconds), the node will switch to using the normal sync method.",
Destination: &cfg.SnapTimeout,
Destination: &cfg.NoSnapSyncPeerTimeout,
},
}
)

func DefaultConfig(homeDir string) *config.Config {
cfg := &config.Config{
HomeDir: defaultHomeDir,
ConfigFile: defaultConfigFile,
DebugLevel: defaultLogLevel,
DebugPrintOrigins: defaultDebugPrintOrigins,
DataDir: defaultDataDir,
LogDir: defaultLogDir,
DbType: defaultDbType,
RPCKey: defaultRPCKeyFile,
RPCCert: defaultRPCCertFile,
RPCMaxClients: defaultMaxRPCClients,
RPCMaxWebsockets: defaultMaxRPCWebsockets,
RPCMaxConcurrentReqs: defaultMaxRPCConcurrentReqs,
Generate: defaultGenerate,
MaxPeers: defaultMaxPeers,
MinTxFee: defaultMinRelayTxFee,
BlockMinSize: defaultBlockMinSize,
BlockMaxSize: defaultBlockMaxSize,
SigCacheMaxSize: defaultSigCacheMaxSize,
Banning: true,
MaxInbound: defaultMaxInboundPeersPerHost,
InvalidTxIndex: defaultInvalidTxIndex,
TxHashIndex: defaultTxhashIndex,
NTP: false,
MempoolExpiry: defaultMempoolExpiry,
AcceptNonStd: true,
RPCUser: defaultRPCUser,
RPCPass: defaultRPCPass,
ObsoleteHeight: defaultObsoleteHeight,
SubmitNoSynced: false,
DevNextGDB: true,
GBTTimeOut: defaultGBTTimeout,
SnapTimeout: defaultSnapTimeout,
HomeDir: defaultHomeDir,
ConfigFile: defaultConfigFile,
DebugLevel: defaultLogLevel,
DebugPrintOrigins: defaultDebugPrintOrigins,
DataDir: defaultDataDir,
LogDir: defaultLogDir,
DbType: defaultDbType,
RPCKey: defaultRPCKeyFile,
RPCCert: defaultRPCCertFile,
RPCMaxClients: defaultMaxRPCClients,
RPCMaxWebsockets: defaultMaxRPCWebsockets,
RPCMaxConcurrentReqs: defaultMaxRPCConcurrentReqs,
Generate: defaultGenerate,
MaxPeers: defaultMaxPeers,
MinTxFee: defaultMinRelayTxFee,
BlockMinSize: defaultBlockMinSize,
BlockMaxSize: defaultBlockMaxSize,
SigCacheMaxSize: defaultSigCacheMaxSize,
Banning: true,
MaxInbound: defaultMaxInboundPeersPerHost,
InvalidTxIndex: defaultInvalidTxIndex,
TxHashIndex: defaultTxhashIndex,
NTP: false,
MempoolExpiry: defaultMempoolExpiry,
AcceptNonStd: true,
RPCUser: defaultRPCUser,
RPCPass: defaultRPCPass,
ObsoleteHeight: defaultObsoleteHeight,
SubmitNoSynced: false,
DevNextGDB: true,
GBTTimeOut: defaultGBTTimeout,
NoSnapSyncPeerTimeout: defaultSnapTimeout,
}
if len(homeDir) > 0 {
hd, err := filepath.Abs(homeDir)
Expand Down

0 comments on commit a9bcdf4

Please sign in to comment.