Documentation
¶
Index ¶
- Constants
- Variables
- func Abs[T Number](a T) T
- func AddrShort(addr string) string
- func AlmostEqual[T Number](a, b T, tolerance float64) bool
- func BytesToString(b []byte) string
- func CastErrorData(errData []byte, abis []*abi.ABI) (abi.Error, interface{}, bool)
- func CopySlice[T any](s []T) []T
- func CopyURL(u *url.URL) *url.URL
- func DecryptBytes(bytes, privateKey []byte) ([]byte, error)
- func DecryptString(str string, privateKey string) (string, error)
- func EncodeAbiParameters(abiParams []AbiParameter, params []interface{}) ([]byte, error)
- func EncryptString(str string, publicKeyHex string) (string, error)
- func Exp10(exp int) *big.Int
- func ExtractGETHErrorData(err error) ([]byte, bool)
- func Filter[T any](arr []T, f func(T) bool) (ret []T)
- func FilterValue[T comparable](arr []T, val T) (ret []T)
- func GetRandomAddr() common.Address
- func HexToHash(s string) (common.Hash, error)
- func JoinUsername(accountName, userName string) string
- func Merge[T any](cs ...<-chan T) <-chan T
- func MustPrivKeyStringToAddr(privateKey string) common.Address
- func MustPrivKeyToAddr(privateKey *ecdsa.PrivateKey) common.Address
- func MustPubKeyStringFromPrivate(privateKey string) string
- func MustUnmarshallString(value json.RawMessage) string
- func NewRat(numerator, denominator *big.Int) *big.Rat
- func NormalizeJson(msg []byte) ([]byte, error)
- func ParsePort(addr string) (port string)
- func PrivKeyBytesToAddr(privateKey []byte) (common.Address, error)
- func PrivKeyStringToAddr(privateKey string) (common.Address, error)
- func PrivKeyToAddr(privateKey *ecdsa.PrivateKey) (common.Address, error)
- func PubKeyStringFromPrivate(privateKey string) (string, error)
- func ReadJSONFile(filePath string) (string, error)
- func RelativeError[T Number](target, actual T) float64
- func RemoveHexPrefix(s string) string
- func SanitizeFilename(fileName string) string
- func SetUserName(u *url.URL, userName string)
- func SetWorkerName(u *url.URL, workerName string)
- func Short(s Hexable) string
- func SignEthMessage(msg []byte, privateKeyHex string) ([]byte, error)
- func SignEthMessageV2(msg []byte, privateKeyBytes []byte) ([]byte, error)
- func SplitUsername(username string) (accountName string, workerName string, ok bool)
- func StrShort(str string) string
- func StrShortConf(str string, prefix, suffix int) string
- func TCPPipe() (clientConn net.Conn, serverConn net.Conn, err error)
- func TryConvertGethError(err error) error
- func VerifySignature(params []byte, signature []byte, publicKeyBytes []byte) bool
- func VerifySignatureAddr(params []byte, signature []byte, addr common.Address) bool
- func WrapError(parent error, child error) error
- type AbiParameter
- type Address
- type AtomicValue
- type BigInt
- type Bool
- type BoundStackMap
- func (bs *BoundStackMap[T]) At(index int) (T, bool)
- func (bs *BoundStackMap[T]) Capacity() int
- func (bs *BoundStackMap[T]) Clear()
- func (bs *BoundStackMap[T]) Count() int
- func (bs *BoundStackMap[T]) Filter(f func(key string, value T) bool)
- func (bs *BoundStackMap[T]) Get(key string) (T, bool)
- func (bs *BoundStackMap[T]) Push(key string, item T)
- func (bs *BoundStackMap[T]) Range(f func(key string, value T) bool)
- func (bs *BoundStackMap[T]) String() string
- type ChanRecvStop
- type Collection
- type EVMError
- type Hash
- type HexString
- type Hexable
- type ILogger
- type IModel
- type Logger
- type LoggerMock
- func (l *LoggerMock) Close() error
- func (l *LoggerMock) DPanic(args ...interface{})
- func (l *LoggerMock) DPanicf(template string, args ...interface{})
- func (l *LoggerMock) DPanicw(template string, args ...interface{})
- func (l *LoggerMock) Debug(args ...interface{})
- func (l *LoggerMock) Debugf(template string, args ...interface{})
- func (l *LoggerMock) Debugw(template string, args ...interface{})
- func (l *LoggerMock) Error(args ...interface{})
- func (l *LoggerMock) Errorf(template string, args ...interface{})
- func (l *LoggerMock) Errorw(template string, args ...interface{})
- func (l *LoggerMock) Fatal(args ...interface{})
- func (l *LoggerMock) Fatalf(template string, args ...interface{})
- func (l *LoggerMock) Fatalw(template string, args ...interface{})
- func (l *LoggerMock) Info(args ...interface{})
- func (l *LoggerMock) Infof(template string, args ...interface{})
- func (l *LoggerMock) Infow(template string, args ...interface{})
- func (l *LoggerMock) Log(lvl zapcore.Level, msg string, fields ...zapcore.Field)
- func (l *LoggerMock) Named(n string) ILogger
- func (l *LoggerMock) Panic(args ...interface{})
- func (l *LoggerMock) Panicf(template string, args ...interface{})
- func (l *LoggerMock) Panicw(template string, args ...interface{})
- func (l *LoggerMock) Sync() error
- func (l *LoggerMock) Warn(args ...interface{})
- func (l *LoggerMock) Warnf(template string, args ...interface{})
- func (l *LoggerMock) Warnw(template string, args ...interface{})
- func (l *LoggerMock) With(args ...interface{}) ILogger
- type Meta
- type Number
- type Runnable
- type Set
- type Stack
- func (s *Stack[T]) Clear()
- func (s *Stack[T]) Copy() *Stack[T]
- func (s *Stack[T]) IsEmpty() bool
- func (s *Stack[T]) Peek() (T, bool)
- func (s *Stack[T]) Pop() (T, bool)
- func (s *Stack[T]) Push(str T)
- func (s *Stack[T]) Range(f func(T) bool)
- func (s *Stack[T]) Remove(f func(T) bool)
- func (s *Stack[T]) Size() int
- type Subscription
- type Task
Constants ¶
const CharNewLine = '\n'
Variables ¶
var (
ErrInvalidAddress = errors.New("invalid address")
)
var (
ErrInvalidHashLen = errors.New("invalid hash length")
)
var (
ErrInvalidHexString = fmt.Errorf("invalid hex string")
)
var (
ErrInvalidPrivateKey = fmt.Errorf("invalid private key")
)
Functions ¶
func AlmostEqual ¶
func BytesToString ¶
func CastErrorData ¶
CastErrorData casts the error data to the appropriate error type
func DecryptBytes ¶
func EncodeAbiParameters ¶
func EncodeAbiParameters(abiParams []AbiParameter, params []interface{}) ([]byte, error)
func ExtractGETHErrorData ¶
ExtractGETHErrorData extracts the error data from an unexproted geth error
func FilterValue ¶
func FilterValue[T comparable](arr []T, val T) (ret []T)
func GetRandomAddr ¶
func JoinUsername ¶
func MustPrivKeyStringToAddr ¶
func MustPrivKeyToAddr ¶
func MustPrivKeyToAddr(privateKey *ecdsa.PrivateKey) common.Address
func MustUnmarshallString ¶
func MustUnmarshallString(value json.RawMessage) string
func NormalizeJson ¶
NormalizeJson returns normalized json message, without spaces and newlines
func PrivKeyToAddr ¶
func PrivKeyToAddr(privateKey *ecdsa.PrivateKey) (common.Address, error)
func PubKeyStringFromPrivate ¶
func ReadJSONFile ¶
func RelativeError ¶
RelativeError returns relative error between two values
func RemoveHexPrefix ¶
func SanitizeFilename ¶
SanitizeFileName modifies filename to be safe to use as cross-platform file name
func SetUserName ¶
func SetWorkerName ¶
func SplitUsername ¶
func StrShortConf ¶
StrShortConf returns a short version of the string in a format "{prefix chars}..{suffix chars}"
func TryConvertGethError ¶
TryConvertGethError attempts to convert geth error to an EVMError, otherwise just returns original error
func VerifySignature ¶
func VerifySignatureAddr ¶
func WrapError ¶
WrapError allows to use reuse predefined error objects and add dynamic data allowing to create error chains
Example: var ErrEnvParse = errors.New("cannot parse env variable") var err = fmt.Errorf("IS_BUYER should be boolean") wrappedErr := WrapError(ErrEnvParse, err) errors.Is(wrappedErr, ErrEnvParse) // true errors.Unwrap(wrappedErr).Is(err) // true wrappedErr.Error() // "cannot parse env variable: IS_BUYER should be boolean"
Types ¶
type AbiParameter ¶
type AbiParameter struct {
Type string
}
type AtomicValue ¶
type AtomicValue[T any] struct { // contains filtered or unexported fields }
func NewAtomicValue ¶
func NewAtomicValue[T any](v T) *AtomicValue[T]
func (*AtomicValue[T]) CompareAndSwap ¶
func (a *AtomicValue[T]) CompareAndSwap(old, new T) bool
func (*AtomicValue[T]) Load ¶
func (a *AtomicValue[T]) Load() T
func (*AtomicValue[T]) Store ¶
func (a *AtomicValue[T]) Store(v T)
func (*AtomicValue[T]) Swap ¶
func (a *AtomicValue[T]) Swap(v T) T
type BigInt ¶
func (BigInt) MarshalJSON ¶
func (*BigInt) UnmarshalJSON ¶
Enables the use of big.Int as a JSON field
type BoundStackMap ¶
type BoundStackMap[T any] struct { // contains filtered or unexported fields }
func NewBoundStackMap ¶
func NewBoundStackMap[T any](size int) *BoundStackMap[T]
NewBoundStackMap creates a new map with the limited capacity, where new records overwrite the oldest ones. The map is thread-safe
func (*BoundStackMap[T]) At ¶
func (bs *BoundStackMap[T]) At(index int) (T, bool)
func (*BoundStackMap[T]) Capacity ¶
func (bs *BoundStackMap[T]) Capacity() int
func (*BoundStackMap[T]) Clear ¶
func (bs *BoundStackMap[T]) Clear()
func (*BoundStackMap[T]) Count ¶
func (bs *BoundStackMap[T]) Count() int
func (*BoundStackMap[T]) Filter ¶
func (bs *BoundStackMap[T]) Filter(f func(key string, value T) bool)
func (*BoundStackMap[T]) Get ¶
func (bs *BoundStackMap[T]) Get(key string) (T, bool)
func (*BoundStackMap[T]) Push ¶
func (bs *BoundStackMap[T]) Push(key string, item T)
func (*BoundStackMap[T]) Range ¶
func (bs *BoundStackMap[T]) Range(f func(key string, value T) bool)
func (*BoundStackMap[T]) String ¶
func (bs *BoundStackMap[T]) String() string
type ChanRecvStop ¶
type ChanRecvStop[T any] struct { DataCh chan T StopCh chan struct{} }
func NewChanRecvStop ¶
func NewChanRecvStop[T any]() *ChanRecvStop[T]
NewChanRecvStop creates a new ChanRecvStop, an abstraction over a channel that supports multiple writers and a single reader. The writes can be stopped and/or unblocked by calling the Stop method from a reader
func (*ChanRecvStop[T]) Receive ¶
func (c *ChanRecvStop[T]) Receive() <-chan T
func (*ChanRecvStop[T]) Send ¶
func (c *ChanRecvStop[T]) Send(data T)
func (*ChanRecvStop[T]) Stop ¶
func (c *ChanRecvStop[T]) Stop()
type Collection ¶
type Collection[T IModel] struct { // contains filtered or unexported fields }
func NewCollection ¶
func NewCollection[T IModel]() *Collection[T]
func (*Collection[T]) Delete ¶
func (p *Collection[T]) Delete(ID string)
func (*Collection[T]) Len ¶
func (p *Collection[T]) Len() int
Len returns the number of items in the collection. It is O(n)
func (*Collection[T]) Load ¶
func (p *Collection[T]) Load(ID string) (item T, ok bool)
func (*Collection[T]) LoadOrStore ¶
func (p *Collection[T]) LoadOrStore(item T) (actual T, loaded bool)
func (*Collection[T]) Range ¶
func (p *Collection[T]) Range(f func(item T) bool)
func (*Collection[T]) Store ¶
func (p *Collection[T]) Store(item T)
type EVMError ¶
func ConvertGethError ¶
ConvertGethError converts a geth error to an EVMError with exposed error signature and arguments
type Hash ¶
func GetRandomHash ¶
func MustStringToHash ¶
func StringToHash ¶
func (*Hash) UnmarshalParam ¶
type HexString ¶
type HexString []byte
Arbitrary length hex string represented internally as a byte slice
func MustStringToHexString ¶
func PubKeyFromPrivate ¶
func StringToHexString ¶
func (HexString) MarshalJSON ¶
func (*HexString) UnmarshalJSON ¶
func (*HexString) UnmarshalText ¶
type ILogger ¶
type ILogger interface { Debug(args ...interface{}) Info(args ...interface{}) Warn(args ...interface{}) Error(args ...interface{}) DPanic(args ...interface{}) // Development panic - panics only in development mode Panic(args ...interface{}) Fatal(args ...interface{}) Debugf(template string, args ...interface{}) Infof(template string, args ...interface{}) Warnf(template string, args ...interface{}) Errorf(template string, args ...interface{}) DPanicf(template string, args ...interface{}) Panicf(template string, args ...interface{}) Fatalf(template string, args ...interface{}) Debugw(msg string, keysAndValues ...interface{}) Infow(msg string, keysAndValues ...interface{}) Warnw(msg string, keysAndValues ...interface{}) Errorw(msg string, keysAndValues ...interface{}) DPanicw(msg string, keysAndValues ...interface{}) Panicw(msg string, keysAndValues ...interface{}) Fatalw(msg string, keysAndValues ...interface{}) Log(lvl zapcore.Level, msg string, fields ...zapcore.Field) Sync() error Close() error Named(name string) ILogger With(args ...interface{}) ILogger }
type Logger ¶
type Logger struct { *zap.SugaredLogger // contains filtered or unexported fields }
func NewLoggerMemory ¶
type LoggerMock ¶
type LoggerMock struct{}
func (*LoggerMock) Close ¶
func (l *LoggerMock) Close() error
func (*LoggerMock) DPanic ¶
func (l *LoggerMock) DPanic(args ...interface{})
func (*LoggerMock) DPanicf ¶
func (l *LoggerMock) DPanicf(template string, args ...interface{})
func (*LoggerMock) DPanicw ¶
func (l *LoggerMock) DPanicw(template string, args ...interface{})
func (*LoggerMock) Debug ¶
func (l *LoggerMock) Debug(args ...interface{})
func (*LoggerMock) Debugf ¶
func (l *LoggerMock) Debugf(template string, args ...interface{})
func (*LoggerMock) Debugw ¶
func (l *LoggerMock) Debugw(template string, args ...interface{})
func (*LoggerMock) Error ¶
func (l *LoggerMock) Error(args ...interface{})
func (*LoggerMock) Errorf ¶
func (l *LoggerMock) Errorf(template string, args ...interface{})
func (*LoggerMock) Errorw ¶
func (l *LoggerMock) Errorw(template string, args ...interface{})
func (*LoggerMock) Fatal ¶
func (l *LoggerMock) Fatal(args ...interface{})
func (*LoggerMock) Fatalf ¶
func (l *LoggerMock) Fatalf(template string, args ...interface{})
func (*LoggerMock) Fatalw ¶
func (l *LoggerMock) Fatalw(template string, args ...interface{})
func (*LoggerMock) Info ¶
func (l *LoggerMock) Info(args ...interface{})
func (*LoggerMock) Infof ¶
func (l *LoggerMock) Infof(template string, args ...interface{})
func (*LoggerMock) Infow ¶
func (l *LoggerMock) Infow(template string, args ...interface{})
func (*LoggerMock) Named ¶
func (l *LoggerMock) Named(n string) ILogger
func (*LoggerMock) Panic ¶
func (l *LoggerMock) Panic(args ...interface{})
func (*LoggerMock) Panicf ¶
func (l *LoggerMock) Panicf(template string, args ...interface{})
func (*LoggerMock) Panicw ¶
func (l *LoggerMock) Panicw(template string, args ...interface{})
func (*LoggerMock) Sync ¶
func (l *LoggerMock) Sync() error
func (*LoggerMock) Warn ¶
func (l *LoggerMock) Warn(args ...interface{})
func (*LoggerMock) Warnf ¶
func (l *LoggerMock) Warnf(template string, args ...interface{})
func (*LoggerMock) Warnw ¶
func (l *LoggerMock) Warnw(template string, args ...interface{})
func (*LoggerMock) With ¶
func (l *LoggerMock) With(args ...interface{}) ILogger
type Number ¶
type Number interface { constraints.Integer | constraints.Float }
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
func NewSubscription ¶
func NewSubscription(producer func(quit <-chan struct{}) error, ch chan interface{}) *Subscription
func (*Subscription) Ch ¶
func (s *Subscription) Ch() chan interface{}
func (*Subscription) Err ¶
func (s *Subscription) Err() <-chan error
func (*Subscription) Events ¶
func (s *Subscription) Events() <-chan interface{}
func (*Subscription) Unsubscribe ¶
func (s *Subscription) Unsubscribe()
type Task ¶
type Task struct {
// contains filtered or unexported fields
}
Task is a wrapper around a function that can be started and stopped
func NewTask ¶
NewTask creates a new task from Runnable that runs in a separate goroutine that can be started and stopped
func NewTaskFunc ¶
NewTaskFunc creates a new task from a function that runs in a separate goroutine that can be started and stopped