osmoutils

package
v10.0.1-0...-246915f Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func ApplyFuncIfNoError

func ApplyFuncIfNoError(ctx sdk.Context, f func(ctx sdk.Context) error) (err error)

This function lets you run the function f, but if theres an error or panic drop the state machine change and log the error. If there is no error, proceeds as normal (but with some slowdown due to SDK store weirdness) Try to avoid usage of iterators in f.

func BinarySearch

func BinarySearch(f func(input sdk.Int) (sdk.Int, error),
	lowerbound sdk.Int,
	upperbound sdk.Int,
	targetOutput sdk.Int,
	errTolerance ErrTolerance,
	maxIterations int) (sdk.Int, error)

Binary search inputs between [lowerbound, upperbound] to a monotonic increasing function f. We stop once f(found_input) meets the ErrTolerance constraints. If we perform more than maxIterations (or equivalently lowerbound = upperbound), we return an error.

func DecApproxEq

func DecApproxEq(t *testing.T, d1 sdk.Dec, d2 sdk.Dec, tol sdk.Dec) (*testing.T, bool, string, string, string)

intended to be used with require/assert: require.True(DecEq(...)) TODO: Replace with function in SDK types package when we update

func DefaultFeeString

func DefaultFeeString(cfg network.Config) string

func ParseSdkIntFromString

func ParseSdkIntFromString(s string, separator string) ([]sdk.Int, error)

func ParseUint64SliceFromString

func ParseUint64SliceFromString(s string, separator string) ([]uint64, error)

func PrintPanicRecoveryError

func PrintPanicRecoveryError(ctx sdk.Context, recoveryError interface{})

PrintPanicRecoveryError error logs the recoveryError, along with the stacktrace, if it can be parsed. If not emits them to stdout.

Types

type ErrTolerance

type ErrTolerance struct {
	AdditiveTolerance       sdk.Int
	MultiplicativeTolerance sdk.Dec
}

ErrTolerance is used to define a compare function, which checks if two ints are within a certain error tolerance of one another. ErrTolerance.Compare(a, b) returns true iff: |a - b| <= AdditiveTolerance |a - b| / min(a, b) <= MultiplicativeTolerance Each check is respectively ignored if the entry is nil (sdk.Dec{}, sdk.Int{}) Note that if AdditiveTolerance == 0, then this is equivalent to a standard compare.

func (ErrTolerance) Compare

func (e ErrTolerance) Compare(expected sdk.Int, actual sdk.Int) int

Compare returns if actual is within errTolerance of expected. returns 0 if it is returns 1 if not, and expected > actual. returns -1 if not, and expected < actual

type Proposal

type Proposal struct {
	Title       string
	Description string
	Deposit     string
}

func ParseProposalFlags

func ParseProposalFlags(fs *pflag.FlagSet) (*Proposal, error)

Directories

Path Synopsis
package partialord allows one to define partial orderings, and derive a total ordering
package partialord allows one to define partial orderings, and derive a total ordering
internal/dag
Package dag implements a simple Directed Acyclical Graph (DAG) for deterministic topological sorts It should not be externally exposed, and is intended to be a very simple dag implementation utilizing adjacency lists to store edges.
Package dag implements a simple Directed Acyclical Graph (DAG) for deterministic topological sorts It should not be externally exposed, and is intended to be a very simple dag implementation utilizing adjacency lists to store edges.

Jump to

Keyboard shortcuts

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