package
0.5.0
Repository: https://github.com/goplugin/pluginv2.git
Documentation: pkg.go.dev

# README

package utils

StartStopOnce

stateDiagram-v2
    [*] --> Unstarted
    Unstarted --> Starting : StartOnce()
    Starting --> StartFailed
    Starting --> Started
    Started --> Stopping : StopOnce()
    Stopping --> Stopped
    Stopping --> StopFailed
    StartFailed --> [*]
    Stopped --> [*]
    StopFailed --> [*]

# Packages

Package bigmath compensates for awkward big.Int API.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

ABIEncode is the equivalent of abi.decode.
ABIEncode is the equivalent of abi.encode.
AddHexPrefix adds the prefix (0x) to a given hex string.
AllEqual returns true iff all the provided elements are equal to each other.
BatchSplit splits an slices into an slices of slicess with a maximum length.
BoxOutput formats its arguments as fmt.Printf, and encloses them in a box of arrows pointing at their content, in order to better highlight it.
Bytes32FromString returns a 32 byte array filled from the given string, which may be of any length.
No description provided by the author
Bytes4FromString returns a 4 byte array filled from the given string, which may be of any length.
CheckPasswordHash wraps around bcrypt.CompareHashAndPassword for a friendlier API.
CheckUint256 returns an error if n is out of bounds for a uint256.
ConcatBytes appends a bunch of byte arrays into a single byte array.
ContextFromChan creates a context that finishes when the provided channel receives or is closed.
ContextFromChanWithDeadline creates a context with a deadline that finishes when the provided channel receives or is closed.
DurationFromNow returns the amount of time since the Time field was last updated.
EIP55CapitalizedAddress returns true iff possibleAddressString has the correct capitalization for an Ethereum address, per EIP 55.
EnsureClosed closes the io.Closer, returning nil if it was already closed or not started yet.
EnsureDirAndMaxPerms ensures that the given path exists, that it's a directory, and that it has permissions that are no more permissive than the given ones.
EnsureFileMaxPerms ensures that the given file has permissions that are no more permissive than the given ones.
EnsureFilepathMaxPerms ensures that the file at the given filepath has permissions that are no more permissive than the given ones.
EVMBytesToUint64 converts a bytebuffer to uint64.
EVMEncodeBytes encodes arbitrary bytes as bytes expected by the EVM.
EVMTranscodeBool converts a json input to an EVM bool.
EVMTranscodeInt256 converts a json input to an EVM int256.
EVMTranscodeUint256 converts a json input to an EVM uint256.
EVMWordBigInt returns a big.Int as an EVM word byte array, with support for a signed representation.
EVMWordSignedBigInt returns a big.Int as an EVM word byte array, with support for a signed representation.
EVMWordUint128 returns a uint128 as an EVM word byte array.
EVMWordUint32 returns a uint32 as an EVM word byte array.
EVMWordUint64 returns a uint64 as an EVM word byte array.
FileExists returns true if a file at the passed string exists.
FiniteTicker starts a goroutine to execute the given function periodically, until the returned function is called.
FormatJSON applies indent to format a JSON response.
GetScryptParams fetches ScryptParams from a ScryptConfigReader.
HasHexPrefix returns true if the string starts with 0x.
HashPassword wraps around bcrypt.GenerateFromPassword for a friendlier API.
HexToBig parses the given hex string or panics if it is invalid.
HexToUint256 returns the uint256 represented by s, or an error if it doesn't represent one.
IsEmpty returns true if bytes contains only zero values, or has len 0.
IsEmptyAddress checks that the address is empty, synonymous with the zero account/address.
IsFileOwnedByChainlink attempts to read fileInfo to verify file owner.
ISO8601UTC formats given time to ISO8601.
IsQuoted checks if the first and last characters are either " or '.
JustError takes a tuple and returns the last entry, the error.
Keccak256 is a simplified interface for the legacy SHA3 implementation that Ethereum uses.
No description provided by the author
No description provided by the author
MinKey returns the minimum value of the given element array with respect to the given key function.
MultiErrorList returns an error which formats underlying errors as a list, or nil if err is nil.
No description provided by the author
MustHash returns the keccak256 hash, or panics on failure.
No description provided by the author
MustUnmarshalToMap performs UnmarshalToMap, panics upon failure.
NewBackoffSleeper returns a BackoffSleeper that is configured to sleep for 0 seconds initially, then backs off from 1 second minimum to 10 seconds maximum.
NewBackoffTicker returns a new BackoffTicker for the given range.
NewBig constructs a Big from *big.Int.
NewBigI constructs a Big from int64.
NewBoundedPriorityQueue creates a new BoundedPriorityQueue.
NewBoundedQueue creates a new BoundedQueue instance.
NewBytes32ID returns a randomly generated UUID that conforms to Ethereum bytes32.
NewCronTicker returns a new CrontTicker for the given schedule.
NewDeferableWriteCloser creates a deferable writercloser.
NewDependentAwaiter creates a new DependentAwaiter.
NewDiskStatsProvider returns a new `DiskStatsProvider` instance.
NewHash return random Keccak256.
NewHighCapacityMailbox create a new mailbox with a capacity that is better able to handle e.g.
No description provided by the author
NewMailbox creates a new mailbox instance.
No description provided by the author
NewPausableTicker creates a new PausableTicker.
NewRedialBackoff is a standard backoff to use for redialling or reconnecting to unreachable network endpoints.
NewResettableTimer creates a new ResettableTimer.
NewSecret returns a new securely random sequence of n bytes of entropy.
NewSingleMailbox returns a new Mailbox with capacity one.
NewSleeperTask takes a worker and returns a SleeperTask.
NormalizedJSON returns a JSON representation of an object that has been normalized to produce a consistent output for hashing.
PadByteToHash returns a hash with zeros padded on the left of the given byte.
ParseEthereumAddress returns addressString as a go-ethereum Address, or an error if it's invalid, e.g.
No description provided by the author
No description provided by the author
No description provided by the author
RandUint256 generates a random bigNum up to 2 ** 256 - 1.
RemoveHexPrefix removes the prefix (0x) of a given hex string.
RemoveQuotes removes the first and last character if they are both either " or ', otherwise it is a noop.
RetryWithBackoff retries the sleeper and backs off if not Done.
Sha256 returns a hexadecimal encoded string of a hashed input.
SleeperFuncTask returns a Worker to execute the given work function.
StringToHex converts a standard string to a hex encoded string.
ToDecimal converts an input to a decimal.
TooPermissive checks if the file has more than the allowed permissions.
TryParseHex parses the given hex string to bytes, it can return error if the hex string is invalid.
Uint256ToBytes is x represented as the bytes of a uint256.
Uint256ToBytes32 returns the bytes32 encoding of the big int provided.
UnmarshalToMap takes an input json string and returns a map[string]interface i.e.
ValidateCronSchedule returns an error if the given schedule is invalid.
No description provided by the author
WaitGroupChan creates a channel that closes when the provided sync.WaitGroup is done.
WithCloseChan wraps a context so that it is canceled if the passed in channel is closed.
WithJitter adds +/- 10% to a duration.
WrapIfError decorates an error with the given message.
WriteFileWithMaxPerms writes `data` to `path` and ensures that the file has permissions that are no more permissive than the given ones.

