Documentation ¶
Index ¶
- func ConvertToHashSlice(ss []string) []types.Hash
- func ConvertToNumberedEpoch(cfx sdk.ClientOperator, epoch *types.Epoch) (*types.Epoch, error)
- func GetEthHardforkBlockNumber(chainId uint64) web3goTypes.BlockNumber
- func GetShortIdOfHash(hash string) uint64
- func GetSummaryOfBlock(block *types.Block) *types.BlockSummary
- func IncludeCfxLogAddrs(log *types.Log, addresses []cfxaddress.Address) bool
- func IncludeEthLogAddrs(log *web3goTypes.Log, addresses []common.Address) bool
- func IsEip155Tx(tx *web3goTypes.TransactionDetail) bool
- func IsEmptyBlock(block *types.Block) bool
- func IsInterfaceValNil(i interface{}) bool
- func IsLegacyEthTx(tx *web3goTypes.TransactionDetail) bool
- func IsSuccessEthTx(tx *web3goTypes.TransactionDetail) bool
- func IsTxExecutedInBlock(tx *types.Transaction) bool
- func IsValidHashStr(hashStr string) bool
- func IsZeroHash(hash *common.Hash) bool
- func MatchCfxLogTopics(log *types.Log, topics [][]types.Hash) bool
- func MatchEthLogTopics(log *web3goTypes.Log, topics [][]common.Hash) bool
- func MaxInt(a, b int) int
- func MaxUint64(a, b uint64) uint64
- func MinInt(a, b int) int
- func MinUint32(a, b uint32) uint32
- func MinUint64(a, b uint64) uint64
- func MustMarshalJson(v interface{}) []byte
- func MustMarshalRLP(v interface{}) []byte
- func MustUnmarshalJson(data []byte, v interface{})
- func MustUnmarshalRLP(data []byte, v interface{})
- func NormalizeEthBlockNumber(w3c *web3go.Client, blockNum *web3goTypes.BlockNumber, ...) (*web3goTypes.BlockNumber, error)
- func RandUint64(limit uint64) uint64
- func StripLogExtraFieldsForRPC(logs []types.Log)
- func WildCardToRegexp(pattern string) string
- type ConcurrentMap
- type ExpirableLruCache
- func (c *ExpirableLruCache) Add(key, value interface{}) bool
- func (c *ExpirableLruCache) Get(key interface{}) (v interface{}, found bool)
- func (c *ExpirableLruCache) GetOrUpdate(key interface{}, updateFunc func() (interface{}, error)) (interface{}, error)
- func (c *ExpirableLruCache) GetWithoutExp(key interface{}) (v interface{}, expired, found bool)
- type TimeNowFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertToHashSlice ¶
ConvertToHashSlice convert string slice to hash slice
func ConvertToNumberedEpoch ¶
ConvertToNumberedEpoch converts named epoch to numbered epoch if necessary
func GetEthHardforkBlockNumber ¶
func GetEthHardforkBlockNumber(chainId uint64) web3goTypes.BlockNumber
GetEthHardforkBlockNumber gets eSpace hardfork block number by chain ID
func GetShortIdOfHash ¶
func GetSummaryOfBlock ¶
func GetSummaryOfBlock(block *types.Block) *types.BlockSummary
func IncludeCfxLogAddrs ¶
func IncludeCfxLogAddrs(log *types.Log, addresses []cfxaddress.Address) bool
IncludeCfxLogAddrs checks if the core space event logs include any of the given addresses
func IncludeEthLogAddrs ¶
func IncludeEthLogAddrs(log *web3goTypes.Log, addresses []common.Address) bool
IncludeEthLogAddrs checks if the eSpace event logs include any of the given addresses
func IsEip155Tx ¶
func IsEip155Tx(tx *web3goTypes.TransactionDetail) bool
IsEip155Tx check if the EVM transaction is compliant to EIP155
func IsEmptyBlock ¶
IsEmptyBlock checks if block contains any executed transaction(s)
func IsInterfaceValNil ¶
func IsInterfaceValNil(i interface{}) bool
Helper function to check if interface value is nil, since "i == nil" checks nil interface case only. Refer to https://mangatmodi.medium.com/go-check-nil-interface-the-right-way-d142776edef1 for more details.
func IsLegacyEthTx ¶
func IsLegacyEthTx(tx *web3goTypes.TransactionDetail) bool
IsLegacyEthTx check if the EVM transaction is legacy (pre EIP155)
func IsSuccessEthTx ¶
func IsSuccessEthTx(tx *web3goTypes.TransactionDetail) bool
IsSuccessEthTx check if the EVM transaction is success
func IsTxExecutedInBlock ¶
func IsTxExecutedInBlock(tx *types.Transaction) bool
func IsValidHashStr ¶
IsValidHashStr validates if the search (block/tx) hash contains the right characters and in the right length.
func IsZeroHash ¶
func MatchCfxLogTopics ¶
MatchCfxLogTopics checks if the core space event log matches with the given topics condition
func MatchEthLogTopics ¶
func MatchEthLogTopics(log *web3goTypes.Log, topics [][]common.Hash) bool
MatchEthLogTopics checks if the eSpace event log matches with the given topics condition
func MustMarshalJson ¶
func MustMarshalJson(v interface{}) []byte
func MustMarshalRLP ¶
func MustMarshalRLP(v interface{}) []byte
func MustUnmarshalJson ¶
func MustUnmarshalJson(data []byte, v interface{})
func MustUnmarshalRLP ¶
func MustUnmarshalRLP(data []byte, v interface{})
func NormalizeEthBlockNumber ¶
func NormalizeEthBlockNumber( w3c *web3go.Client, blockNum *web3goTypes.BlockNumber, hardforkBlockNumber web3goTypes.BlockNumber, ) (*web3goTypes.BlockNumber, error)
NormalizeEthBlockNumber normalizes ETH block number to be positive if necessary
func RandUint64 ¶
func StripLogExtraFieldsForRPC ¶
StripLogExtraFields strips extra unnecessary fields from logs to comply with fullnode rpc
func WildCardToRegexp ¶
WildCardToRegexp converts a wildcard pattern to a regular expression pattern.
Types ¶
type ConcurrentMap ¶
func (*ConcurrentMap) LoadOrStoreFn ¶
func (m *ConcurrentMap) LoadOrStoreFn( key interface{}, factory func(k interface{}) interface{}, ) (actual interface{}, loaded bool)
func (*ConcurrentMap) LoadOrStoreFnErr ¶
func (m *ConcurrentMap) LoadOrStoreFnErr( key interface{}, factory func(k interface{}) (interface{}, error), ) (actual interface{}, loaded bool, err error)
type ExpirableLruCache ¶
type ExpirableLruCache struct {
// contains filtered or unexported fields
}
ExpirableLruCache naive implementation of LRU cache with fixed TTL expiration duration. This cache uses a lazy eviction policy, by which the expired entry will be purged when it's being looked up.
func NewExpirableLruCache ¶
func (*ExpirableLruCache) Add ¶
func (c *ExpirableLruCache) Add(key, value interface{}) bool
Add adds a value to the cache. Returns true if an eviction occurred.
func (*ExpirableLruCache) Get ¶
func (c *ExpirableLruCache) Get(key interface{}) (v interface{}, found bool)
Get looks up a key's value from the cache. Will purge the entry and return nil if the entry expired.
func (*ExpirableLruCache) GetOrUpdate ¶
func (c *ExpirableLruCache) GetOrUpdate(key interface{}, updateFunc func() (interface{}, error)) (interface{}, error)
GetOrUpdate gets or updates the value for the given cache key. If the entry existed but expired, it will be purged and the updateFunc will be called. If the updateFunc returns an error, the function will return that error. If the entry existed and not expired, the function will return the existing value.
func (*ExpirableLruCache) GetWithoutExp ¶
func (c *ExpirableLruCache) GetWithoutExp(key interface{}) (v interface{}, expired, found bool)
GetWithoutExp looks up a key's value from the cache without expiration action.