style: gofumpt linting (#15605)

This commit is contained in:
Marko
2023-03-30 06:27:38 +00:00
committed by GitHub
parent 24344fb382
commit 1f2875d445
56 changed files with 97 additions and 97 deletions
+1 -1
View File
@@ -34,7 +34,7 @@ func generateSequentialKeys(startKey []byte, numKeys int) [][]byte {
}
// Generate many random, unsorted keys
func generateRandomKeys(keySize int, numKeys int) [][]byte {
func generateRandomKeys(keySize, numKeys int) [][]byte {
toReturn := make([][]byte, 0, numKeys)
for i := 0; i < numKeys; i++ {
newKey := randSlice(keySize)
+1 -1
View File
@@ -60,7 +60,7 @@ func newMemIterator(start, end []byte, items BTree, ascending bool) *memIterator
return mi
}
func (mi *memIterator) Domain() (start []byte, end []byte) {
func (mi *memIterator) Domain() (start, end []byte) {
return mi.start, mi.end
}
+1 -1
View File
@@ -68,7 +68,7 @@ func (store *Store) Get(key []byte) (value []byte) {
}
// Set implements types.KVStore.
func (store *Store) Set(key []byte, value []byte) {
func (store *Store) Set(key, value []byte) {
types.AssertValidKey(key)
types.AssertValidValue(value)
+2 -2
View File
@@ -44,7 +44,7 @@ func (gs *Store) Get(key []byte) (value []byte) {
}
// Implements KVStore.
func (gs *Store) Set(key []byte, value []byte) {
func (gs *Store) Set(key, value []byte) {
types.AssertValidKey(key)
types.AssertValidValue(value)
gs.gasMeter.ConsumeGas(gs.gasConfig.WriteCostFlat, types.GasWriteCostFlatDesc)
@@ -121,7 +121,7 @@ func newGasIterator(gasMeter types.GasMeter, gasConfig types.GasConfig, parent t
}
// Implements Iterator.
func (gi *gasIterator) Domain() (start []byte, end []byte) {
func (gi *gasIterator) Domain() (start, end []byte) {
return gi.parent.Domain()
}
+1 -1
View File
@@ -293,7 +293,7 @@ func TestIAVLReverseIterator(t *testing.T) {
iavlStore.Set([]byte{0x00, 0x02}, []byte("0 2"))
iavlStore.Set([]byte{0x01}, []byte("1"))
testReverseIterator := func(t *testing.T, start []byte, end []byte, expected []string) {
testReverseIterator := func(t *testing.T, start, end []byte, expected []string) {
iter := iavlStore.ReverseIterator(start, end)
var i int
for i = 0; iter.Valid(); iter.Next() {
+2 -2
View File
@@ -32,7 +32,7 @@ func (s *Store) Get(key []byte) []byte {
// Set implements the KVStore interface. It traces a write operation and
// delegates the Set call to the parent KVStore.
func (s *Store) Set(key []byte, value []byte) {
func (s *Store) Set(key, value []byte) {
types.AssertValidKey(key)
s.parent.Set(key, value)
s.listener.OnWrite(s.parentStoreKey, key, value, false)
@@ -87,7 +87,7 @@ func newTraceIterator(parent types.Iterator, listener *types.MemoryListener) typ
}
// Domain implements the Iterator interface.
func (li *listenIterator) Domain() (start []byte, end []byte) {
func (li *listenIterator) Domain() (start, end []byte) {
return li.parent.Domain()
}
+2 -2
View File
@@ -27,7 +27,7 @@ func NewStore(parent types.KVStore, prefix []byte) Store {
}
}
func cloneAppend(bz []byte, tail []byte) (res []byte) {
func cloneAppend(bz, tail []byte) (res []byte) {
res = make([]byte, len(bz)+len(tail))
copy(res, bz)
copy(res[len(bz):], tail)
@@ -193,7 +193,7 @@ func (pi *prefixIterator) Error() error {
}
// copied from github.com/cometbft/cometbft/libs/db/prefix_db.go
func stripPrefix(key []byte, prefix []byte) []byte {
func stripPrefix(key, prefix []byte) []byte {
if len(key) < len(prefix) || !bytes.Equal(key[:len(prefix)], prefix) {
panic("should not happen")
}
+1 -1
View File
@@ -253,7 +253,7 @@ func mockStoreWithStuff() types.KVStore {
return store
}
func checkValue(t *testing.T, store types.KVStore, key []byte, expected []byte) {
func checkValue(t *testing.T, store types.KVStore, key, expected []byte) {
bz := store.Get(key)
require.Equal(t, expected, bz)
}
+2 -2
View File
@@ -330,7 +330,7 @@ func deleteKVStore(kv types.KVStore) error {
}
// we simulate move by a copy and delete
func moveKVStoreData(oldDB types.KVStore, newDB types.KVStore) error {
func moveKVStoreData(oldDB, newDB types.KVStore) error {
// we read from one and write to another
itr := oldDB.Iterator(nil, nil)
for itr.Valid() {
@@ -743,7 +743,7 @@ func (rs *Store) SetInitialVersion(version int64) error {
// parsePath expects a format like /<storeName>[/<subpath>]
// Must start with /, subpath may be empty
// Returns error if it doesn't start with /
func parsePath(path string) (storeName string, subpath string, err error) {
func parsePath(path string) (storeName, subpath string, err error) {
if !strings.HasPrefix(path, "/") {
return storeName, subpath, errorsmod.Wrapf(types.ErrUnknownRequest, "invalid path: %s", path)
}
+1 -1
View File
@@ -860,7 +860,7 @@ type MockListener struct {
stateCache []types.StoreKVPair
}
func (tl *MockListener) OnWrite(storeKey types.StoreKey, key []byte, value []byte, delete bool) error {
func (tl *MockListener) OnWrite(storeKey types.StoreKey, key, value []byte, delete bool) error {
tl.stateCache = append(tl.stateCache, types.StoreKVPair{
StoreKey: storeKey.Name(),
Key: key,
+1 -1
View File
@@ -236,7 +236,7 @@ func (m *Manager) List() ([]*types.Snapshot, error) {
// LoadChunk loads a chunk into a byte slice, mirroring ABCI LoadChunk. It can be called
// concurrently with other operations. If the chunk does not exist, nil is returned.
func (m *Manager) LoadChunk(height uint64, format uint32, chunk uint32) ([]byte, error) {
func (m *Manager) LoadChunk(height uint64, format, chunk uint32) ([]byte, error) {
reader, err := m.store.LoadChunk(height, format, chunk)
if err != nil {
return nil, err
+3 -3
View File
@@ -166,7 +166,7 @@ func (s *Store) Load(height uint64, format uint32) (*types.Snapshot, <-chan io.R
// LoadChunk loads a chunk from disk, or returns nil if it does not exist. The caller must call
// Close() on it when done.
func (s *Store) LoadChunk(height uint64, format uint32, chunk uint32) (io.ReadCloser, error) {
func (s *Store) LoadChunk(height uint64, format, chunk uint32) (io.ReadCloser, error) {
path := s.pathChunk(height, format, chunk)
file, err := os.Open(path)
if os.IsNotExist(err) {
@@ -176,7 +176,7 @@ func (s *Store) LoadChunk(height uint64, format uint32, chunk uint32) (io.ReadCl
}
// loadChunkFile loads a chunk from disk, and errors if it does not exist.
func (s *Store) loadChunkFile(height uint64, format uint32, chunk uint32) (io.ReadCloser, error) {
func (s *Store) loadChunkFile(height uint64, format, chunk uint32) (io.ReadCloser, error) {
path := s.pathChunk(height, format, chunk)
return os.Open(path)
}
@@ -336,7 +336,7 @@ func (s *Store) pathSnapshot(height uint64, format uint32) string {
}
// pathChunk generates a snapshot chunk path.
func (s *Store) pathChunk(height uint64, format uint32, chunk uint32) string {
func (s *Store) pathChunk(height uint64, format, chunk uint32) string {
return filepath.Join(s.pathSnapshot(height, format), strconv.FormatUint(uint64(chunk), 10))
}
+1 -1
View File
@@ -28,7 +28,7 @@ func GetPluginEnvKey(name string) string {
return fmt.Sprintf("%s_%s", pluginEnvKeyPrefix, strings.ToUpper(name))
}
func NewStreamingPlugin(name string, logLevel string) (interface{}, error) {
func NewStreamingPlugin(name, logLevel string) (interface{}, error) {
logger := hclog.New(&hclog.LoggerOptions{
Output: hclog.DefaultOutput,
Level: toHclogLevel(logLevel),
+2 -2
View File
@@ -60,7 +60,7 @@ func (tkv *Store) Get(key []byte) []byte {
// Set implements the KVStore interface. It traces a write operation and
// delegates the Set call to the parent KVStore.
func (tkv *Store) Set(key []byte, value []byte) {
func (tkv *Store) Set(key, value []byte) {
types.AssertValidKey(key)
writeOperation(tkv.writer, writeOp, tkv.context, key, value)
tkv.parent.Set(key, value)
@@ -116,7 +116,7 @@ func newTraceIterator(w io.Writer, parent types.Iterator, tc types.TraceContext)
}
// Domain implements the Iterator interface.
func (ti *traceIterator) Domain() (start []byte, end []byte) {
func (ti *traceIterator) Domain() (start, end []byte) {
return ti.parent.Domain()
}
+1 -1
View File
@@ -11,7 +11,7 @@ func NewMemoryListener() *MemoryListener {
}
// OnWrite implements MemoryListener interface
func (fl *MemoryListener) OnWrite(storeKey StoreKey, key []byte, value []byte, delete bool) {
func (fl *MemoryListener) OnWrite(storeKey StoreKey, key, value []byte, delete bool) {
fl.stateCache = append(fl.stateCache, &StoreKVPair{
StoreKey: storeKey.Name(),
Delete: delete,