Documentation ¶
Index ¶
- Variables
- func FromLengthPrefix(rawData []byte) ([]byte, error)
- func SplitCW20BalanceKey(key []byte) (string, string, error)
- func SplitCW20TokenInfoKey(key []byte) (string, error)
- func SplitDelegationKey(key []byte) (string, string, error)
- type DataProcessor
- type DataProcessorFunc
- type Operation
- type SDKModuleName
- type TraceOperation
- type TraceWatcher
- type TracingError
- type WritebackOp
- type WritebackStatementTypes
Constants ¶
This section is empty.
Variables ¶
var SupportedSDKModuleList = map[SDKModuleName]struct{}{ Bank: {}, IBC: {}, Staking: {}, Distribution: {}, Transfer: {}, Acc: {}, CW20: {}, }
SupportedSDKModuleList holds all the Cosmos SDK module names tracelistener supports.
Functions ¶
func FromLengthPrefix ¶
FromLengthPrefix returns the amount of data signaled by the single-byte length prefix in rawData.
func SplitCW20BalanceKey ¶
SplitCW20BalanceKey returns the contract and the holder address of a given CW20 balance key, or an error if it's not valid. param <key> is a list of bytes. The key is a concatenation of 5 parts, 1. Prefix length: 1 Byte (always 03 for ContractStorePrefix) 2. Contract Address length: 32 Bytes 3. Type Len length: 2 Bytes 4. Type length: From 3 5. Holder Address length: the remaining bytes key : <prefix><contract-address><type-len><type><holder-address> Len 1 32 2 0-510 at least 43
Note: Address len 0 does not make sense, but since in the SDK it's "possible" to have 0 len address for delegator/validator, we also consider empty address valid.
func SplitCW20TokenInfoKey ¶
SplitCW20TokenInfoKey returns the contract address of a given CW20 token_info key, or an error if it's not valid. param <key> is a list of bytes. The key is a concatenation of 5 parts, 1. Prefix length: 1 Byte (always 03 for ContractStorePrefix) 2. Contract Address length: 32 Bytes 4. Type length: 10 Bytes (always token_info) key : <prefix><contract-address><type> Len 1 32 10
func SplitDelegationKey ¶
SplitDelegationKey given a key, split it into prefix, delegator and validator address. param <key> is a list of byte. The key is a concatenation of 5 parts, 1. Prefix length: 1 Byte 2. Delegator Address Len length: 1 Byte 3. Delegator Address length: From 2 4. Validator Address Len length: 1 Byte 5. Validator Address length: From 4 key : <prefix><del-addr-len><del-addr><val-addr-len><val-addr> Len 1 1 0-255 1 0-255
Note: Address len 0 does not make sense, but since in the SDK it's "possible" to have 0 len address for delegator/validator, we also consider empty address valid.
Types ¶
type DataProcessor ¶
type DataProcessor interface { OpsChan() chan TraceOperation WritebackChan() chan []WritebackOp ErrorsChan() chan error DatabaseMigrations() []string Flush() error SetDBUpsertEnabled(enabled bool) StartBackgroundProcessing() StopBackgroundProcessing() }
type DataProcessorFunc ¶
type DataProcessorFunc func(logger *zap.SugaredLogger, cfg *config.Config) (DataProcessor, error)
DataProcessorFunc is the type of function used to initialize a data processor.
type Operation ¶
type Operation []byte
Operation is a kind of operations a TraceWatcher observes.
var ( // WriteOp is a write trace operation WriteOp Operation = []byte("write") // DeleteOp is a write trace operation DeleteOp Operation = []byte("delete") // ReadOp is a write trace operation ReadOp Operation = []byte("read") // IterRangeOp is a write trace operation IterRangeOp Operation = []byte("iterRange") )
type SDKModuleName ¶
type SDKModuleName string
SDKModuleName represent a Cosmos SDK module name, available under the 'x' directory in the SDK codebase.
const ( // Bank SDK module Bank SDKModuleName = "bank" // IBC SDK module IBC SDKModuleName = "ibc" // Staking SDK module Staking SDKModuleName = "staking" // Distribution SDK module Distribution SDKModuleName = "distribution" // IBC Transfer SDK module Transfer SDKModuleName = "transfer" // Account storage SDK module Acc SDKModuleName = "acc" // CW20 token module CW20 SDKModuleName = "cw20" )
func (SDKModuleName) String ¶
func (smn SDKModuleName) String() string
String implements the fmt.Stringer interface.
type TraceOperation ¶
type TraceOperation struct { Operation string `json:"operation"` Key []byte `json:"key"` Value []byte `json:"value"` BlockHeight uint64 `json:"block_height"` TxHash string `json:"tx_hash"` // SuggestedProcessor signals to the trace processor that // what SDK module this trace comes from. // Json key is defined here: https://github.com/cosmos/cosmos-sdk/blob/9898ac5e9dea5f40427f925c70bbc1ab0d52ed77/store/cachemulti/store.go#L18. SuggestedProcessor SDKModuleName `json:"store_name"` }
func (TraceOperation) String ¶
func (t TraceOperation) String() string
func (*TraceOperation) UnmarshalJSON ¶
func (t *TraceOperation) UnmarshalJSON(bytes []byte) error
type TraceWatcher ¶
type TraceWatcher struct { DataSourcePath string WatchedOps []Operation DataChan chan<- TraceOperation ErrorChan chan<- error Logger *zap.SugaredLogger }
TraceWatcher watches DataSource for WatchedOps, sends observed data over DataChan. Any observing error will be sent over ErrorChan. If WatchedOps is nil, all store operations will be sent over DataChan.
func (*TraceWatcher) ParseOperation ¶
func (tr *TraceWatcher) ParseOperation(data TraceOperation) error
func (*TraceWatcher) Watch ¶
func (tr *TraceWatcher) Watch(exporter *exporter.Exporter)
type TracingError ¶
type TracingError struct { InnerError error Module string Data TraceOperation }
func (TracingError) Error ¶
func (t TracingError) Error() string
type WritebackOp ¶
type WritebackOp struct { Type WritebackStatementTypes Data []models.DatabaseEntrier Statement string // SourceModule indicates the SDK module which initiated a WritebackOp. // It is used in bulk importing only. SourceModule string }
WritebackOp represents a unit of database writeback operated by a processor. It contains the database query to be executed along with a slice of DatabaseEntrier data.
func (WritebackOp) DBPlaceholderAmount ¶
func (wo WritebackOp) DBPlaceholderAmount() int64
DBPlaceholderAmount returns the total amount of database placeholders in wo.Data.
func (WritebackOp) DBSinglePlaceholderAmount ¶
func (wo WritebackOp) DBSinglePlaceholderAmount() int64
DBSinglePlaceholderAmount returns the amount of struct fields of a single object in wo.Data.
func (WritebackOp) InterfaceSlice ¶
func (wo WritebackOp) InterfaceSlice() []interface{}
InterfaceSlice returns Data as a slice of interface{}.
func (WritebackOp) SplitStatementToDBLimit ¶
func (wo WritebackOp) SplitStatementToDBLimit() []WritebackOp
SplitStatementToDBLimit splits wo into slices up to CockroachDB placeholder limit.
func (WritebackOp) SplitStatements ¶
func (wo WritebackOp) SplitStatements(limit int) []WritebackOp
SplitStatements returns a slice of WritebackOps on which the total amount of database statement placeholders is either equal to, or slightly less than limit.
type WritebackStatementTypes ¶
type WritebackStatementTypes uint
const ( Delete WritebackStatementTypes = iota Write )
func (WritebackStatementTypes) String ¶
func (i WritebackStatementTypes) String() string