Merge pull request #614 from nspcc-dev/configurable-mempool-size

config: add MemPoolSize configuration parameter
This commit is contained in:
Evgeniy Kulikov 2020-01-23 13:25:27 +03:00 committed by GitHub
commit eb59460032
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 17 additions and 1 deletions

View file

@ -47,6 +47,7 @@ type (
SecondsPerBlock int `yaml:"SecondsPerBlock"`
LowPriorityThreshold float64 `yaml:"LowPriorityThreshold"`
MaxTransactionsPerBlock int64 `yaml:"MaxTransactionsPerBlock"`
MemPoolSize int `yaml:"MemPoolSize"`
StandbyValidators []string `yaml:"StandbyValidators"`
SeedList []string `yaml:"SeedList"`
SystemFee SystemFee `yaml:"SystemFee"`

View file

@ -3,6 +3,7 @@ ProtocolConfiguration:
AddressVersion: 23
SecondsPerBlock: 15
LowPriorityThreshold: 0.001
MemPoolSize: 50000
StandbyValidators:
- 03b209fd4f53a7170ea4444e0cb0a6bb6a53c2bd016926989cf85f9b0fba17a70c
- 02df48f60e8f3e01c48ff40b9b7f1310d7a8b2a193188befe1c2e3df740e895093

View file

@ -3,6 +3,7 @@ ProtocolConfiguration:
AddressVersion: 23
SecondsPerBlock: 15
LowPriorityThreshold: 0.000
MemPoolSize: 50000
StandbyValidators:
- 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2
- 02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e

View file

@ -3,6 +3,7 @@ ProtocolConfiguration:
AddressVersion: 23
SecondsPerBlock: 15
LowPriorityThreshold: 0.000
MemPoolSize: 50000
StandbyValidators:
- 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2
- 02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e

View file

@ -3,6 +3,7 @@ ProtocolConfiguration:
AddressVersion: 23
SecondsPerBlock: 1
LowPriorityThreshold: 0.001
MemPoolSize: 50000
StandbyValidators:
- 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2
SeedList:

View file

@ -3,6 +3,7 @@ ProtocolConfiguration:
AddressVersion: 23
SecondsPerBlock: 15
LowPriorityThreshold: 0.000
MemPoolSize: 50000
StandbyValidators:
- 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2
- 02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e

View file

@ -3,6 +3,7 @@ ProtocolConfiguration:
AddressVersion: 23
SecondsPerBlock: 15
LowPriorityThreshold: 0.000
MemPoolSize: 50000
StandbyValidators:
- 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2
- 02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e

View file

@ -3,6 +3,7 @@ ProtocolConfiguration:
AddressVersion: 23
SecondsPerBlock: 15
LowPriorityThreshold: 0.000
MemPoolSize: 50000
StandbyValidators:
- 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2
- 02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e

View file

@ -3,6 +3,7 @@ ProtocolConfiguration:
AddressVersion: 23
SecondsPerBlock: 15
LowPriorityThreshold: 0.000
MemPoolSize: 50000
StandbyValidators:
- 0327da12b5c40200e9f65569476bbff2218da4f32548ff43b6387ec1416a231ee8
- 026ce35b29147ad09e4afe4ec4a7319095f08198fa8babbe3c56e970b143528d22

View file

@ -3,6 +3,7 @@ ProtocolConfiguration:
AddressVersion: 23
SecondsPerBlock: 15
LowPriorityThreshold: 0.000
MemPoolSize: 50000
StandbyValidators:
- 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2
- 02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e

View file

@ -37,6 +37,8 @@ const (
// contain any relationship between the two, so we should follow this
// behavior.
registeredAssetLifetime = 2 * 2000000
defaultMemPoolSize = 50000
)
var (
@ -95,6 +97,10 @@ func NewBlockchain(s storage.Store, cfg config.ProtocolConfiguration, log *zap.L
return nil, errors.New("empty logger")
}
if cfg.MemPoolSize <= 0 {
cfg.MemPoolSize = defaultMemPoolSize
log.Info("mempool size is not set or wrong, setting default value", zap.Int("MemPoolSize", cfg.MemPoolSize))
}
bc := &Blockchain{
config: cfg,
dao: newDao(s),
@ -102,7 +108,7 @@ func NewBlockchain(s storage.Store, cfg config.ProtocolConfiguration, log *zap.L
headersOpDone: make(chan struct{}),
stopCh: make(chan struct{}),
runToExitCh: make(chan struct{}),
memPool: mempool.NewMemPool(50000),
memPool: mempool.NewMemPool(cfg.MemPoolSize),
keyCache: make(map[util.Uint160]map[string]*keys.PublicKey),
log: log,
}