Documentation ¶
Index ¶
- Constants
- Variables
- func CleanUpgradeFeatureSlice(arr []string) []string
- func GetCodecUpgradeHeight() int64
- func MapToSlice(m map[string]int64) []string
- func MarshalAny(m BinaryMarshaler, x interface{}) ([]byte, error)
- func MarshalJSONIndent(m JSONMarshaler, obj interface{}) ([]byte, error)
- func MustMarshalJSONIndent(m JSONMarshaler, obj interface{}) []byte
- func ProtoMarshalJSON(msg proto.Message) ([]byte, error)
- func RegisterEvidences(legacy *LegacyAmino, _ *ProtoCodec)
- func SliceToExistingMap(arr []string, m map[string]int64) map[string]int64
- func SliceToMap(arr []string) map[string]int64
- func UnmarshalAny(m BinaryMarshaler, iface interface{}, bz []byte) error
- type BinaryMarshaler
- type Codec
- func (cdc *Codec) AminoCodec() *LegacyAmino
- func (cdc *Codec) DisableUpgradeOverride()
- func (cdc *Codec) IsAfterAppTransferUpgrade(height int64) bool
- func (cdc *Codec) IsAfterCodecUpgrade(height int64) bool
- func (cdc *Codec) IsAfterEnforceMaxChainsUpgrade(height int64) bool
- func (cdc *Codec) IsAfterNamedFeatureActivationHeight(height int64, key string) bool
- func (cdc *Codec) IsAfterNonCustodialUpgrade(height int64) bool
- func (cdc *Codec) IsAfterOutputAddressEditorUpgrade(height int64) bool
- func (cdc *Codec) IsAfterPerChainRTTMUpgrade(height int64) bool
- func (cdc *Codec) IsAfterRewardDelegatorUpgrade(height int64) bool
- func (cdc *Codec) IsAfterValidatorSplitUpgrade(height int64) bool
- func (cdc *Codec) IsOnNamedFeatureActivationHeight(height int64, key string) bool
- func (cdc *Codec) IsOnNamedFeatureActivationHeightWithTolerance(height int64, featureKey string, tolerance int64) bool
- func (cdc *Codec) IsOnNonCustodialUpgrade(height int64) bool
- func (cdc *Codec) LegacyMarshalBinaryBare(o interface{}) ([]byte, error)
- func (cdc *Codec) LegacyMarshalBinaryLengthPrefixed(o interface{}) ([]byte, error)
- func (cdc *Codec) LegacyUnmarshalBinaryBare(bz []byte, ptr interface{}) error
- func (cdc *Codec) LegacyUnmarshalBinaryLengthPrefixed(bz []byte, ptr interface{}) error
- func (cdc *Codec) MarshalBinaryBare(o interface{}, height int64) ([]byte, error)
- func (cdc *Codec) MarshalBinaryLengthPrefixed(o interface{}, height int64) ([]byte, error)
- func (cdc *Codec) MarshalJSON(o interface{}) ([]byte, error)
- func (cdc *Codec) MarshalJSONIndent(o interface{}, prefix string, indent string) ([]byte, error)
- func (cdc *Codec) MustMarshalJSON(o interface{}) []byte
- func (cdc *Codec) MustUnmarshalJSON(bz []byte, ptr interface{})
- func (cdc *Codec) ProtoCodec() *ProtoCodec
- func (cdc *Codec) ProtoMarshalBinaryBare(o ProtoMarshaler) ([]byte, error)
- func (cdc *Codec) ProtoMarshalBinaryLengthPrefixed(o ProtoMarshaler) ([]byte, error)
- func (cdc *Codec) ProtoUnmarshalBinaryBare(bz []byte, ptr ProtoMarshaler) error
- func (cdc *Codec) ProtoUnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler) error
- func (cdc *Codec) RegisterImplementation(iface interface{}, impls ...proto.Message)
- func (cdc *Codec) RegisterInterface(name string, iface interface{}, impls ...proto.Message)
- func (cdc *Codec) RegisterStructure(o interface{}, name string)
- func (cdc *Codec) SetUpgradeOverride(b bool)
- func (cdc *Codec) UnmarshalBinaryBare(bz []byte, ptr interface{}, height int64) error
- func (cdc *Codec) UnmarshalBinaryLengthPrefixed(bz []byte, ptr interface{}, height int64) error
- func (cdc *Codec) UnmarshalJSON(bz []byte, o interface{}) error
- type JSONMarshaler
- type LegacyAmino
- func (cdc *LegacyAmino) MarshalBinaryBare(o interface{}) ([]byte, error)
- func (cdc *LegacyAmino) MarshalBinaryLengthPrefixed(o interface{}) ([]byte, error)
- func (cdc *LegacyAmino) MarshalJSON(o interface{}) ([]byte, error)
- func (cdc *LegacyAmino) MarshalJSONIndent(o interface{}, prefix, indent string) ([]byte, error)
- func (cdc *LegacyAmino) MustMarshalBinaryBare(o interface{}) []byte
- func (cdc *LegacyAmino) MustMarshalBinaryLengthPrefixed(o interface{}) []byte
- func (cdc *LegacyAmino) MustMarshalJSON(o interface{}) []byte
- func (cdc *LegacyAmino) MustUnmarshalBinaryBare(bz []byte, ptr interface{})
- func (cdc *LegacyAmino) MustUnmarshalBinaryLengthPrefixed(bz []byte, ptr interface{})
- func (cdc *LegacyAmino) MustUnmarshalJSON(bz []byte, ptr interface{})
- func (cdc *LegacyAmino) PrintTypes(out io.Writer) error
- func (cdc *LegacyAmino) RegisterConcrete(o interface{}, name string, copts *amino.ConcreteOptions)
- func (cdc *LegacyAmino) RegisterInterface(ptr interface{}, iopts *amino.InterfaceOptions)
- func (cdc *LegacyAmino) Seal()
- func (cdc *LegacyAmino) UnmarshalBinaryBare(bz []byte, ptr interface{}) error
- func (cdc *LegacyAmino) UnmarshalBinaryLengthPrefixed(bz []byte, ptr interface{}) error
- func (cdc *LegacyAmino) UnmarshalJSON(bz []byte, ptr interface{}) error
- func (*LegacyAmino) UnpackAny(*types.Any, interface{}) error
- type Marshaler
- type ProtoCodec
- func (pc *ProtoCodec) MarshalBinaryBare(o ProtoMarshaler) ([]byte, error)
- func (pc *ProtoCodec) MarshalBinaryLengthPrefixed(o ProtoMarshaler) ([]byte, error)
- func (pc *ProtoCodec) MarshalJSON(o interface{}) ([]byte, error)
- func (pc *ProtoCodec) MustMarshalBinaryBare(o ProtoMarshaler) []byte
- func (pc *ProtoCodec) MustMarshalBinaryLengthPrefixed(o ProtoMarshaler) []byte
- func (pc *ProtoCodec) MustMarshalJSON(o interface{}) []byte
- func (pc *ProtoCodec) MustUnmarshalBinaryBare(bz []byte, ptr ProtoMarshaler)
- func (pc *ProtoCodec) MustUnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler)
- func (pc *ProtoCodec) MustUnmarshalJSON(bz []byte, ptr interface{})
- func (pc *ProtoCodec) Register(protoName string, iface interface{}, impls ...proto.Message)
- func (pc *ProtoCodec) RegisterImplementation(iface interface{}, impls ...proto.Message)
- func (pc *ProtoCodec) UnmarshalBinaryBare(bz []byte, ptr ProtoMarshaler) error
- func (pc *ProtoCodec) UnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler) error
- func (pc *ProtoCodec) UnmarshalJSON(bz []byte, ptr interface{}) error
- func (pc *ProtoCodec) UnpackAny(any *types.Any, iface interface{}) error
- type ProtoMarshaler
Constants ¶
const ( UpgradeCodecHeight = int64(30024) CodecChainHaltHeight = int64(30334) ValidatorSplitHeight = int64(45353) NonCustodial1RollbackHeight = int64(69583) NonCustodial2AllowanceHeight = int64(74622) UpgradeCodecUpdateKey = "CODEC" ValidatorSplitUpdateKey = "SPLIT" NonCustodialUpdateKey = "NCUST" EnforceMaxChainsUpdateKey = "MAXCH" TxCacheEnhancementKey = "REDUP" MaxRelayProtKey = "MREL" ReplayBurnKey = "REPBR" BlockSizeModifyKey = "BLOCK" RSCALKey = "RSCAL" VEDITKey = "VEDIT" OutputAddressEditKey = "OEDIT" ClearUnjailedValSessionKey = "CRVAL" PerChainRTTM = "PerChainRTTM" AppTransferKey = "AppTransfer" RewardDelegatorsKey = "RewardDelegators" )
Variables ¶
var ( UpgradeFeatureMap = make(map[string]int64) UpgradeHeight int64 = math.MaxInt64 OldUpgradeHeight int64 = 0 NotProtoCompatibleInterfaceError = errors.New("the interface passed for encoding does not implement proto marshaller") // Used to short-circuit specific protocol upgrades in tests; // <= -1: replaced amino with proto // <= -2: after validator split // <= -3: after non-custodial // <= -4: allow smaller block sizes for testing purposes TestMode int64 = 0 )
Functions ¶
func CleanUpgradeFeatureSlice ¶
CleanUpgradeFeatureSlice convert slice to map and back to remove duplicates
func GetCodecUpgradeHeight ¶
func GetCodecUpgradeHeight() int64
func MarshalAny ¶
func MarshalAny(m BinaryMarshaler, x interface{}) ([]byte, error)
MarshalAny is a convenience function for packing the provided value in an Any and then proto marshaling it to bytes
func MarshalJSONIndent ¶
func MarshalJSONIndent(m JSONMarshaler, obj interface{}) ([]byte, error)
MarshalJSONIndent provides a utility for indented JSON encoding of an object via an Amino codec. It returns an error if it cannot serialize or indent as JSON.
func MustMarshalJSONIndent ¶
func MustMarshalJSONIndent(m JSONMarshaler, obj interface{}) []byte
MustMarshalJSONIndent executes MarshalJSONIndent except it panics upon failure.
func ProtoMarshalJSON ¶
ProtoMarshalJSON provides an auxiliary function to return Proto3 JSON encoded bytes of a message.
func RegisterEvidences ¶
func RegisterEvidences(legacy *LegacyAmino, _ *ProtoCodec)
func SliceToExistingMap ¶
SliceToExistingMap merge slice to existing map
func UnmarshalAny ¶
func UnmarshalAny(m BinaryMarshaler, iface interface{}, bz []byte) error
UnmarshalAny is a convenience function for proto unmarshaling an Any from bz and then unpacking it to the interface pointer passed in as iface using the provided AnyUnpacker or returning an error
Ex:
var x MyInterface err := UnmarshalAny(unpacker, &x, bz)
Types ¶
type BinaryMarshaler ¶
type BinaryMarshaler interface { MarshalBinaryBare(o ProtoMarshaler) ([]byte, error) MustMarshalBinaryBare(o ProtoMarshaler) []byte MarshalBinaryLengthPrefixed(o ProtoMarshaler) ([]byte, error) MustMarshalBinaryLengthPrefixed(o ProtoMarshaler) []byte UnmarshalBinaryBare(bz []byte, ptr ProtoMarshaler) error MustUnmarshalBinaryBare(bz []byte, ptr ProtoMarshaler) UnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler) error MustUnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler) types.AnyUnpacker }
type Codec ¶
type Codec struct {
// contains filtered or unexported fields
}
func NewCodec ¶
func NewCodec(anyUnpacker types.AnyUnpacker) *Codec
func (*Codec) AminoCodec ¶
func (cdc *Codec) AminoCodec() *LegacyAmino
func (*Codec) DisableUpgradeOverride ¶
func (cdc *Codec) DisableUpgradeOverride()
func (*Codec) IsAfterAppTransferUpgrade ¶
func (*Codec) IsAfterCodecUpgrade ¶
IsAfterCodecUpgrade Note: includes the actual upgrade height
func (*Codec) IsAfterEnforceMaxChainsUpgrade ¶
IsAfterEnforceMaxChainsUpgrade Note: includes the actual upgrade height
func (*Codec) IsAfterNamedFeatureActivationHeight ¶
IsAfterNamedFeatureActivationHeight Note: includes the actual upgrade height
func (*Codec) IsAfterNonCustodialUpgrade ¶
IsAfterNonCustodialUpgrade Note: includes the actual upgrade height
func (*Codec) IsAfterOutputAddressEditorUpgrade ¶
func (*Codec) IsAfterPerChainRTTMUpgrade ¶
func (*Codec) IsAfterRewardDelegatorUpgrade ¶
func (*Codec) IsAfterValidatorSplitUpgrade ¶
IsAfterValidatorSplitUpgrade Note: includes the actual upgrade height
func (*Codec) IsOnNamedFeatureActivationHeight ¶
IsOnNamedFeatureActivationHeight Note: includes the actual upgrade height
func (*Codec) IsOnNamedFeatureActivationHeightWithTolerance ¶
func (cdc *Codec) IsOnNamedFeatureActivationHeightWithTolerance( height int64, featureKey string, tolerance int64, ) bool
IsOnNamedFeatureActivationHeightWithTolerance is used to enable certain business logic within some tolerance (i.e. only a few blocks) of feature activation to have more confidence in the feature's release and avoid non-deterministic or hard-to-predict behaviour.
func (*Codec) IsOnNonCustodialUpgrade ¶
IsOnNonCustodialUpgrade Note: includes the actual upgrade height
func (*Codec) LegacyMarshalBinaryBare ¶
func (*Codec) LegacyMarshalBinaryLengthPrefixed ¶
func (*Codec) LegacyUnmarshalBinaryBare ¶
func (*Codec) LegacyUnmarshalBinaryLengthPrefixed ¶
func (*Codec) MarshalBinaryBare ¶
func (*Codec) MarshalBinaryLengthPrefixed ¶
func (*Codec) MarshalJSON ¶
func (*Codec) MarshalJSONIndent ¶
func (*Codec) MustMarshalJSON ¶
func (*Codec) MustUnmarshalJSON ¶
func (*Codec) ProtoCodec ¶
func (cdc *Codec) ProtoCodec() *ProtoCodec
func (*Codec) ProtoMarshalBinaryBare ¶
func (cdc *Codec) ProtoMarshalBinaryBare(o ProtoMarshaler) ([]byte, error)
func (*Codec) ProtoMarshalBinaryLengthPrefixed ¶
func (cdc *Codec) ProtoMarshalBinaryLengthPrefixed(o ProtoMarshaler) ([]byte, error)
func (*Codec) ProtoUnmarshalBinaryBare ¶
func (cdc *Codec) ProtoUnmarshalBinaryBare(bz []byte, ptr ProtoMarshaler) error
func (*Codec) ProtoUnmarshalBinaryLengthPrefixed ¶
func (cdc *Codec) ProtoUnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler) error
func (*Codec) RegisterImplementation ¶
func (*Codec) RegisterInterface ¶
func (*Codec) RegisterStructure ¶
func (*Codec) SetUpgradeOverride ¶
func (*Codec) UnmarshalBinaryBare ¶
func (*Codec) UnmarshalBinaryLengthPrefixed ¶
func (*Codec) UnmarshalJSON ¶
type JSONMarshaler ¶
type LegacyAmino ¶
type LegacyAmino struct {
Amino *amino.Codec
}
deprecated: Codec defines a wrapper for an Amino codec that properly handles protobuf types with Any's
func NewLegacyAminoCodec ¶
func NewLegacyAminoCodec() *LegacyAmino
func (*LegacyAmino) MarshalBinaryBare ¶
func (cdc *LegacyAmino) MarshalBinaryBare(o interface{}) ([]byte, error)
func (*LegacyAmino) MarshalBinaryLengthPrefixed ¶
func (cdc *LegacyAmino) MarshalBinaryLengthPrefixed(o interface{}) ([]byte, error)
func (*LegacyAmino) MarshalJSON ¶
func (cdc *LegacyAmino) MarshalJSON(o interface{}) ([]byte, error)
func (*LegacyAmino) MarshalJSONIndent ¶
func (cdc *LegacyAmino) MarshalJSONIndent(o interface{}, prefix, indent string) ([]byte, error)
func (*LegacyAmino) MustMarshalBinaryBare ¶
func (cdc *LegacyAmino) MustMarshalBinaryBare(o interface{}) []byte
func (*LegacyAmino) MustMarshalBinaryLengthPrefixed ¶
func (cdc *LegacyAmino) MustMarshalBinaryLengthPrefixed(o interface{}) []byte
func (*LegacyAmino) MustMarshalJSON ¶
func (cdc *LegacyAmino) MustMarshalJSON(o interface{}) []byte
func (*LegacyAmino) MustUnmarshalBinaryBare ¶
func (cdc *LegacyAmino) MustUnmarshalBinaryBare(bz []byte, ptr interface{})
func (*LegacyAmino) MustUnmarshalBinaryLengthPrefixed ¶
func (cdc *LegacyAmino) MustUnmarshalBinaryLengthPrefixed(bz []byte, ptr interface{})
func (*LegacyAmino) MustUnmarshalJSON ¶
func (cdc *LegacyAmino) MustUnmarshalJSON(bz []byte, ptr interface{})
func (*LegacyAmino) PrintTypes ¶
func (cdc *LegacyAmino) PrintTypes(out io.Writer) error
func (*LegacyAmino) RegisterConcrete ¶
func (cdc *LegacyAmino) RegisterConcrete(o interface{}, name string, copts *amino.ConcreteOptions)
func (*LegacyAmino) RegisterInterface ¶
func (cdc *LegacyAmino) RegisterInterface(ptr interface{}, iopts *amino.InterfaceOptions)
func (*LegacyAmino) Seal ¶
func (cdc *LegacyAmino) Seal()
func (*LegacyAmino) UnmarshalBinaryBare ¶
func (cdc *LegacyAmino) UnmarshalBinaryBare(bz []byte, ptr interface{}) error
func (*LegacyAmino) UnmarshalBinaryLengthPrefixed ¶
func (cdc *LegacyAmino) UnmarshalBinaryLengthPrefixed(bz []byte, ptr interface{}) error
func (*LegacyAmino) UnmarshalJSON ¶
func (cdc *LegacyAmino) UnmarshalJSON(bz []byte, ptr interface{}) error
type Marshaler ¶
type Marshaler interface { BinaryMarshaler JSONMarshaler }
Marshaler defines the interface module codecs must implement in order to support backwards compatibility with Amino while allowing custom Protobuf-based serialization. Note, Amino can still be used without any dependency on Protobuf. There are three typical implementations that fulfill this contract:
1. AminoCodec: Provides full Amino serialization compatibility. 2. ProtoCodec: Provides full Protobuf serialization compatibility.
type ProtoCodec ¶
type ProtoCodec struct {
// contains filtered or unexported fields
}
ProtoCodec defines a codec that utilizes Protobuf for both binary and JSON encoding.
func NewProtoCodec ¶
func NewProtoCodec(anyUnpacker types.AnyUnpacker) *ProtoCodec
func (*ProtoCodec) MarshalBinaryBare ¶
func (pc *ProtoCodec) MarshalBinaryBare(o ProtoMarshaler) ([]byte, error)
func (*ProtoCodec) MarshalBinaryLengthPrefixed ¶
func (pc *ProtoCodec) MarshalBinaryLengthPrefixed(o ProtoMarshaler) ([]byte, error)
func (*ProtoCodec) MarshalJSON ¶
func (pc *ProtoCodec) MarshalJSON(o interface{}) ([]byte, error)
func (*ProtoCodec) MustMarshalBinaryBare ¶
func (pc *ProtoCodec) MustMarshalBinaryBare(o ProtoMarshaler) []byte
func (*ProtoCodec) MustMarshalBinaryLengthPrefixed ¶
func (pc *ProtoCodec) MustMarshalBinaryLengthPrefixed(o ProtoMarshaler) []byte
func (*ProtoCodec) MustMarshalJSON ¶
func (pc *ProtoCodec) MustMarshalJSON(o interface{}) []byte
func (*ProtoCodec) MustUnmarshalBinaryBare ¶
func (pc *ProtoCodec) MustUnmarshalBinaryBare(bz []byte, ptr ProtoMarshaler)
func (*ProtoCodec) MustUnmarshalBinaryLengthPrefixed ¶
func (pc *ProtoCodec) MustUnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler)
func (*ProtoCodec) MustUnmarshalJSON ¶
func (pc *ProtoCodec) MustUnmarshalJSON(bz []byte, ptr interface{})
func (*ProtoCodec) Register ¶
func (pc *ProtoCodec) Register(protoName string, iface interface{}, impls ...proto.Message)
func (*ProtoCodec) RegisterImplementation ¶
func (pc *ProtoCodec) RegisterImplementation(iface interface{}, impls ...proto.Message)
func (*ProtoCodec) UnmarshalBinaryBare ¶
func (pc *ProtoCodec) UnmarshalBinaryBare(bz []byte, ptr ProtoMarshaler) error
func (*ProtoCodec) UnmarshalBinaryLengthPrefixed ¶
func (pc *ProtoCodec) UnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler) error
func (*ProtoCodec) UnmarshalJSON ¶
func (pc *ProtoCodec) UnmarshalJSON(bz []byte, ptr interface{}) error
type ProtoMarshaler ¶
type ProtoMarshaler interface { proto.Message // for JSON serialization Marshal() ([]byte, error) MarshalTo(data []byte) (n int, err error) MarshalToSizedBuffer(dAtA []byte) (int, error) Size() int Unmarshal(data []byte) error }
ProtoMarshaler defines an interface a type must implement as protocol buffer defined message.
Directories ¶
Path | Synopsis |
---|---|
Package legacy contains a global amino Cdc which is deprecated but still used in several places within the SDK.
|
Package legacy contains a global amino Cdc which is deprecated but still used in several places within the SDK. |
Package types defines a custom wrapper for google.protobuf.Any which supports cached values as well as InterfaceRegistry which keeps track of types which can be used with Any for both security and introspection
|
Package types defines a custom wrapper for google.protobuf.Any which supports cached values as well as InterfaceRegistry which keeps track of types which can be used with Any for both security and introspection |
unknownproto implements functionality to "type check" protobuf serialized byte sequences against an expected proto.Message to report:
|
unknownproto implements functionality to "type check" protobuf serialized byte sequences against an expected proto.Message to report: |