-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: remove store kv dependency (#14144)
- Loading branch information
1 parent
cdae85f
commit f3be418
Showing
15 changed files
with
262 additions
and
276 deletions.
There are no files selected for viewing
231 changes: 120 additions & 111 deletions
231
api/cosmos/base/kv/v1beta1/kv.pulsar.go → ...se/store/internal/kv/v1beta1/kv.pulsar.go
Large diffs are not rendered by default.
Oops, something went wrong.
6 changes: 4 additions & 2 deletions
6
proto/cosmos/base/kv/v1beta1/kv.proto → ...s/base/store/internal/kv/v1beta1/kv.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package kv | ||
|
||
import "fmt" | ||
|
||
// AssertKeyAtLeastLength panics when store key length is less than the given length. | ||
func AssertKeyAtLeastLength(bz []byte, length int) { | ||
if len(bz) < length { | ||
panic(fmt.Sprintf("expected key of length at least %d, got %d", length, len(bz))) | ||
} | ||
} | ||
|
||
// AssertKeyLength panics when store key length is not equal to the given length. | ||
func AssertKeyLength(bz []byte, length int) { | ||
if len(bz) != length { | ||
panic(fmt.Sprintf("unexpected key length; got: %d, expected: %d", len(bz), length)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package kv | ||
|
||
import ( | ||
"bytes" | ||
"sort" | ||
) | ||
|
||
func (kvs Pairs) Len() int { return len(kvs.Pairs) } | ||
func (kvs Pairs) Less(i, j int) bool { | ||
switch bytes.Compare(kvs.Pairs[i].Key, kvs.Pairs[j].Key) { | ||
case -1: | ||
return true | ||
|
||
case 0: | ||
return bytes.Compare(kvs.Pairs[i].Value, kvs.Pairs[j].Value) < 0 | ||
|
||
case 1: | ||
return false | ||
|
||
default: | ||
panic("invalid comparison result") | ||
} | ||
} | ||
|
||
func (kvs Pairs) Swap(i, j int) { kvs.Pairs[i], kvs.Pairs[j] = kvs.Pairs[j], kvs.Pairs[i] } | ||
|
||
// Sort invokes sort.Sort on kvs. | ||
func (kvs Pairs) Sort() { sort.Sort(kvs) } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,10 @@ | ||
package kv | ||
|
||
import ( | ||
"bytes" | ||
"sort" | ||
) | ||
|
||
func (kvs Pairs) Len() int { return len(kvs.Pairs) } | ||
func (kvs Pairs) Less(i, j int) bool { | ||
switch bytes.Compare(kvs.Pairs[i].Key, kvs.Pairs[j].Key) { | ||
case -1: | ||
return true | ||
|
||
case 0: | ||
return bytes.Compare(kvs.Pairs[i].Value, kvs.Pairs[j].Value) < 0 | ||
|
||
case 1: | ||
return false | ||
|
||
default: | ||
panic("invalid comparison result") | ||
} | ||
type Pair struct { | ||
Key []byte | ||
Value []byte | ||
} | ||
|
||
func (kvs Pairs) Swap(i, j int) { kvs.Pairs[i], kvs.Pairs[j] = kvs.Pairs[j], kvs.Pairs[i] } | ||
|
||
// Sort invokes sort.Sort on kvs. | ||
func (kvs Pairs) Sort() { sort.Sort(kvs) } | ||
type Pairs struct { | ||
Pairs []Pair | ||
} |
Oops, something went wrong.