core

package
v0.0.0-...-33aa4ec Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: GPL-3.0 Imports: 25 Imported by: 29

Documentation

Index

Constants

View Source
const (
	// NotSpecifiedString is the string representation of NotSpecified trie node version
	NotSpecifiedString = "not specified"

	// AutoBalanceEnabledString is the string representation of AutoBalanceEnabled trie node version
	AutoBalanceEnabledString = "auto balanced"
)
View Source
const AllShardId = uint32(0xFFFFFFF0)

AllShardId will be used to identify that a message is for all shards

View Source
const BaseOperationCostString = "BaseOperationCost"

BaseOperationCostString represents the field name for base operation costs

View Source
const BuiltInCostString = "BuiltInCost"

BuiltInCostString represents the field name for built in operation costs

View Source
const BuiltInFunctionChangeOwnerAddress = "ChangeOwnerAddress"

BuiltInFunctionChangeOwnerAddress is the key for the change owner built in function built-in function

View Source
const BuiltInFunctionClaimDeveloperRewards = "ClaimDeveloperRewards"

BuiltInFunctionClaimDeveloperRewards is the key for the claim developer rewards built-in function

View Source
const BuiltInFunctionDCTBurn = "DCTBurn"

BuiltInFunctionDCTBurn is the key for the electronic standard digital token burn built-in function

View Source
const BuiltInFunctionDCTFreeze = "DCTFreeze"

BuiltInFunctionDCTFreeze is the key for the electronic standard digital token freeze built-in function

View Source
const BuiltInFunctionDCTLocalBurn = "DCTLocalBurn"

BuiltInFunctionDCTLocalBurn is the key for the electronic standard digital token local burn built-in function

View Source
const BuiltInFunctionDCTLocalMint = "DCTLocalMint"

BuiltInFunctionDCTLocalMint is the key for the electronic standard digital token local mint built-in function

View Source
const BuiltInFunctionDCTNFTAddQuantity = "DCTNFTAddQuantity"

BuiltInFunctionDCTNFTAddQuantity is the key for the electronic standard digital token NFT add quantity built-in function

View Source
const BuiltInFunctionDCTNFTAddURI = "DCTNFTAddURI"

BuiltInFunctionDCTNFTAddURI is the key for the electronic standard digital token NFT add URI built-in function

View Source
const BuiltInFunctionDCTNFTBurn = "DCTNFTBurn"

BuiltInFunctionDCTNFTBurn is the key for the electronic standard digital token NFT burn built-in function

View Source
const BuiltInFunctionDCTNFTCreate = "DCTNFTCreate"

BuiltInFunctionDCTNFTCreate is the key for the electronic standard digital token NFT create built-in function

View Source
const BuiltInFunctionDCTNFTCreateRoleTransfer = "DCTNFTCreateRoleTransfer"

BuiltInFunctionDCTNFTCreateRoleTransfer is the key for the electronic standard digital token create role transfer function

View Source
const BuiltInFunctionDCTNFTTransfer = "DCTNFTTransfer"

BuiltInFunctionDCTNFTTransfer is the key for the electronic standard digital token NFT transfer built-in function

View Source
const BuiltInFunctionDCTNFTUpdateAttributes = "DCTNFTUpdateAttributes"

BuiltInFunctionDCTNFTUpdateAttributes is the key for the electronic standard digital token NFT update attributes built-in function

View Source
const BuiltInFunctionDCTPause = "DCTPause"

BuiltInFunctionDCTPause is the key for the electronic standard digital token pause built-in function

View Source
const BuiltInFunctionDCTSetLimitedTransfer = "DCTSetLimitedTransfer"

BuiltInFunctionDCTSetLimitedTransfer is the key for the electronic standard digital token built-in function which sets the property for the token to be transferable only through accounts with transfer roles

View Source
const BuiltInFunctionDCTTransfer = "DCTTransfer"

BuiltInFunctionDCTTransfer is the key for the electronic standard digital token transfer built-in function

View Source
const BuiltInFunctionDCTUnFreeze = "DCTUnFreeze"

BuiltInFunctionDCTUnFreeze is the key for the electronic standard digital token unfreeze built-in function

View Source
const BuiltInFunctionDCTUnPause = "DCTUnPause"

BuiltInFunctionDCTUnPause is the key for the electronic standard digital token unpause built-in function

View Source
const BuiltInFunctionDCTUnSetLimitedTransfer = "DCTUnSetLimitedTransfer"

BuiltInFunctionDCTUnSetLimitedTransfer is the key for the electronic standard digital token built-in function which unsets the property for the token to be transferable only through accounts with transfer roles

View Source
const BuiltInFunctionDCTWipe = "DCTWipe"

BuiltInFunctionDCTWipe is the key for the electronic standard digital token wipe built-in function

View Source
const BuiltInFunctionGuardAccount = "GuardAccount"

BuiltInFunctionGuardAccount is the built-in function key for guarding an account

View Source
const BuiltInFunctionMigrateDataTrie = "MigrateDataTrie"

BuiltInFunctionMigrateDataTrie is the built-in function key for migrating the data trie

