gitlab.com/SiaPrime/SiaPrime@v1.4.1/modules/wallet/consts.go (about)

     1  package wallet
     2  
     3  import (
     4  	"gitlab.com/SiaPrime/SiaPrime/build"
     5  )
     6  
     7  const (
     8  	// defragBatchSize defines how many outputs are combined during one defrag.
     9  	defragBatchSize = 35
    10  
    11  	// defragStartIndex is the number of outputs to skip over when performing a
    12  	// defrag.
    13  	defragStartIndex = 10
    14  
    15  	// defragThreshold is the number of outputs a wallet is allowed before it is
    16  	// defragmented.
    17  	defragThreshold = 50
    18  )
    19  
    20  var (
    21  	// lookaheadBuffer together with lookaheadRescanThreshold defines the constant part
    22  	// of the maxLookahead
    23  	lookaheadBuffer = build.Select(build.Var{
    24  		Dev:      uint64(400),
    25  		Standard: uint64(4000),
    26  		Testing:  uint64(40),
    27  	}).(uint64)
    28  
    29  	// lookaheadRescanThreshold is the number of keys in the lookahead that will be
    30  	// generated before a complete wallet rescan is initialized.
    31  	lookaheadRescanThreshold = build.Select(build.Var{
    32  		Dev:      uint64(100),
    33  		Standard: uint64(1000),
    34  		Testing:  uint64(10),
    35  	}).(uint64)
    36  )
    37  
    38  func init() {
    39  	// Sanity check - the defrag threshold needs to be higher than the batch
    40  	// size plus the start index.
    41  	if build.DEBUG && defragThreshold <= defragBatchSize+defragStartIndex {
    42  		panic("constants are incorrect, defragThreshold needs to be larger than the sum of defragBatchSize and defragStartIndex")
    43  	}
    44  }
    45  
    46  // maxLookahead returns the size of the lookahead for a given seed progress
    47  // which usually is the current primarySeedProgress
    48  func maxLookahead(start uint64) uint64 {
    49  	return start + lookaheadRescanThreshold + lookaheadBuffer + start/10
    50  }