address bez's comments

This commit is contained in:
ValarDragon 2018-10-29 09:37:42 -07:00
parent e4b5e2c9f3
commit 100f88800b
1 changed files with 13 additions and 2 deletions

View File

@ -198,8 +198,13 @@ func SimulateFromSeed(tb testing.TB, app *baseapp.BaseApp,
// Returns a function to simulate blocks. Written like this to avoid constant parameters being passed everytime, to minimize
// memory overhead
func createBlockSimulator(testingMode bool, tb testing.TB, t *testing.T, event func(string), invariants []Invariant, ops []WeightedOperation, operationQueue map[int][]Operation, timeOperationQueue []FutureOperation, totalNumBlocks int, avgBlockSize int, displayLogs func()) func(
r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accounts []Account, header abci.Header, logWriter func(string)) (opCount int) {
func createBlockSimulator(testingMode bool, tb testing.TB, t *testing.T,
event func(string), invariants []Invariant,
ops []WeightedOperation, operationQueue map[int][]Operation, timeOperationQueue []FutureOperation,
totalNumBlocks int, avgBlockSize int, displayLogs func()) func(
r *rand.Rand,
app *baseapp.BaseApp, ctx sdk.Context,
accounts []Account, header abci.Header, logWriter func(string)) (opCount int) {
var (
lastBlocksizeState = 0 // state for [4 * uniform distribution]
totalOpWeight = 0
@ -258,6 +263,12 @@ func getTestingMode(tb testing.TB) (testingMode bool, t *testing.T, b *testing.B
return
}
/** getBlockSize returns a block size as determined from the transition matrix.
It targets making average block size the provided parameter.
The three states it moves between are:
* "over stuffed" blocks with average size of 2 * avgblocksize,
* normal sized blocks, hitting avgBlocksize on average,
* and empty blocks, with no txs / only txs scheduled from the past. */
func getBlockSize(r *rand.Rand, lastBlockSizeState, avgBlockSize int) (state, blocksize int) {
// TODO: Make blockSizeTransitionMatrix non-global
// TODO: Make default blocksize transitition matrix actually make the average blocksize equal to avgBlockSize