Documentation ¶
Index ¶
- Variables
- func BigIntDivCeil(a, b *big.Int) *big.Int
- func ConvertUnmarshalledUint(x interface{}) (uint64, error)
- func CreateDirSafe(path string, perms fs.FileMode) error
- func DirectoryExists(directoryPath string) bool
- func EncodeUint64ToBytes(value uint64) []byte
- func ExtendByteSlice(b []byte, needLength int) []byte
- func FileExists(filePath string) bool
- func GetTerminationSignalCh() <-chan os.Signal
- func Max(a, b uint64) uint64
- func Min(a, b uint64) uint64
- func PadLeftOrTrim(bb []byte, size int) []byte
- func SaveFileSafe(path string, data []byte, perms fs.FileMode) error
- func SetupDataDir(dataDir string, paths []string, perms fs.FileMode) error
- func ToFixedFloat(num float64, precision int) float64
- 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) )
Functions ¶
func BigIntDivCeil ¶ added in v0.8.0
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 ¶ added in v0.8.0
func CreateDirSafe ¶ added in v0.8.0
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 EncodeUint64ToBytes ¶ added in v0.8.0
EncodeUint64ToBytes encodes provided uint64 to big endian byte slice
func ExtendByteSlice ¶ added in v0.8.0
ExtendByteSlice extends given byte slice by needLength parameter and trims it
func FileExists ¶ added in v0.8.0
Checks if the file at the specified path exists
func GetTerminationSignalCh ¶
GetTerminationSignalCh returns a channel to emit signals by ctrl + c
func PadLeftOrTrim ¶ added in v0.3.3
PadLeftOrTrim left-pads the passed in byte array to the specified size, or trims the array if it exceeds the passed in size
func SaveFileSafe ¶ added in v0.8.0
Creates a file at path and with perms level permissions. If file already exists, owner and permissions are verified, and the file is overwritten.
func SetupDataDir ¶
SetupDataDir sets up the data directory and the corresponding sub-directories
func ToFixedFloat ¶
Types ¶
type JSONNumber ¶ added in v0.3.0
type JSONNumber struct {
Value uint64
}
JSONNumber is the number represented in decimal or hex in json
func (*JSONNumber) MarshalJSON ¶ added in v0.3.0
func (d *JSONNumber) MarshalJSON() ([]byte, error)
func (*JSONNumber) UnmarshalJSON ¶ added in v0.3.0
func (d *JSONNumber) UnmarshalJSON(data []byte) error