chore: fix typos (#25191)
This commit is contained in:
parent
15adb55701
commit
97c0bd8cb2
@ -156,7 +156,7 @@ func (kv KVPair) Bytes() []byte {
|
||||
// * 8 bytes to Uvarint encode the length of the value
|
||||
// So preallocate for the worst case, which will in total
|
||||
// be a maximum of 14 bytes wasted, if len(key)=1, len(value)=1,
|
||||
// but that's going to rare.
|
||||
// but that's going to be rare.
|
||||
buf := make([]byte, 8+len(kv.Key)+8+len(kv.Value))
|
||||
|
||||
// Encode the key, prefixed with its length.
|
||||
|
||||
@ -67,7 +67,7 @@ func convertInnerOps(p *cmtprotocrypto.Proof) ([]*ics23.InnerOp, error) {
|
||||
}
|
||||
|
||||
// buildPath returns a list of steps from leaf to root
|
||||
// in each step, true means index is left side, false index is right side
|
||||
// in each step, true means index is left side, false means index is right side
|
||||
// code adapted from merkle/simple_proof.go:computeHashFromAunts
|
||||
func buildPath(idx, total int64) []bool {
|
||||
if total < 2 {
|
||||
|
||||
@ -15,7 +15,7 @@ var (
|
||||
)
|
||||
|
||||
/*
|
||||
CreateMembershipProof will produce a CommitmentProof that the given key (and queries value) exists in the map.
|
||||
CreateMembershipProof will produce a CommitmentProof that the given key (and queried value) exists in the map.
|
||||
If the key doesn't exist in the tree, this will return an error.
|
||||
*/
|
||||
func CreateMembershipProof(data map[string][]byte, key []byte) (*ics23.CommitmentProof, error) {
|
||||
|
||||
@ -55,7 +55,7 @@ func CalcRoot(data map[string][]byte) []byte {
|
||||
return root
|
||||
}
|
||||
|
||||
// GetKey this returns a key, on Left/Right/Middle
|
||||
// GetKey returns a key, on Left/Right/Middle
|
||||
func GetKey(allkeys []string, loc Where) string {
|
||||
if loc == Left {
|
||||
return allkeys[0]
|
||||
|
||||
@ -11,7 +11,7 @@ var (
|
||||
innerPrefix = []byte{1}
|
||||
)
|
||||
|
||||
// HashFromByteSlices computes a Merkle tree where the leaves are the byte slice,
|
||||
// HashFromByteSlices computes a Merkle tree where the leaves are the byte slices,
|
||||
// in the provided order. It follows RFC-6962.
|
||||
func HashFromByteSlices(items [][]byte) []byte {
|
||||
return hashFromByteSlices(sha256.New(), items)
|
||||
|
||||
@ -52,19 +52,19 @@ func (s *Store) Has(key []byte) bool {
|
||||
}
|
||||
|
||||
// Iterator implements the KVStore interface. It delegates the Iterator call
|
||||
// the to the parent KVStore.
|
||||
// to the parent KVStore.
|
||||
func (s *Store) Iterator(start, end []byte) types.Iterator {
|
||||
return s.iterator(start, end, true)
|
||||
}
|
||||
|
||||
// ReverseIterator implements the KVStore interface. It delegates the
|
||||
// ReverseIterator call the to the parent KVStore.
|
||||
// ReverseIterator call to the parent KVStore.
|
||||
func (s *Store) ReverseIterator(start, end []byte) types.Iterator {
|
||||
return s.iterator(start, end, false)
|
||||
}
|
||||
|
||||
// iterator facilitates iteration over a KVStore. It delegates the necessary
|
||||
// calls to it's parent KVStore.
|
||||
// calls to its parent KVStore.
|
||||
func (s *Store) iterator(start, end []byte, ascending bool) types.Iterator {
|
||||
var parent types.Iterator
|
||||
|
||||
|
||||
@ -12,8 +12,8 @@ import (
|
||||
|
||||
var _ types.KVStore = Store{}
|
||||
|
||||
// Store is similar with cometbft/cometbft/libs/db/prefix_db
|
||||
// both gives access only to the limited subset of the store
|
||||
// Store is similar to cometbft/cometbft/libs/db/prefix_db
|
||||
// both give access only to the limited subset of the store
|
||||
// for convenience or safety
|
||||
type Store struct {
|
||||
parent types.KVStore
|
||||
@ -75,7 +75,7 @@ func (s Store) Set(key, value []byte) {
|
||||
s.parent.Set(s.key(key), value)
|
||||
}
|
||||
|
||||
// Delete implements KVStore, calls delete on the parent store with the key prefixed with the prefix
|
||||
// Delete implements KVStore, calls Delete on the parent store with the key prefixed with the prefix
|
||||
func (s Store) Delete(key []byte) {
|
||||
s.parent.Delete(s.key(key))
|
||||
}
|
||||
|
||||
@ -153,12 +153,12 @@ func TestPruningHeight_Inputs(t *testing.T) {
|
||||
0,
|
||||
types.PruningEverything,
|
||||
},
|
||||
"currentHeight is zero - prune everything - invalid currentHeight": {
|
||||
"currentHeight is zero - prune everything - invalid currentHeight": {
|
||||
0,
|
||||
0,
|
||||
types.PruningEverything,
|
||||
},
|
||||
"currentHeight is positive but within keep recent- prune everything - not kept": {
|
||||
"currentHeight is positive but within keep recent - prune everything - not kept": {
|
||||
keepRecent,
|
||||
0,
|
||||
types.PruningEverything,
|
||||
|
||||
@ -32,7 +32,7 @@ const (
|
||||
const (
|
||||
// PruningDefault defines a pruning strategy where the last 362880 heights are
|
||||
// kept where to-be pruned heights are pruned at every 10th height.
|
||||
// The last 362880 heights are kept(approximately 3.5 weeks worth of state) assuming the typical
|
||||
// The last 362880 heights are kept (approximately 3.5 weeks worth of state) assuming the typical
|
||||
// block time is 6s. If these values do not match the applications' requirements, use the "custom" option.
|
||||
PruningDefault PruningStrategy = iota
|
||||
// PruningEverything defines a pruning strategy where all committed heights are
|
||||
|
||||
@ -354,7 +354,7 @@ func moveKVStoreData(oldDB, newDB types.KVStore) error {
|
||||
|
||||
// PruneSnapshotHeight prunes the given height according to the prune strategy.
|
||||
// If the strategy is PruneNothing, this is a no-op.
|
||||
// For other strategies, this height is persisted until the snapshot is operated.
|
||||
// For other strategies, this height is persisted until the snapshot is completed.
|
||||
func (rs *Store) PruneSnapshotHeight(height int64) {
|
||||
rs.pruningManager.HandleSnapshotHeight(height)
|
||||
}
|
||||
@ -694,7 +694,7 @@ func (rs *Store) handlePruning(version int64) error {
|
||||
return rs.PruneStores(pruneHeight)
|
||||
}
|
||||
|
||||
// PruneStores prunes all history upto the specific height of the multi store.
|
||||
// PruneStores prunes all history up to the specific height of the multi store.
|
||||
func (rs *Store) PruneStores(pruningHeight int64) (err error) {
|
||||
if pruningHeight <= 0 {
|
||||
rs.logger.Debug("pruning skipped, height is less than or equal to 0")
|
||||
|
||||
@ -436,7 +436,7 @@ func TestMultiStoreRestart(t *testing.T) {
|
||||
reloadedCid := multi.LastCommitID()
|
||||
require.Equal(t, int64(4), reloadedCid.Version, "Reloaded CID is not the same as last flushed CID")
|
||||
|
||||
// Check that store1 and store2 retained date from 3rd commit
|
||||
// Check that store1 and store2 retained data from 3rd commit
|
||||
store1 = multi.GetStoreByName("store1").(types.KVStore)
|
||||
val := store1.Get([]byte(k))
|
||||
require.Equal(t, []byte(fmt.Sprintf("%s:%d", v, 3)), val, "Reloaded value not the same as last flushed value")
|
||||
|
||||
@ -63,7 +63,7 @@ func readChunks(chunks <-chan io.ReadCloser) [][]byte {
|
||||
return bodies
|
||||
}
|
||||
|
||||
// snapshotItems serialize a array of bytes as SnapshotItem_ExtensionPayload, and return the chunks.
|
||||
// snapshotItems serialize an array of bytes as SnapshotItem_ExtensionPayload, and return the chunks.
|
||||
func snapshotItems(items [][]byte, ext snapshottypes.ExtensionSnapshotter) [][]byte {
|
||||
// copy the same parameters from the code
|
||||
snapshotChunkSize := uint64(10e6)
|
||||
|
||||
@ -170,7 +170,7 @@ func TestManager_Restore(t *testing.T) {
|
||||
err = manager.Restore(types.Snapshot{Height: 3, Format: types.CurrentFormat, Hash: []byte{1, 2, 3}})
|
||||
require.Error(t, err)
|
||||
|
||||
// Restore errors on chunk and chunkhashes mismatch
|
||||
// Restore errors on chunk and chunk hashes mismatch
|
||||
err = manager.Restore(types.Snapshot{
|
||||
Height: 3,
|
||||
Format: types.CurrentFormat,
|
||||
|
||||
@ -32,20 +32,20 @@ type Snapshotter interface {
|
||||
Restore(height uint64, format uint32, protoReader protoio.Reader) (SnapshotItem, error)
|
||||
}
|
||||
|
||||
// ExtensionPayloadReader read extension payloads,
|
||||
// it returns io.EOF when reached either end of stream or the extension boundaries.
|
||||
// ExtensionPayloadReader reads extension payloads,
|
||||
// it returns io.EOF when it reaches either end of stream or the extension boundaries.
|
||||
type ExtensionPayloadReader = func() ([]byte, error)
|
||||
|
||||
// ExtensionPayloadWriter is a helper to write extension payloads to underlying stream.
|
||||
type ExtensionPayloadWriter = func([]byte) error
|
||||
|
||||
// ExtensionSnapshotter is an extension Snapshotter that is appended to the snapshot stream.
|
||||
// ExtensionSnapshotter has an unique name and manages it's own internal formats.
|
||||
// ExtensionSnapshotter has an unique name and manages its own internal formats.
|
||||
type ExtensionSnapshotter interface {
|
||||
// SnapshotName returns the name of snapshotter, it should be unique in the manager.
|
||||
SnapshotName() string
|
||||
|
||||
// SnapshotFormat returns the default format the extension snapshotter use to encode the
|
||||
// SnapshotFormat returns the default format the extension snapshotter uses to encode the
|
||||
// payloads when taking a snapshot.
|
||||
// It's defined within the extension, different from the global format for the whole state-sync snapshot.
|
||||
SnapshotFormat() uint32
|
||||
@ -57,6 +57,6 @@ type ExtensionSnapshotter interface {
|
||||
SnapshotExtension(height uint64, payloadWriter ExtensionPayloadWriter) error
|
||||
|
||||
// RestoreExtension restores an extension state snapshot,
|
||||
// the payload reader returns `io.EOF` when reached the extension boundaries.
|
||||
// the payload reader returns `io.EOF` when it reaches the extension boundaries.
|
||||
RestoreExtension(height uint64, format uint32, payloadReader ExtensionPayloadReader) error
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user