Documentation ¶
Index ¶
- Variables
- func BigIntDivCeil(a, b *big.Int) *big.Int
- func BigMin(x, y *big.Int) *big.Int
- func ConvertUnmarshalledUint(x interface{}) (uint64, error)
- func CreateDirSafe(path string, perms fs.FileMode) error
- func DirectoryExists(directoryPath string) bool
- func EncodeBigInt(b *big.Int) *string
- func EncodeBytes(b []byte) *string
- func EncodeBytesToUint64(b []byte) uint64
- func EncodeUint64(b uint64) *string
- func EncodeUint64ToBytes(value uint64) []byte
- func ExtendByteSlice(b []byte, needLength int) []byte
- func FileExists(filePath string) bool
- func GetTerminationSignalCh() <-chan os.Signal
- func IsContextDone(err error) bool
- func Max(a, b uint64) uint64
- func Min(a, b uint64) uint64
- func PadLeftOrTrim(bb []byte, size int) []byte
- func ParseBytes(val *string) ([]byte, error)
- func ParseUint256orHex(val *string) (*big.Int, error)
- func ParseUint64orHex(val *string) (uint64, error)
- func RetryForever(ctx context.Context, interval time.Duration, fn func(context.Context) error)
- func SafeAddUint64(a, b uint64) (uint64, bool)
- func SaveFileSafe(path string, data []byte, perms fs.FileMode) error
- func SetupDataDir(dataDir string, paths []string, perms fs.FileMode) error
- type Duration
- type JSONNumber
Constants ¶
This section is empty.
Variables ¶
var ( // MaxSafeJSInt represents max value which JS support // It is used for smartContract fields // Our staking repo is written in JS, as are many other clients // If we use higher value JS will not be able to parse it MaxSafeJSInt = uint64(math.Pow(2, 53) - 2) IBFTImportantNotice = "***** IMPORTANT NOTICE: IBFT consensus protocol is about to be" + " removed from the Edge in the following release. *****\n" + "Please migrate to the PolyBFT protocol and plan your activities accordingly.\n" + "More information on how to execute the migration process can be found here" + "(https://wiki.polygon.technology/docs/edge/operate/ibft-to-polybft/)." )
Functions ¶
func BigIntDivCeil ¶
BigIntDivCeil performs integer division and rounds given result to next bigger integer number It is calculated using this formula result = (a + b - 1) / b
func ConvertUnmarshalledUint ¶
func CreateDirSafe ¶
Creates a directory at path and with perms level permissions. If directory already exists, owner and permissions are verified.
func DirectoryExists ¶
DirectoryExists checks if the directory at the specified path exists
func EncodeBigInt ¶
func EncodeBytes ¶
func EncodeBytesToUint64 ¶
EncodeBytesToUint64 big endian byte slice to uint64
func EncodeUint64 ¶
func EncodeUint64ToBytes ¶
EncodeUint64ToBytes encodes provided uint64 to big endian byte slice
func ExtendByteSlice ¶
ExtendByteSlice extends given byte slice by needLength parameter and trims it
func FileExists ¶
Checks if the file at the specified path exists
func GetTerminationSignalCh ¶
GetTerminationSignalCh returns a channel to emit signals by ctrl + c
func IsContextDone ¶
IsContextDone returns true if the error is due to the context being cancelled or expired. This is useful for determining if a function should retry.
func PadLeftOrTrim ¶
PadLeftOrTrim left-pads the passed in byte array to the specified size, or trims the array if it exceeds the passed in size
func ParseBytes ¶
func ParseUint64orHex ¶
ParseUint64orHex parses the given uint64 hex string into the number. It can parse the string with 0x prefix as well.
func RetryForever ¶
RetryForever will execute a function until it completes without error or the context is cancelled or expired.
func SafeAddUint64 ¶
SafeAddUint64 sums two unsigned int64 numbers if there is no overflow. In case there is an overflow, it would return 0 and true, otherwise sum and false.
func SaveFileSafe ¶
Creates a file at path and with perms level permissions. If file already exists, owner and permissions are verified, and the file is overwritten.
Types ¶
type Duration ¶
Duration is a wrapper struct for time.Duration which implements json (un)marshaling
func (Duration) MarshalJSON ¶
func (*Duration) UnmarshalJSON ¶
type JSONNumber ¶
type JSONNumber struct {
Value uint64
}
JSONNumber is the number represented in decimal or hex in json
func (*JSONNumber) MarshalJSON ¶
func (d *JSONNumber) MarshalJSON() ([]byte, error)
func (*JSONNumber) UnmarshalJSON ¶
func (d *JSONNumber) UnmarshalJSON(data []byte) error