View Source
const BuiltInFunctionMultiDCTNFTTransfer = "MultiDCTNFTTransfer"

BuiltInFunctionMultiDCTNFTTransfer is the key for the electronic standard digital token multi transfer built-in function

View Source
const BuiltInFunctionSaveKeyValue = "SaveKeyValue"

BuiltInFunctionSaveKeyValue is the key for the save key value built-in function

View Source
const BuiltInFunctionSetDCTRole = "DCTSetRole"

BuiltInFunctionSetDCTRole is the key for the electronic standard digital token set built-in function

View Source
const BuiltInFunctionSetGuardian = "SetGuardian"

BuiltInFunctionSetGuardian is the key for setting a guardian built-in function

View Source
const BuiltInFunctionSetUserName = "SetUserName"

BuiltInFunctionSetUserName is the key for the set user name built-in function

View Source
const BuiltInFunctionUnGuardAccount = "UnGuardAccount"

BuiltInFunctionUnGuardAccount is the built-in function key for un-guarding an account

View Source
const BuiltInFunctionUnSetDCTRole = "DCTUnSetRole"

BuiltInFunctionUnSetDCTRole is the key for the electronic standard digital token unset built-in function

View Source
const CompletedTxEventIdentifier = "completedTxEvent"

CompletedTxEventIdentifier is the identifier for the log that is generated when the execution of a smart contract call is done

View Source
const DCTKeyIdentifier = "dct"

DCTKeyIdentifier is the key prefix for dct tokens

View Source
const DCTNFTLatestNonceIdentifier = "nonce"

DCTNFTLatestNonceIdentifier is the key prefix for dct latest nonce identifier

View Source
const DCTRoleIdentifier = "role"

DCTRoleIdentifier is the key prefix for dct role identifier

View Source
const DCTRoleLocalBurn = "DCTRoleLocalBurn"

DCTRoleLocalBurn is the constant string for the local role of burn for DCT tokens

View Source
const DCTRoleLocalMint = "DCTRoleLocalMint"

DCTRoleLocalMint is the constant string for the local role of mint for DCT tokens

View Source
const DCTRoleNFTAddQuantity = "DCTRoleNFTAddQuantity"

DCTRoleNFTAddQuantity is the constant string for the local role of adding quantity for existing DCT NFT tokens

View Source
const DCTRoleNFTAddURI = "DCTRoleNFTAddURI"

DCTRoleNFTAddURI is the constant string for the local role of adding a URI for DCT NFT tokens

View Source
const DCTRoleNFTBurn = "DCTRoleNFTBurn"

DCTRoleNFTBurn is the constant string for the local role of burn for DCT NFT tokens

View Source
const DCTRoleNFTCreate = "DCTRoleNFTCreate"

DCTRoleNFTCreate is the constant string for the local role of create for DCT NFT tokens

View Source
const DCTRoleNFTCreateMultiShard = "DCTRoleNFTCreateMultiShard"

DCTRoleNFTCreateMultiShard is the constant string for the local role of create for DCT NFT tokens multishard

View Source
const DCTRoleNFTUpdateAttributes = "DCTRoleNFTUpdateAttributes"

DCTRoleNFTUpdateAttributes is the constant string for the local role of updating attributes for DCT NFT tokens

View Source
const DCTRoleTransfer = "DCTTransferRole"

DCTRoleTransfer is the constant string for the local role to transfer DCT, only for special tokens

View Source
const DefaultAddressPrefix = "moa"

DefaultAddressPrefix is the default hrp of Dharitri/Andes

View Source
const DelegationSystemSCKey = "delegation"

DelegationSystemSCKey is the key under which there is data in case of system delegation smart contracts

View Source
const FileModeReadWrite = 0664

FileModeReadWrite represents the permission for a file which allows reading and writing for user and group and read for others

View Source
const FileModeUserReadWrite = 0600

FileModeUserReadWrite represents the permission for a file which allows the user for reading and writing

View Source
const FungibleDCT = "FungibleDCT"

FungibleDCT defines the string for the token type of fungible DCT

View Source
const GasRefundForRelayerMessage = "gas refund for relayer"

GasRefundForRelayerMessage is the return message for to the smart contract result with refund for the relayer

View Source
const GetNodeFromDBErrorString = "getNodeFromDB error"

GetNodeFromDBErrorString represents the string which is returned when a getting node from DB returns an error

View Source
const GuardiansKeyIdentifier = "guardians"

GuardiansKeyIdentifier is the key prefix for guardians

View Source
const InitialVersionOfTransaction = uint32(1)

InitialVersionOfTransaction defines the initial version for a transaction

View Source
const InternalVMErrorsOperation = "internalVMErrors"

InternalVMErrorsOperation is the identifier for the log that is generated when the execution of a smart contract generates an interval vm error

View Source
const MaxBufferSizeToSendTrieNodes = 1 << 18 //256KB

MaxBufferSizeToSendTrieNodes represents max buffer size to send in bytes used when resolving trie nodes Every trie node that has a greater size than this constant is considered a large trie node and should be split in smaller chunks

View Source
const MaxLeafSize = uint64(1 << 26) //64MB

