feat(indexer): add to modules and implement proto fields (#22544)
This commit is contained in:
+15
-3
@@ -44,7 +44,7 @@ var (
|
||||
// Deprecated: exists only for state compatibility reasons, should not
|
||||
// be used for new storage keys using time. Please use the time KeyCodec
|
||||
// provided in the collections package.
|
||||
TimeKey collcodec.KeyCodec[time.Time] = timeKeyCodec{}
|
||||
TimeKey collcodec.NameableKeyCodec[time.Time] = timeKeyCodec{}
|
||||
|
||||
// LEUint64Key is a collections KeyCodec that encodes uint64 using little endian.
|
||||
// NOTE: it MUST NOT be used by other modules, distribution relies on this only for
|
||||
@@ -56,7 +56,7 @@ var (
|
||||
// Deprecated: exists only for state compatibility reasons, should not be
|
||||
// used for new storage keys using []byte. Please use the BytesKey provided
|
||||
// in the collections package.
|
||||
LengthPrefixedBytesKey collcodec.KeyCodec[[]byte] = lengthPrefixedBytesKey{collections.BytesKey}
|
||||
LengthPrefixedBytesKey collcodec.NameableKeyCodec[[]byte] = lengthPrefixedBytesKey{collections.BytesKey}
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -139,6 +139,10 @@ func (g lengthPrefixedAddressKey[T]) Size(key T) int { return g.SizeNonTerminal(
|
||||
|
||||
func (g lengthPrefixedAddressKey[T]) KeyType() string { return "index_key/" + g.KeyCodec.KeyType() }
|
||||
|
||||
func (g lengthPrefixedAddressKey[T]) WithName(name string) collcodec.KeyCodec[T] {
|
||||
return collcodec.NamedKeyCodec[T]{KeyCodec: g, Name: name}
|
||||
}
|
||||
|
||||
// Deprecated: LengthPrefixedAddressKey implements an SDK backwards compatible indexing key encoder
|
||||
// for addresses.
|
||||
// The status quo in the SDK is that address keys are length prefixed even when they're the
|
||||
@@ -148,7 +152,7 @@ func (g lengthPrefixedAddressKey[T]) KeyType() string { return "index_key/" + g.
|
||||
// byte to the string, then when you know when the string part finishes, it's logical that the
|
||||
// part which remains is the address key. In the SDK instead we prepend to the address key its
|
||||
// length too.
|
||||
func LengthPrefixedAddressKey[T addressUnion](keyCodec collcodec.KeyCodec[T]) collcodec.KeyCodec[T] {
|
||||
func LengthPrefixedAddressKey[T addressUnion](keyCodec collcodec.KeyCodec[T]) collcodec.NameableKeyCodec[T] {
|
||||
return lengthPrefixedAddressKey[T]{
|
||||
keyCodec,
|
||||
}
|
||||
@@ -176,6 +180,10 @@ func (g lengthPrefixedBytesKey) KeyType() string {
|
||||
return "index_key/" + g.KeyCodec.KeyType()
|
||||
}
|
||||
|
||||
func (g lengthPrefixedBytesKey) WithName(name string) collcodec.KeyCodec[[]byte] {
|
||||
return collcodec.NamedKeyCodec[[]byte]{KeyCodec: g, Name: name}
|
||||
}
|
||||
|
||||
// Collection Codecs
|
||||
|
||||
type intValueCodec struct{}
|
||||
@@ -329,6 +337,10 @@ func (t timeKeyCodec) DecodeNonTerminal(buffer []byte) (int, time.Time, error) {
|
||||
}
|
||||
func (t timeKeyCodec) SizeNonTerminal(key time.Time) int { return t.Size(key) }
|
||||
|
||||
func (t timeKeyCodec) WithName(name string) collcodec.KeyCodec[time.Time] {
|
||||
return collcodec.NamedKeyCodec[time.Time]{KeyCodec: t, Name: name}
|
||||
}
|
||||
|
||||
type leUint64Key struct{}
|
||||
|
||||
func (l leUint64Key) Encode(buffer []byte, key uint64) (int, error) {
|
||||
|
||||
Reference in New Issue
Block a user