MCPcopy Create free account
hub / github.com/CPChain/chain / sanitize

Method sanitize

core/tx_pool.go:181–223  ·  view source on GitHub ↗

sanitize checks the provided user configurations and changes anything that's unreasonable or unworkable.

()

Source from the content-addressed store, hash-verified

179// sanitize checks the provided user configurations and changes anything that's
180// unreasonable or unworkable.
181func (config *TxPoolConfig) sanitize() TxPoolConfig {
182 conf := *config
183 if conf.Rejournal < time.Second {
184 log.Warn("Sanitizing invalid txpool journal time", "provided", conf.Rejournal, "updated", time.Second)
185 conf.Rejournal = time.Second
186 }
187 if conf.PriceLimit < 1 {
188 log.Warn("Sanitizing invalid txpool price limit", "provided", conf.PriceLimit, "updated", DefaultTxPoolConfig.PriceLimit)
189 conf.PriceLimit = DefaultTxPoolConfig.PriceLimit
190 }
191 if conf.PriceBump < 1 {
192 log.Warn("Sanitizing invalid txpool price bump", "provided", conf.PriceBump, "updated", DefaultTxPoolConfig.PriceBump)
193 conf.PriceBump = DefaultTxPoolConfig.PriceBump
194 }
195 if conf.MaxTxMapSize < DefaultTxPoolConfig.MaxTxMapSize {
196 log.Warn("Sanitizing invalid txpool map size ", "provided", conf.MaxTxMapSize, "updated", DefaultTxPoolConfig.MaxTxMapSize)
197 conf.MaxTxMapSize = DefaultTxPoolConfig.MaxTxMapSize
198 }
199
200 // cf. https://github.com/ethereum/go-ethereum/pull/17210/files
201 if conf.AccountSlots < 1 {
202 log.Warn("Sanitizing invalid txpool account slots", "provided", conf.AccountSlots, "updated", DefaultTxPoolConfig.AccountSlots)
203 conf.AccountSlots = DefaultTxPoolConfig.AccountSlots
204 }
205 if conf.GlobalSlots < 1 {
206 log.Warn("Sanitizing invalid txpool global slots", "provided", conf.GlobalSlots, "updated", DefaultTxPoolConfig.GlobalSlots)
207 conf.GlobalSlots = DefaultTxPoolConfig.GlobalSlots
208 }
209 if conf.AccountQueue < 1 {
210 log.Warn("Sanitizing invalid txpool account queue", "provided", conf.AccountQueue, "updated", DefaultTxPoolConfig.AccountQueue)
211 conf.AccountQueue = DefaultTxPoolConfig.AccountQueue
212 }
213 if conf.GlobalQueue < 1 {
214 log.Warn("Sanitizing invalid txpool global queue", "provided", conf.GlobalQueue, "updated", DefaultTxPoolConfig.GlobalQueue)
215 conf.GlobalQueue = DefaultTxPoolConfig.GlobalQueue
216 }
217 if conf.Lifetime < 1 {
218 log.Warn("Sanitizing invalid txpool lifetime", "provided", conf.Lifetime, "updated", DefaultTxPoolConfig.Lifetime)
219 conf.Lifetime = DefaultTxPoolConfig.Lifetime
220 }
221
222 return conf
223}
224
225// TxPool contains all currently known transactions. Transactions
226// enter the pool when they are received from the network or submitted

Callers 1

NewTxPoolFunction · 0.80

Calls 1

WarnMethod · 0.65

Tested by

no test coverage detected