MaxLeafSize represents maximum amount of data which can be saved under one leaf

View Source
const MaxLenForDCTIssueMint = 100

MaxLenForDCTIssueMint defines the maximum length in bytes for the issued/minted balance

View Source
const MaxMachineIDLen = 10

MaxMachineIDLen is the maximum machine ID length

View Source
const MaxNumShards = 256

MaxNumShards represents the maximum number of shards possible in the system

View Source
const MaxRoyalty = uint32(10000)

MaxRoyalty defines 100% as uint32

View Source
const MaxUserNameLength = 32

MaxUserNameLength represents the maximum number of bytes a UserName can have

View Source
const MeasurementsLoggerFormat = "%.4fs"

MeasurementsLoggerFormat contains the formatting string to output elapsed time in seconds in a consistent way

View Source
const MegabyteSize = 1024 * 1024

MegabyteSize represents the size in bytes of a megabyte

View Source
const MetachainShardId = uint32(0xFFFFFFFF)

MetachainShardId will be used to identify a shard ID as metachain

View Source
const MinLenArgumentsDCTNFTTransfer = 4

MinLenArgumentsDCTNFTTransfer defines the minimum length for dct nft transfer

View Source
const MinLenArgumentsDCTTransfer = 2

MinLenArgumentsDCTTransfer defines the min length of arguments for the DCT transfer

View Source
const MinMetaTxExtraGasCost = uint64(1_000_000)

MinMetaTxExtraGasCost is the constant defined for minimum gas value to be sent in meta transaction

View Source
const NonFungibleDCT = "NonFungibleDCT"

NonFungibleDCT defines the string for the token type of non fungible DCT

View Source
const NumInitCharactersForScAddress = 10

NumInitCharactersForScAddress numbers of characters for smart contract address identifier

View Source
const ProtectedKeyPrefix = "E" + "L" + "R" + "O" + "N" + "D"

ProtectedKeyPrefix is the key prefix which is protected from writing in the trie - only for special builtin functions

View Source
const RelayedTransaction = "relayedTx"

RelayedTransaction is the key for the electronic meta/gassless/relayed transaction standard

View Source
const RelayedTransactionV2 = "relayedTxV2"

RelayedTransactionV2 is the key for the optimized electronic meta/gassless/relayed transaction standard

View Source
const SCDeployIdentifier = "SCDeploy"

SCDeployIdentifier is the identifier for a smart contract deploy

View Source
const SCDeployInitFunctionName = "_init"

SCDeployInitFunctionName is the key for the function which is called at smart contract deploy time

View Source
const SCUpgradeIdentifier = "SCUpgrade"

SCUpgradeIdentifier is the identifier for a smart contract upgrade

View Source
const SemiFungibleDCT = "SemiFungibleDCT"

SemiFungibleDCT defines the string for the token type of semi fungible DCT

View Source
const ShardIdentiferLen = 2

ShardIdentiferLen number of characters for shard identifier in an address

View Source
const SignalErrorOperation = "signalError"

SignalErrorOperation is the identifier for the log that is generated when a smart contract is executed but return an error

View Source
const TopicRequestSuffix = "_REQUEST"

TopicRequestSuffix represents the topic name suffix for requests

View Source
const VMTypeLen = 2

VMTypeLen number of characters with VMType identifier in an address, these are the last 2 characters from the initial identifier

View Source
const WriteLogIdentifier = "writeLog"

WriteLogIdentifier is the identifier for the information log that is generated by a smart contract call/dct transfer

Variables

View Source
var DCTSCAddress = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 255, 255}

DCTSCAddress is the hard-coded address for dct issuing smart contract

View Source
var ErrAdditionOverflow = errors.New("uint64 addition overflowed")

ErrAdditionOverflow signals that uint64 addition overflowed

View Source
var ErrContextClosing = errors.New("context closing")

ErrContextClosing signals that the parent context requested the closing of its children

View Source
var ErrDBIsClosed = errors.New("DB is closed")

ErrDBIsClosed is raised when the DB is closed

View Source
var ErrEmptyFile = errors.New("empty file provided")

ErrEmptyFile signals that a empty file has been provided

View Source
var ErrFileLoggingProcessIsClosed = errors.New("file logging process is closed")

ErrFileLoggingProcessIsClosed signals that the file logging process is closed

View Source
var ErrInvalidGasScheduleConfig = errors.New("invalid gas schedule config")

ErrInvalidGasScheduleConfig signals that invalid gas schedule config was provided

View Source
var ErrInvalidIdentifierForEpochStartBlockRequest = errors.New("invalid identifier for epoch start block request")

ErrInvalidIdentifierForEpochStartBlockRequest signals that an invalid identifier for epoch start block request has been provided

View Source
var ErrInvalidIndex = errors.New("invalid private key index")

ErrInvalidIndex signals that an invalid private key index has been provided

View Source
var ErrInvalidLogFileMinLifeSpan = errors.New("minimum log file life span is invalid")

ErrInvalidLogFileMinLifeSpan signals that an invalid log file life span was provided

View Source
var ErrInvalidPollingInterval = errors.New("invalid polling interval ")

ErrInvalidPollingInterval signals that an invalid polling interval has been provided

View Source
var ErrInvalidTransactionVersion = errors.New("invalid transaction version")

ErrInvalidTransactionVersion signals that an invalid transaction version has been provided

View Source
var ErrInvalidValue = errors.New("invalid value provided")

ErrInvalidValue signals that a nil value has been provided

View Source
var ErrMajorVersionMismatch = errors.New("major version mismatch")

ErrMajorVersionMismatch signals that the major version mismatch

View Source
var ErrMinorVersionMismatch = errors.New("minor version mismatch")

ErrMinorVersionMismatch signals that the minor version mismatch

View Source
var ErrNilAppStatusHandler = errors.New("appStatusHandler is nil")

ErrNilAppStatusHandler signals that a nil status handler has been provided

View Source
var ErrNilEnableEpochsHandler = errors.New("nil enable epochs handler")

ErrNilEnableEpochsHandler signals that a nil enable epochs handler has been provided

View Source
var ErrNilEpochStartNotifier = errors.New("nil epoch start notifier")

ErrNilEpochStartNotifier signals that nil epoch start notifier has been provided

View Source
var ErrNilFile = errors.New("nil file provided")

ErrNilFile signals that a nil file has been provided

View Source
var ErrNilGoRoutineProcessor = errors.New("nil go routine processor")

ErrNilGoRoutineProcessor signals that a nil go routine processor has been provided

View Source
var ErrNilHasher = errors.New("nil hasher provided")

ErrNilHasher signals that a nil hasher has been provided

View Source
var ErrNilInputData = errors.New("nil input data")

ErrNilInputData signals that a nil data has been provided

View Source
var ErrNilLogger = errors.New("nil logger")

ErrNilLogger signals that a nil logger instance has been provided

View Source
var ErrNilMarshalizer = errors.New("nil marshalizer provided")

ErrNilMarshalizer signals that a nil marshalizer has been provided

View Source
var ErrNilNodesCoordinator = errors.New("nil nodes coordinator")

ErrNilNodesCoordinator signals a nil nodes coordinator has been provided

View Source
var ErrNilPemBLock = errors.New("nil pem block")

ErrNilPemBLock signals that the pem block is nil

View Source
var ErrNilPubkeyConverter = errors.New("nil pubkey converter")

ErrNilPubkeyConverter signals that a nil public key converter has been provided

View Source
var ErrNilShardCoordinator = errors.New("nil shard coordinator")

ErrNilShardCoordinator signals that a nil shard coordinator was provided

View Source
var ErrNilSignalChan = errors.New("nil signal channel")

ErrNilSignalChan returns whenever a nil signal channel is provided

View Source
var ErrNilStatusTagProvider = errors.New("nil status tag provider")

ErrNilStatusTagProvider signals that a nil status tag provider has been given as parameter

View Source
var ErrNilStore = errors.New("nil data storage service")

ErrNilStore signals that the provided storage service is nil

View Source
var ErrNilTransactionFeeCalculator = errors.New("nil transaction fee calculator")

ErrNilTransactionFeeCalculator signals that a nil transaction fee calculator has been provided

View Source
var ErrNilUrl = errors.New("url is empty")

ErrNilUrl signals that the provided url is empty

View Source
var ErrNotPositiveValue = errors.New("the provided value is not positive")

ErrNotPositiveValue signals that a 0 or negative value has been provided

View Source
var ErrPemFileIsInvalid = errors.New("pem file is invalid")

ErrPemFileIsInvalid signals that a pem file is invalid

View Source
var ErrReleaseVersionMismatch = errors.New("release version mismatch")

ErrReleaseVersionMismatch signals that the release version mismatch

View Source
var ErrSubtractionOverflow = errors.New("uint64 subtraction overflowed")

ErrSubtractionOverflow signals that uint64 subtraction overflowed

View Source
var ErrSuffixNotPresentOrInIncorrectPosition = errors.New("suffix is not present or the position is incorrect")

ErrSuffixNotPresentOrInIncorrectPosition signals that the suffix is not present in the data field or its position is incorrect

View Source
var ErrVersionNumComponents = errors.New("invalid version while checking number of components")

ErrVersionNumComponents signals that a wrong number of components was provided

View Source
var SystemAccountAddress = bytes.Repeat([]byte{255}, 32)

SystemAccountAddress is the hard-coded address in which we save global settings on all shards

Functions

func AbsDuration

func AbsDuration(duration time.Duration) time.Duration

AbsDuration returns the absolute value of the provided time.Duration parameter

func CalculateHash

func CalculateHash(
	marshalizer marshal.Marshalizer,
	hasher hashing.Hasher,
	object interface{},
) ([]byte, error)

CalculateHash marshalizes the interface and calculates its hash

func CommunicationIdentifierBetweenShards

func CommunicationIdentifierBetweenShards(shardId1 uint32, shardId2 uint32) string

CommunicationIdentifierBetweenShards is used to generate the identifier between shardID1 and shardID2 identifier is generated such as the first shard from identifier is always smaller or equal than the last

func ConvertBytes

func ConvertBytes(bytes uint64) string

ConvertBytes converts the input bytes in a readable string using multipliers (k, M, G)

func ConvertShardIDToUint32

func ConvertShardIDToUint32(shardIDStr string) (uint32, error)

ConvertShardIDToUint32 converts shard id from string to uint32

func ConvertToEvenHex

func ConvertToEvenHex(value int) string

ConvertToEvenHex converts the provided value in a hex string, even number of characters

func ConvertToEvenHexBigInt

func ConvertToEvenHexBigInt(value *big.Int) string

ConvertToEvenHexBigInt converts the provided value in a hex string, even number of characters

func CreateFile

func CreateFile(arg ArgCreateFileArgument) (*os.File, error)

CreateFile opens or creates a file relative to the default path

func DumpGoRoutinesToLog

func DumpGoRoutinesToLog(goRoutinesNumberStart int, log Logger)

DumpGoRoutinesToLog will print the currently running go routines in the log

func EmptyChannel

func EmptyChannel(ch chan bool) int

EmptyChannel empties the given channel

func EpochStartIdentifier

func EpochStartIdentifier(epoch uint32) string

EpochStartIdentifier returns the string for the epoch start identifier

func FileExists

func FileExists(path string) bool

FileExists returns true if the file at the given path exists

func GetAnonymizedMachineID

func GetAnonymizedMachineID(appID string) string

GetAnonymizedMachineID returns the machine ID anonymized with the provided app ID string

func GetApproximatePercentageOfValue

func GetApproximatePercentageOfValue(value *big.Int, percentage float64) *big.Int

GetApproximatePercentageOfValue returns the approximate percentage of value the approximation comes from floating point operations, which in case of large numbers has some loss in accuracy and can cause the result to be slightly lower or higher than the actual value

func GetIntTrimmedPercentageOfValue

func GetIntTrimmedPercentageOfValue(value *big.Int, percentage float64) *big.Int

GetIntTrimmedPercentageOfValue returns the exact percentage of value, that fits into the integer (with loss of division remainder)

func GetPBFTFallbackThreshold

func GetPBFTFallbackThreshold(consensusSize int) int

GetPBFTFallbackThreshold returns the pBFT fallback threshold for a given consensus size

func GetPBFTThreshold

func GetPBFTThreshold(consensusSize int) int

GetPBFTThreshold returns the pBFT threshold for a given consensus size

func GetRunningGoRoutines

func GetRunningGoRoutines(log Logger) *bytes.Buffer

GetRunningGoRoutines gets the currently running go routines stack trace as a bytes.Buffer

func GetShardIDString

func GetShardIDString(shardID uint32) string

GetShardIDString will return the string representation of the shard id

func GetTrimmedPk

func GetTrimmedPk(pk string) string

GetTrimmedPk returns a trimmed string to the pkPrefixSize value

func IsClosingError

func IsClosingError(err error) bool

IsClosingError returns true if the provided error is used whenever the node is in the closing process

func IsEmptyAddress

func IsEmptyAddress(address []byte) bool

IsEmptyAddress returns whether an address is empty

func IsGetNodeFromDBError

func IsGetNodeFromDBError(err error) bool

IsGetNodeFromDBError returns true if the provided error is of type getNodeFromDB

func IsInRangeInclusive

func IsInRangeInclusive(value, min, max *big.Int) bool

IsInRangeInclusive returns true if the provided value is in the given range, including the provided min and max values

func IsInRangeInclusiveFloat64

func IsInRangeInclusiveFloat64(value, min, max float64) bool

IsInRangeInclusiveFloat64 returns true if the provided value is in the given range including the provided min and max values

func IsMetachainIdentifier

func IsMetachainIdentifier(identifier []byte) bool

IsMetachainIdentifier verifies if the identifier is of type metachain

func IsSmartContractAddress

func IsSmartContractAddress(rcvAddress []byte) bool

IsSmartContractAddress verifies if a set address is of type smart contract

func IsSmartContractOnMetachain

func IsSmartContractOnMetachain(identifier []byte, rcvAddress []byte) bool

IsSmartContractOnMetachain verifies if an address is smart contract on metachain

func IsSystemAccountAddress

func IsSystemAccountAddress(address []byte) bool

IsSystemAccountAddress returns true if given address is system account address

func IsUnknownEpochIdentifier

func IsUnknownEpochIdentifier(identifier []byte) (bool, error)

IsUnknownEpochIdentifier return if the epoch identifier represents unknown epoch

func IsValidDCTRole

func IsValidDCTRole(role string) bool

IsValidDCTRole returns true if the input string represents a valid DCT role

func LoadAllKeysFromPemFile

func LoadAllKeysFromPemFile(relativePath string) ([][]byte, []string, error)

LoadAllKeysFromPemFile loads all the secret keys and existing public key bytes stored in the file

func LoadJsonFile

func LoadJsonFile(dest interface{}, relativePath string) error

LoadJsonFile method to open and decode json file

func LoadSkPkFromPemFile

func LoadSkPkFromPemFile(relativePath string, skIndex int) ([]byte, string, error)

