utils

package
v0.0.0-...-b00a37c Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2021 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Name = "Dimosthenes"

	// Version is the current version of the blockchain.
	Version = "0.1.1"

	// DimosDir is the directory that the blockchain will live in.
	DimosDir = ".dimos"

	// ChainDir is the directory where the blockchain database will live in.
	ChainDir = "chain"

	// Genesis is the name of the file that will contain the genesis hash.
	Genesis = "genesis"

	// CurrentHash is the file that contains the current hash.
	CurrentHash = "current_hash"

	// MaxUnitSupply defines the maximum unit supply, which is 1 qadrillion.
	MaxUnitSupply = 1e15

	// UnitsInCoin The amount of units in a coin are 100 million. As a result, we can have 10 million coins.
	UnitsInCoin = 1e8
)

Name is the name of the blockchain.

Variables

This section is empty.

Functions

func Abs

func Abs(x int64) int64

Abs returns the absolute value of x.

func BytesToFloat64

func BytesToFloat64(bytes []byte) float64

BytesToFloat64 converts bytes to a float64.

func BytesToUInt64

func BytesToUInt64(bytes []byte) uint64

BytesToUInt64 converts a byte array to an int64.

func CheckEndian

func CheckEndian()

CheckEndian checks the byte order and determines the endiannes.

func CheckIfFileExists

func CheckIfFileExists(path string) bool

CheckIfFileExists checks if the given path exists.

func Float64ToByte

func Float64ToByte(f float64) ([]byte, error)

Float64ToByte converts a float64 type number to a byte array.

func GetChainDir

func GetChainDir(createIfNotExists bool) (string, error)

GetChainDir returns the directory the blockchain should live in.

func GetCurrentHash

func GetCurrentHash() ([]byte, error)

GetCurrentHash gets the current block's hash in the blockchain.

func GetGenesisHash

func GetGenesisHash() ([]byte, error)

GetGenesisHash gets the genesis block hash from inside

func IsIPAddressValid

func IsIPAddressValid(ip string) bool

IsIPAddressValid checks whether a provided IP address is valid.

func ReadFile

func ReadFile(path string) ([]byte, error)

ReadFile reads the contents of the file at the given path.

func ReadFileInChainDir

func ReadFileInChainDir(fileName string) ([]byte, error)

ReadFileInChainDir Read a file in the blockchain directory.

func UInt32ToBytes

func UInt32ToBytes(num uint32) []byte

UInt32ToBytes converts an uint32 to []bytes.

func UInt32ToBytesCustomSize

func UInt32ToBytesCustomSize(num uint32, size int) []byte

UInt32ToBytesCustomSize converts an uint32 to []bytes with a custom output size.

func UInt64ToBytes

func UInt64ToBytes(num uint64) []byte

UInt64ToBytes converts an uint64 to []bytes.

func WriteCurrentHash

func WriteCurrentHash(hash []byte) error

WriteCurrentHash writes the current hash to the disk.

func WriteGenesisHash

func WriteGenesisHash(hash []byte) error

WriteGenesisHash writes the genesis hash to the disk.

func WriteReadOnlyFile

func WriteReadOnlyFile(path string, contents []byte) error

WriteReadOnlyFile writes the contents to the read only file at the given path.

func WriteToFile

func WriteToFile(path string, contents []byte) error

WriteToFile writes the contents to the file at the given path.

Types

This section is empty.

Jump to

Keyboard shortcuts

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