filtercommon

package
v0.0.0-...-bda353b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package filtercommon transaction filter parameter check

Package filtercommon transaction filter common tools

Package filtercommon transaction filter common config

Package filtercommon stat common

Index

Constants

This section is empty.

Variables

View Source
var (
	// StringNil If the error string is not equal to StringNil then you need to returnup
	StringNil = ""
	// ErrStrSharding Error string prefix "sharding."
	ErrStrSharding = "sharding."
	// ErrStrBirdsNest Error string prefix "brids_nest."
	ErrStrBirdsNest = "brids_nest."
	// ErrStrCuckoo Error string prefix "cuckoo."
	ErrStrCuckoo = "cuckoo."
	// ErrStrSnapshot snapshot. Error string prefix snapshot.
	ErrStrSnapshot = "snapshot."

	// ErrStrInvalidShardingTimeoutMustBeGreaterThan1 Invalid sharding timeout must be greater than 1
	ErrStrInvalidShardingTimeoutMustBeGreaterThan1 = ErrStrSharding + "timeout must be greater than 1"
	// ErrStrInvalidShardingLengthRange2_50 Invalid sharding size range: 2_50
	ErrStrInvalidShardingLengthRange2_50 = ErrStrSharding + "length range 2 ~ 50"
	// ErrStrBirdsNestLength bird's nest length must range from 2 to 100
	ErrStrBirdsNestLength = ErrStrBirdsNest + "length must range from 2 to 100"

	// ErrStrSnapshotPathCannotBeNil snapshot path cannot be nil
	ErrStrSnapshotPathCannotBeNil = ErrStrSnapshot + "path cannot be nil"
	// ErrStrSnapshotSerializeIntervalMustBeGreaterThan0 snapshot serialize_interval must be greater than 0
	ErrStrSnapshotSerializeIntervalMustBeGreaterThan0 = ErrStrSnapshot + "serialize_interval must be greater than 0"

	// ErrStrRulesAbsoluteExpireTimeMustBeGreaterThan0 absolute expire time must be greater than 0
	ErrStrRulesAbsoluteExpireTimeMustBeGreaterThan0 = "rules.absolute_expire_time must be greater than 0"

	// ErrStrCuckooKeyTypeNotSupport cuckoo key type not support
	ErrStrCuckooKeyTypeNotSupport = ErrStrCuckoo + "key_type %v not support"
	// ErrStrInvalidCuckooTableTypeNotSupport cuckoo table_type not support
	ErrStrInvalidCuckooTableTypeNotSupport = ErrStrCuckoo + "table_type not support"
	// ErrStrInvalidCuckooBitsPerItemMustBeGreaterThan0 cuckoo bits_per_item must be greater than 0
	ErrStrInvalidCuckooBitsPerItemMustBeGreaterThan0 = ErrStrCuckoo + "bits_per_item must be greater than 0"
	// ErrStrInvalidCuckooMaxNumKeysMustBeGreaterThan0 cuckoo max_num_keys must be greater than 0
	ErrStrInvalidCuckooMaxNumKeysMustBeGreaterThan0 = ErrStrCuckoo + "max_num_keys must be greater than 0"
	// ErrStrInvalidCuckooTagsPerBucketMustBeGreaterThan0 cuckoo tags_per_bucket must be greater than 0
	ErrStrInvalidCuckooTagsPerBucketMustBeGreaterThan0 = ErrStrCuckoo + "tags_per_bucket must be greater than 0"
)

Functions

func ChaseBlockHeight

func ChaseBlockHeight(store protocol.BlockchainStore, filter protocol.TxFilter, log protocol.Logger) error

ChaseBlockHeight Chase high block

func CheckBNConfig

func CheckBNConfig(c localconf.BirdsNestConfig, isSnapshot bool) string

CheckBNConfig check bird's nest configuration

func CheckShardingBNConfig

func CheckShardingBNConfig(c localconf.ShardingBirdsNestConfig) string

CheckShardingBNConfig check sharding bird's nest configuration

func CheckSnapshot

func CheckSnapshot(c localconf.SnapshotSerializerConfig) string

CheckSnapshot check snapshot configuration

func LoggingFixLength

func LoggingFixLength(format string, args ...interface{}) string

LoggingFixLength The string length is fixed to avoid outputting a large number of logs

func LoggingFixLengthFunc

func LoggingFixLengthFunc(format string, args ...interface{}) func() string

LoggingFixLengthFunc The string length is fixed to avoid outputting a large number of logs

func NewStat

func NewStat(fpCount uint32, filterCosts, dbCosts time.Duration) *txfilter.Stat

NewStat txfilter stat

func NewStat0

func NewStat0(filterCosts, dbCosts time.Duration) *txfilter.Stat

NewStat0 txfilter stat FP count 0

func NewStat1

func NewStat1(filterCosts, dbCosts time.Duration) *txfilter.Stat

NewStat1 txfilter stat FP count 1

Types

type TxFilterConfig

type TxFilterConfig struct {
	// Transaction filter type
	Type TxFilterType `json:"type,omitempty"`
	// Bird's nest configuration
	BirdsNest *bn.BirdsNestConfig `json:"birds_nest,omitempty"`
	// Sharding bird's nest configuration
	ShardingBirdsNest *sbn.ShardingBirdsNestConfig `json:"sharding_birds_nest,omitempty"`
}

TxFilterConfig transaction filter config

func GetConf

func GetConf(chainId string) (*TxFilterConfig, error)

GetConf Get the configuration of the transaction filter

func ToPbConfig

func ToPbConfig(conf localconf.TxFilterConfig, chainId string) (*TxFilterConfig, error)

ToPbConfig Convert localconf.TxFilterConfig to config.TxFilterConfig

type TxFilterLogger

type TxFilterLogger struct {
	// contains filtered or unexported fields
}

TxFilterLogger protocol.Logger wrapper

func NewLogger

func NewLogger(log protocol.Logger) *TxFilterLogger

NewLogger new logger by protocol.Logger

func (TxFilterLogger) Debugf

func (t TxFilterLogger) Debugf(format string, args ...interface{})

Debugf debug sprintf

func (TxFilterLogger) Errorf

func (t TxFilterLogger) Errorf(format string, args ...interface{})

Errorf error sprintf

func (TxFilterLogger) Infof

func (t TxFilterLogger) Infof(format string, args ...interface{})

Infof info sprintf

func (TxFilterLogger) Warnf

func (t TxFilterLogger) Warnf(format string, args ...interface{})

Warnf warning sprintf

type TxFilterType

type TxFilterType int32

TxFilterType Transaction filter type

const (
	// TxFilterTypeDefault Default transaction filter type
	TxFilterTypeDefault TxFilterType = 0
	// TxFilterTypeBirdsNest Bird's Nest transaction filter type
	TxFilterTypeBirdsNest TxFilterType = 1
	// TxFilterTypeMap Map transaction filter type
	TxFilterTypeMap TxFilterType = 2
	// TxFilterTypeShardingBirdsNest Sharding Bird's Nest transaction filter type
	TxFilterTypeShardingBirdsNest TxFilterType = 3
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL