master
go 94 lines 4.85 KB
Raw
1 package config
2
3 import "time"
4
5 const (
6 // DefaultMFSNoFlushLimit is the default limit for consecutive unflushed MFS operations
7 DefaultMFSNoFlushLimit = 256
8
9 // DefaultShutdownTimeout caps how long graceful shutdown is allowed to
10 // take before the daemon force-exits with status 1. Set generously so
11 // it does not change existing kubo behavior in practice but guarantees
12 // Docker / kubernetes infrastructure can never be stuck indefinitely
13 // on a hung FX OnStop hook. Smaller than the 22h DHT reprovide cycle,
14 // so a hung daemon recovers before missing more than one cycle.
15 // Set Internal.ShutdownTimeout to 0 to opt out and wait forever.
16 DefaultShutdownTimeout = 12 * time.Hour
17 )
18
19 type Internal struct {
20 // All marked as omitempty since we are expecting to make changes to all subcomponents of Internal
21 Bitswap *InternalBitswap `json:",omitempty"`
22 UnixFSShardingSizeThreshold *OptionalString `json:",omitempty"` // moved to Import.UnixFSHAMTDirectorySizeThreshold
23 Libp2pForceReachability *OptionalString `json:",omitempty"`
24 BackupBootstrapInterval *OptionalDuration `json:",omitempty"`
25 // MFSNoFlushLimit controls the maximum number of consecutive
26 // MFS operations allowed with --flush=false before requiring a manual flush.
27 // This prevents unbounded memory growth and ensures data consistency.
28 // Set to 0 to disable limiting (old behavior, may cause high memory usage)
29 // This is an EXPERIMENTAL feature and may change or be removed in future releases.
30 // See https://github.com/ipfs/kubo/issues/10842
31 MFSNoFlushLimit *OptionalInteger `json:",omitempty"`
32 // ShutdownTimeout caps how long graceful shutdown of the daemon is
33 // allowed to take. Defaults to DefaultShutdownTimeout. When the
34 // deadline expires the daemon logs which subsystem failed to close and
35 // exits with status 1. Set to 0 to disable the cap and wait forever.
36 ShutdownTimeout *OptionalDuration `json:",omitempty"`
37 }
38
39 type InternalBitswap struct {
40 TaskWorkerCount OptionalInteger
41 EngineBlockstoreWorkerCount OptionalInteger
42 EngineTaskWorkerCount OptionalInteger
43 MaxOutstandingBytesPerPeer OptionalInteger
44 ProviderSearchDelay OptionalDuration
45 ProviderSearchMaxResults OptionalInteger
46 WantHaveReplaceSize OptionalInteger
47 BroadcastControl *BitswapBroadcastControl
48 }
49
50 type BitswapBroadcastControl struct {
51 // EnableEnables or disables broadcast control functionality. Setting this
52 // to false disables broadcast control functionality and restores the
53 // previous broadcast behavior of sending broadcasts to all peers. When
54 // disabled, all other BroadcastControl configuration items are ignored.
55 // Default is [DefaultBroadcastControlEnable].
56 Enable Flag `json:",omitempty"`
57 // MaxPeers sets a hard limit on the number of peers to send broadcasts to.
58 // A value of 0 means no broadcasts are sent. A value of -1 means there is
59 // no limit. Default is [DefaultBroadcastControlMaxPeers].
60 MaxPeers OptionalInteger
61 // LocalPeers enables or disables broadcast control for peers on the local
62 // network. If false, than always broadcast to peers on the local network.
63 // If true, apply broadcast control to local peers. Default is
64 // [DefaultBroadcastControlLocalPeers].
65 LocalPeers Flag `json:",omitempty"`
66 // PeeredPeers enables or disables broadcast reduction for peers configured
67 // for peering. If false, than always broadcast to peers configured for
68 // peering. If true, apply broadcast reduction to peered peers. Default is
69 // [DefaultBroadcastControlPeeredPeers].
70 PeeredPeers Flag `json:",omitempty"`
71 // MaxRandomPeers is the number of peers to broadcast to anyway, even
72 // though broadcast reduction logic has determined that they are not
73 // broadcast targets. Setting this to a non-zero value ensures at least
74 // this number of random peers receives a broadcast. This may be helpful in
75 // cases where peers that are not receiving broadcasts my have wanted
76 // blocks. Default is [DefaultBroadcastControlMaxRandomPeers].
77 MaxRandomPeers OptionalInteger
78 // SendToPendingPeers enables or disables sending broadcasts to any peers
79 // to which there is a pending message to send. When enabled, this sends
80 // broadcasts to many more peers, but does so in a way that does not
81 // increase the number of separate broadcast messages. There is still the
82 // increased cost of the recipients having to process and respond to the
83 // broadcasts. Default is [DefaultBroadcastControlSendToPendingPeers].
84 SendToPendingPeers Flag `json:",omitempty"`
85 }
86
87 const (
88 DefaultBroadcastControlEnable = true // Enabled
89 DefaultBroadcastControlMaxPeers = -1 // Unlimited
90 DefaultBroadcastControlLocalPeers = false // No control of local
91 DefaultBroadcastControlPeeredPeers = false // No control of peered
92 DefaultBroadcastControlMaxRandomPeers = 0 // No randoms
93 DefaultBroadcastControlSendToPendingPeers = false // Disabled
94 )