# Constants

DefaultSecretSize is the entropy in bytes to generate a base64 string of 64 characters.
EVMWordByteLen the length of an EVM Word Byte.
FastN is a shorter N parameter for testing.
FastP is a shorter P parameter for testing.
FormatBool encodes the output as bytes containing a bool.
FormatBytes encodes the output as bytes.
FormatInt256 encodes the output as bytes containing an int256.
FormatPreformatted encodes the output, assumed to be hex, as bytes.
FormatUint256 encodes the output as bytes containing a uint256.
nolint.
nolint.
nolint.
No description provided by the author
PasswordComplexityRequirements defines the complexity requirements message Note that adding an entropy requirement wouldn't add much, since a 16 character password already has an entropy score of 75 even if it's all lowercase characters.
nolint.
nolint.
nolint.
nolint.
nolint.
nolint.
nolint.
nolint.

# Variables

DefaultScryptParams is for use in production.
EmptyHash is a hash of all zeroes, otherwise in Ethereum as 0x0000000000000000000000000000000000000000000000000000000000000000.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
FastScryptParams is for use in tests, where you don't want to wear out your CPU with expensive key derivations, do not use it in production, or your encrypted keys will be easy to brute-force!.
No description provided by the author
MaxInt256 represents the largest number represented by an EVM word using signed encoding.
MaxUint256 represents the largest number represented by an EVM word.
MinInt256 represents the smallest number represented by an EVM word using signed encoding.
No description provided by the author
ZeroAddress is an address of all zeroes, otherwise in Ethereum as 0x0000000000000000000000000000000000000000.

# Structs

BackoffSleeper is a sleeper that backs off on subsequent attempts.
BackoffTicker sends ticks with periods that increase over time, over a configured range.
BoundedPriorityQueue stores a series of BoundedQueues with associated priorities and capacities.
BoundedQueue is a FIFO queue that discards older items when it reaches its capacity.
CronTicker is like a time.Ticker but for a cron schedule.
DeferableWriteCloser is to be used in leiu of defer'ing Close on an [io.WriteCloser] (// For more background see https://www.joeshaw.org/dont-defer-close-on-writable-files/) Callers should *both* explicitly call Close and check for errors when done with the underlying writerclose *and* defer the Close() to handle returns before the explicit close For example rather than import "os" f, err := os.Create("./foo") if err != nil { return err} defer f.Close() return f.Write([]bytes("hi")) do import "os" f, err := os.Create("./foo") if err != nil {return nil} wc := NewDeferableWriteCloser(f) defer wc.Close() err = wc.Write([]bytes("hi")) if err != nil {return err} return wc.Close().
KeyedMutex allows to lock based on particular values.
No description provided by the author
Mailbox contains a notify channel, a mutual exclusive lock, a queue of interfaces, and a queue capacity.
No description provided by the author
PausableTicker stores a ticker with a duration.
ResettableTimer stores a timer.
No description provided by the author
StartStopOnce contains a StartStopOnceState integer.

# Interfaces

DependentAwaiter contains Dependent funcs.
DiskStatsProvider describes the abstraction to the `shirou/gopsutil/v3` for mocking purposes.
No description provided by the author
Sleeper interface is used for tasks that need to be done on some interval, excluding Cron, like reconnecting.
SleeperTask represents a task that waits in the background to process some work.
TickerBase is an interface for pausable tickers.
Worker is a simple interface that represents some work to do repeatedly.

# Type aliases

Big stores large integers and can deserialize a variety of inputs.
BigFloat accepts both string and float JSON values.
FileSize repesents a file size in bytes.
StartStopOnceState holds the state for StartStopOnce.