LoadSkPkFromPemFile loads the secret key and existing public key bytes stored in the file

func LoadTomlFile

func LoadTomlFile(dest interface{}, relativePath string) error

LoadTomlFile method to open and decode toml file

func LoadTomlFileToMap

func LoadTomlFileToMap(relativePath string) (map[string]interface{}, error)

LoadTomlFileToMap opens and decodes a toml file as a map[string]interface{}

func MaxFloat64

func MaxFloat64(a float64, b float64) float64

MaxFloat64 returns the maximum of two given numbers

func MaxInt

func MaxInt(a int, b int) int

MaxInt returns the maximum of two given numbers

func MaxInt32

func MaxInt32(a int32, b int32) int32

MaxInt32 returns the maximum of two given numbers

func MaxInt64

func MaxInt64(a int64, b int64) int64

MaxInt64 returns the maximum of two given numbers

func MaxUint32

func MaxUint32(a uint32, b uint32) uint32

MaxUint32 returns the maximum of two given numbers

func MaxUint64

func MaxUint64(a uint64, b uint64) uint64

MaxUint64 returns the maximum of two given numbers

func MinInt

func MinInt(a int, b int) int

MinInt returns the minimum of two given numbers

func MinInt32

func MinInt32(a int32, b int32) int32

MinInt32 returns the minimum of two given numbers

func MinInt64

func MinInt64(a int64, b int64) int64

MinInt64 returns the minimum of two given numbers

func MinUint32

func MinUint32(a uint32, b uint32) uint32

MinUint32 returns the minimum of two given numbers

func MinUint64

func MinUint64(a uint64, b uint64) uint64

MinUint64 returns the minimum of two given numbers

func NewGetNodeFromDBErrWithKey

func NewGetNodeFromDBErrWithKey(key []byte, err error, id string) *getNodeFromDBErrWithKey

NewGetNodeFromDBErrWithKey will create a new instance of GetNodeFromDBErrWithKey

func NewKeyLoader

func NewKeyLoader() *keyLoader

NewKeyLoader creates a new instance of type key loader

func NewTrieNodeVersionVerifier

func NewTrieNodeVersionVerifier(enableEpochsHandler EnableEpochsHandler) (*trieNodeVersionVerifier, error)

func OpenFile

func OpenFile(relativePath string) (*os.File, error)

OpenFile method opens the file from given path - does not close the file

func SafeAddUint64

func SafeAddUint64(a, b uint64) (uint64, error)

SafeAddUint64 performs addition on uint64 and returns an error if the addition overflows

func SafeMul

func SafeMul(a uint64, b uint64) *big.Int

SafeMul returns multiplication results of two uint64 values into a big int

func SafeSubUint64

func SafeSubUint64(a, b uint64) (uint64, error)

SafeSubUint64 performs subtraction on uint64 and returns an error if it overflows

func SaveSkToPemFile

func SaveSkToPemFile(file *os.File, identifier string, skBytes []byte) error

SaveSkToPemFile saves secret key bytes in the file

func SaveTomlFile

func SaveTomlFile(src interface{}, relativePath string) error

SaveTomlFile will open and save data to toml file

func SecondsToHourMinSec

func SecondsToHourMinSec(input int) string

SecondsToHourMinSec transform seconds input in a human friendly format

func ShardIdToString

func ShardIdToString(shardId uint32) string

ShardIdToString returns the string according to the shard id

func UniqueIdentifier

func UniqueIdentifier() string

UniqueIdentifier returns a unique string identifier of 32 bytes

Types

type Accumulator

type Accumulator interface {
	AddData(data interface{})
	OutputChannel() <-chan []interface{}
	Close() error
	IsInterfaceNil() bool
}

Accumulator defines the interface able to accumulate data and periodically evict them

type AppStatusHandler

type AppStatusHandler interface {
	IsInterfaceNil() bool
	Increment(key string)
	AddUint64(key string, val uint64)
	Decrement(key string)
	SetInt64Value(key string, value int64)
	SetUInt64Value(key string, value uint64)
	SetStringValue(key string, value string)
	Close()
}

AppStatusHandler interface will handle different implementations of monitoring tools, such as term-ui or status metrics

type ArgCreateFileArgument

type ArgCreateFileArgument struct {
	Directory     string
	Prefix        string
	FileExtension string
}

ArgCreateFileArgument will hold the arguments for a new file creation method call

type ConnectedAddressesHandler

type ConnectedAddressesHandler interface {
	ConnectedAddresses() []string
}

ConnectedAddressesHandler interface will be used for passing the network component to AppStatusPolling

type DCTType

type DCTType uint32

DCTType defines the possible types in case of DCT tokens

const (
	// Fungible defines the token type for DCT fungible tokens
	Fungible DCTType = iota
	// NonFungible defines the token type for DCT non fungible tokens
	NonFungible
)

type EnableEpochsHandler

type EnableEpochsHandler interface {
	IsAutoBalanceDataTriesEnabled() bool
	IsInterfaceNil() bool
}

EnableEpochsHandler defines the behavior of a component that can return if a feature is enabled or not

type EpochNotifier

