github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/storage/pebble/registers/comparer.go (about)

     1  package registers
     2  
     3  import "github.com/cockroachdb/pebble"
     4  
     5  const (
     6  	// Size of the block height encoded in the key.
     7  	HeightSuffixLen = 8
     8  )
     9  
    10  // NewMVCCComparer creates a new comparer with a
    11  // custom Split function that separates the height from the rest of the key.
    12  //
    13  // This is needed for SeekPrefixGE to work.
    14  func NewMVCCComparer() *pebble.Comparer {
    15  	comparer := *pebble.DefaultComparer
    16  	comparer.Split = func(a []byte) int {
    17  		return len(a) - HeightSuffixLen
    18  	}
    19  	comparer.Name = "flow.MVCCComparer"
    20  
    21  	return &comparer
    22  }