type EpochNotifier interface {
	RegisterNotifyHandler(handler EpochSubscriberHandler)
	IsInterfaceNil() bool
}

EpochNotifier can notify upon an epoch change and provide the current epoch

type EpochSubscriberHandler

type EpochSubscriberHandler interface {
	EpochConfirmed(epoch uint32, timestamp uint64)
	IsInterfaceNil() bool
}

EpochSubscriberHandler defines the behavior of a component that can be notified if a new epoch was confirmed

type GasScheduleNotifier

type GasScheduleNotifier interface {
	RegisterNotifyHandler(handler GasScheduleSubscribeHandler)
	LatestGasSchedule() map[string]map[string]uint64
	UnRegisterAll()
	IsInterfaceNil() bool
}

GasScheduleNotifier can notify upon a gas schedule change

type GasScheduleSubscribeHandler

type GasScheduleSubscribeHandler interface {
	GasScheduleChange(gasSchedule map[string]map[string]uint64)
	IsInterfaceNil() bool
}

GasScheduleSubscribeHandler defines the behavior of a component that can be notified if a the gas schedule was changed

type GetNodeFromDbErrHandler

type GetNodeFromDbErrHandler interface {
	Error() string
	GetKey() []byte
	GetIdentifier() string
	IsInterfaceNil() bool
}

GetNodeFromDbErrHandler defines the behavior of a component that can provide extra info from a missing trie node err

func UnwrapGetNodeFromDBErr

func UnwrapGetNodeFromDBErr(wrappedErr error) GetNodeFromDbErrHandler

UnwrapGetNodeFromDBErr unwraps the provided error until it finds a GetNodeFromDbErrHandler

type HeaderType

type HeaderType string

HeaderType defines the type to be used for the header that is sent

const (
	// MetaHeader defines the type of *block.MetaBlock
	MetaHeader HeaderType = "MetaBlock"
	// ShardHeaderV1 defines the type of *block.Header
	ShardHeaderV1 HeaderType = "Header"
	// ShardHeaderV2 defines the type of *block.HeaderV2
	ShardHeaderV2 HeaderType = "HeaderV2"
)

func GetHeaderType

func GetHeaderType(header data.HeaderHandler) HeaderType

GetHeaderType will return the type of the provided header

type KeyValueHolder

type KeyValueHolder interface {
	Key() []byte
	Value() []byte
}

KeyValueHolder is used to hold a key and an associated value

type Logger

type Logger interface {
	Trace(message string, args ...interface{})
	Debug(message string, args ...interface{})
	Info(message string, args ...interface{})
	Warn(message string, args ...interface{})
	Error(message string, args ...interface{})
	LogIfError(err error, args ...interface{})
	IsInterfaceNil() bool
}

Logger defines the behavior of a data logger component

type NodeType

type NodeType string

NodeType represents the node's role in the network

const NodeTypeObserver NodeType = "observer"

NodeTypeObserver signals that a node is running as observer node

const NodeTypeValidator NodeType = "validator"

NodeTypeValidator signals that a node is running as validator node

type NodeTypeProviderHandler

type NodeTypeProviderHandler interface {
	SetType(nodeType NodeType)
	GetType() NodeType
	IsInterfaceNil() bool
}

NodeTypeProviderHandler defines the actions needed for a component that can handle the node type

type OptionalUint32

type OptionalUint32 struct {
	Value    uint32
	HasValue bool
}

OptionalUint32 holds an optional uint32 value

type OptionalUint64

type OptionalUint64 struct {
	Value    uint64
	HasValue bool
}

OptionalUint64 holds an optional uint64 value

type P2PPeerInfo

type P2PPeerInfo struct {
	PeerType    P2PPeerType
	PeerSubType P2PPeerSubType
	ShardID     uint32
	PkBytes     []byte
}

P2PPeerInfo represents a peer info structure

type P2PPeerSubType

type P2PPeerSubType uint32

P2PPeerSubType defines the subtype of peer (e.g. FullArchive)

const (
	// RegularPeer
	RegularPeer P2PPeerSubType = iota
	// FullHistoryObserver is a node that syncs the entire history of its shard
	FullHistoryObserver
)

func (P2PPeerSubType) String

func (pst P2PPeerSubType) String() string

String returns the string-ified version of P2PPeerSubType

type P2PPeerType

type P2PPeerType int

P2PPeerType defines the type of a p2p peer

const (
	// UnknownPeer defines a peer that is unknown (did not advertise data in any way)
	UnknownPeer P2PPeerType = iota
	// ValidatorPeer means that the peer is a validator
	ValidatorPeer
	// ObserverPeer means that the peer is an observer
	ObserverPeer
)

func (P2PPeerType) String

func (pt P2PPeerType) String() string

String returns the string-ified version of P2PPeerType

type PeerID

type PeerID string

PeerID is a p2p peer identity.

func NewPeerID

func NewPeerID(input string) (PeerID, error)

NewPeerID creates a new peer id or returns an error

func (PeerID) Bytes

func (pid PeerID) Bytes() []byte

Bytes returns the peer ID as byte slice

func (PeerID) Pretty

func (pid PeerID) Pretty() string

Pretty returns a b58-encoded string of the peer id

type PeerTopicType

type PeerTopicType string

PeerTopicType represents the type of a peer in regards to the topic it is used

const (
	// IntraShardPeer represents the identifier for intra shard peers to be used in intra shard topics
	IntraShardPeer PeerTopicType = "intra peer"

	// CrossShardPeer represents the identifier for intra shard peers to be used in cross shard topics
	CrossShardPeer PeerTopicType = "cross peer"

	// FullHistoryPeer represents the identifier for intra shard peers to be used in full history topics
	FullHistoryPeer PeerTopicType = "full history peer"
)

func (PeerTopicType) String

func (pt PeerTopicType) String() string

String returns a string version of the peer topic type

type PubkeyConverter

type PubkeyConverter interface {
	Len() int
	Decode(humanReadable string) ([]byte, error)
	Encode(pkBytes []byte) (string, error)
	SilentEncode(pkBytes []byte, log Logger) string
	EncodeSlice(pkBytesSlice [][]byte) ([]string, error)
	IsInterfaceNil() bool
}

PubkeyConverter can convert public key bytes to/from a human readable form

type QueryP2PPeerInfo

type QueryP2PPeerInfo struct {
	IsBlacklisted bool     `json:"isblacklisted"`
	Pid           string   `json:"pid"`
	Pk            string   `json:"pk"`
	PeerType      string   `json:"peertype"`
	PeerSubType   string   `json:"peersubtype"`
	Addresses     []string `json:"addresses"`
}

QueryP2PPeerInfo represents a DTO used in exporting p2p peer info after a query

type Queue

type Queue interface {
	Add(hash []byte) []byte
}

Queue is an interface for queue implementations that evict the first element when the queue is full

type SafeCloser

type SafeCloser interface {
	Close()
	ChanClose() <-chan struct{}
	IsInterfaceNil() bool
}

SafeCloser represents a subcomponent used for signaling a closing event. Its Close method is considered to be concurrent safe

type StopWatch

type StopWatch struct {
	// contains filtered or unexported fields
}

StopWatch is used to measure duration

func NewStopWatch

func NewStopWatch() *StopWatch

NewStopWatch returns a new stopWatch instance used to measure duration between finished and started events

func (*StopWatch) Add

func (sw *StopWatch) Add(src *StopWatch)

Add adds a time measure containing duration list to self

func (*StopWatch) GetMeasurement

func (sw *StopWatch) GetMeasurement(identifier string) time.Duration

GetMeasurement returns the measurement by identifier

func (*StopWatch) GetMeasurements

func (sw *StopWatch) GetMeasurements() []interface{}

GetMeasurements returns a logger compatible slice of interface{} containing pairs of (identifier, duration)

func (*StopWatch) GetMeasurementsMap

func (sw *StopWatch) GetMeasurementsMap() map[string]float64

GetMeasurementsMap returns the measurements as a map of (identifier, duration in seconds)

func (*StopWatch) Start

func (sw *StopWatch) Start(identifier string)

Start marks a start event for a provided identifier

func (*StopWatch) Stop

func (sw *StopWatch) Stop(identifier string)

Stop marks a finish event for a provided identifier

type Throttler

type Throttler interface {
	CanProcess() bool
	StartProcessing()
	EndProcessing()
	IsInterfaceNil() bool
}

Throttler can monitor the number of the currently running go routines

type TimersScheduler

type TimersScheduler interface {
	Add(callback func(alarmID string), duration time.Duration, alarmID string)
	Cancel(alarmID string)
	Close()
	Reset(alarmID string)
	IsInterfaceNil() bool
}

TimersScheduler exposes functionality for scheduling multiple timers

type TrieData

type TrieData struct {
	Key     []byte
	Value   []byte
	Version TrieNodeVersion
}

TrieData holds the data that will be inserted into the trie

type TrieNodeVersion

type TrieNodeVersion uint8

TrieNodeVersion defines the version of the trie node

const (
	// NotSpecified means that the value is not populated or is not important
	NotSpecified TrieNodeVersion = iota

	// AutoBalanceEnabled is used for data tries, and only after the activation of AutoBalanceDataTriesEnableEpoch flag
	AutoBalanceEnabled
)

func GetVersionForNewData

func GetVersionForNewData(handler EnableEpochsHandler) TrieNodeVersion

GetVersionForNewData returns the trie node version that should be used for new data

func (TrieNodeVersion) String

func (version TrieNodeVersion) String() string

type TrieNodeVersionVerifier

type TrieNodeVersionVerifier interface {
	IsValidVersion(version TrieNodeVersion) bool
	IsInterfaceNil() bool
}

TrieNodeVersionVerifier defines the behavior of a component that can verify if a trie node version is valid

type WatchdogTimer

type WatchdogTimer interface {
	Set(callback func(alarmID string), duration time.Duration, alarmID string)
	SetDefault(duration time.Duration, alarmID string)
	Stop(alarmID string)
	Reset(alarmID string)
	IsInterfaceNil() bool
}

WatchdogTimer is used to set alarms for different components

Jump to

Keyboard shortcuts

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