Documentation
¶
Index ¶
- Constants
- Variables
- func AddPaddingBigInt(numInt *big.Int, fixedSize int) []byte
- func AppDataDir(appName string, roaming bool) string
- func AppendSliceString(arrayStrings ...[][]string) [][]string
- func AssertAndConvertStrToNumber(numStr interface{}) (uint64, error)
- func BoolToByte(value bool) byte
- func BytesToInt(bytesArr []byte) int
- func BytesToInt32(b []byte) (int32, error)
- func BytesToUint32(b []byte) (uint32, error)
- func BytesToUint64(b []byte) (uint64, error)
- func CalculateTimeSlot(time int64) int64
- func CheckError(errs ...error) error
- func CleanAndExpandPath(path string, defaultHomeDir string) string
- func CompareStringArray(src []string, dst []string) bool
- func CompressDatabase(src string, dst string) error
- func CopyBytes(b []byte) (copiedBytes []byte)
- func DecompressDatabaseBackup(src string, dst string) error
- func FromHex(s string) []byte
- func GZipFromBytes(src []byte) ([]byte, error)
- func GZipToBytes(src []byte) ([]byte, error)
- func GetENV(key, fallback string) string
- func GetShardChainKey(shardID byte) string
- func GetShardIDFromLastByte(b byte) byte
- func GetValidStaker(committees []string, stakers []string) []string
- func HashB(b []byte) []byte
- func Hex2Bytes(str string) []byte
- func IndexOfByte(item byte, array []byte) int
- func IndexOfHash(item Hash, list []Hash) int
- func IndexOfStr(item string, list []string) int
- func IndexOfStrInHashMap(v string, m map[Hash]string) int
- func IndexOfUint64(target uint64, arr []uint64) int
- func Int32ToBytes(value int32) []byte
- func Int64ToBytes(value int64) []byte
- func IntToBytes(n int) []byte
- func InterfaceSlice(slice interface{}) []interface{}
- func IsPortalExchangeRateToken(tokenIDStr string) bool
- func IsPortalToken(tokenIDStr string) bool
- func RandBigIntMaxRange(max *big.Int) (*big.Int, error)
- func RandInt() int
- func RandInt64() int64
- func Render(data []byte) string
- func SliceExists(slice interface{}, item interface{}) (bool, error)
- func Uint32ToBytes(value uint32) []byte
- func Uint64ToBytes(value uint64) []byte
- type AES
- type BlockInterface
- type BlockPoolInterface
- type ChainInterface
- type ErrorSaver
- type Hash
- func (h Hash) Bytes() []byte
- func (hashObj *Hash) Cmp(target *Hash) (int, error)
- func (hashObj *Hash) Decode(dst *Hash, src string) error
- func (hashObj *Hash) Format(f fmt.State, c rune)
- func (hashObj *Hash) GetBytes() []byte
- func (hashObj *Hash) IsEqual(target *Hash) bool
- func (hashObj Hash) MarshalText() ([]byte, error)
- func (hashObj Hash) NewHash(newHash []byte) (*Hash, error)
- func (hashObj Hash) NewHashFromStr(hash string) (*Hash, error)
- func (hashObj *Hash) SetBytes(newHash []byte) error
- func (hashObj Hash) String() string
- func (hashObj *Hash) UnmarshalJSON(data []byte) error
- func (hashObj Hash) UnmarshalText(text []byte) error
- type SimpleAddr
- type StorageSize
Constants ¶
const ( EmptyString = "" ZeroByte = byte(0x00) DateOutputFormat = "2006-01-02T15:04:05.999999" BigIntSize = 32 // bytes CheckSumLen = 4 // bytes AESKeySize = 32 // bytes Int32Size = 4 // bytes Uint32Size = 4 // bytes Uint64Size = 8 // bytes HashSize = 32 // bytes MaxHashStringSize = HashSize * 2 Base58Version = 0 )
for common
const ( // for key size PrivateKeySize = 32 // bytes PublicKeySize = 32 // bytes BLSPublicKeySize = 128 // bytes BriPublicKeySize = 33 // bytes TransmissionKeySize = 32 //bytes ReceivingKeySize = 32 // bytes PaymentAddressSize = 64 // bytes // for signature size // it is used for both privacy and no privacy SigPubKeySize = 32 SigNoPrivacySize = 64 SigPrivacySize = 96 IncPubKeyB58Size = 51 )
size data for incognito key and signature
const ( ExitCodeUnknow = iota ExitByOs ExitByLogging ExitCodeForceUpdate )
for exit code
const ( TxNormalType = "n" // normal tx(send and receive coin) TxRewardType = "s" // reward tx TxReturnStakingType = "rs" // //TxCustomTokenType = "t" // token tx with no supporting privacy TxCustomTokenPrivacyType = "tp" // token tx with supporting privacy )
For all Transaction information
const ( NodeModeRelay = "relay" NodeModeShard = "shard" NodeModeAuto = "auto" NodeModeBeacon = "beacon" BeaconRole = "beacon" ShardRole = "shard" CommitteeRole = "committee" ProposerRole = "proposer" ValidatorRole = "validator" PendingRole = "pending" SyncingRole = "syncing" //this is for shard case - when beacon tell it is committee, but its state not WaitingRole = "waiting" MaxShardNumber = 8 BlsConsensus = "bls" BridgeConsensus = "dsa" IncKeyType = "inc" )
CONSENSUS
const ( BeaconChainKey = "beacon" ShardChainKey = "shard" )
const ( BeaconChainDataBaseID = -1 BeaconChainDatabaseDirectory = "beacon" ShardChainDatabaseDirectory = "shard" )
const ( REPLACE_IN = 0 REPLACE_OUT = 1 )
const ( //AbiJson = `[{"inputs":[{"internalType":"address","name":"admin","type":"address"},{"internalType":"address","name":"incognitoProxyAddress","type":"address"},{"internalType":"address","name":"_prevVault","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"claimer","type":"address"}],"name":"Claim","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"string","name":"incognitoAddress","type":"string"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"ndays","type":"uint256"}],"name":"Extend","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newVault","type":"address"}],"name":"Migrate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"assets","type":"address[]"}],"name":"MoveAssets","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"pauser","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"pauser","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newIncognitoProxy","type":"address"}],"name":"UpdateIncognitoProxy","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdraw","type":"event"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"constant":true,"inputs":[],"name":"ETH_TOKEN","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"admin","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"claim","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"string","name":"incognitoAddress","type":"string"}],"name":"deposit","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"string","name":"incognitoAddress","type":"string"}],"name":"depositERC20","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"expire","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"n","type":"uint256"}],"name":"extend","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getDecimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"incognito","outputs":[{"internalType":"contractIncognito","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"hash","type":"bytes32"}],"name":"isWithdrawed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"addresspayable","name":"_newVault","type":"address"}],"name":"migrate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address[]","name":"assets","type":"address[]"}],"name":"moveAssets","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"newVault","outputs":[{"internalType":"addresspayable","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes","name":"inst","type":"bytes"}],"name":"parseBurnInst","outputs":[{"internalType":"uint8","name":"","type":"uint8"},{"internalType":"uint8","name":"","type":"uint8"},{"internalType":"address","name":"","type":"address"},{"internalType":"addresspayable","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":false,"inputs":[],"name":"pause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"prevVault","outputs":[{"internalType":"contractWithdrawable","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_successor","type":"address"}],"name":"retire","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"successor","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"unpause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newIncognitoProxy","type":"address"}],"name":"updateIncognitoProxy","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes","name":"inst","type":"bytes"},{"internalType":"uint256[2]","name":"heights","type":"uint256[2]"},{"internalType":"bytes32[][2]","name":"instPaths","type":"bytes32[][2]"},{"internalType":"bool[][2]","name":"instPathIsLefts","type":"bool[][2]"},{"internalType":"bytes32[2]","name":"instRoots","type":"bytes32[2]"},{"internalType":"bytes32[2]","name":"blkData","type":"bytes32[2]"},{"internalType":"uint256[][2]","name":"sigIdxs","type":"uint256[][2]"},{"internalType":"uint8[][2]","name":"sigVs","type":"uint8[][2]"},{"internalType":"bytes32[][2]","name":"sigRs","type":"bytes32[][2]"},{"internalType":"bytes32[][2]","name":"sigSs","type":"bytes32[][2]"}],"name":"withdraw","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"withdrawed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"}]` AbiJson = `` /* 10799-byte string literal not displayed */ BridgeShardID = 1 EthAddrStr = "0x0000000000000000000000000000000000000000" )
Ethereum Decentralized bridge
const ( BridgeRequestNotFoundStatus = 0 BridgeRequestProcessingStatus = 1 BridgeRequestAcceptedStatus = 2 BridgeRequestRejectedStatus = 3 PDENotFoundStatus = 0 PDEContributionWaitingStatus = 1 PDEContributionAcceptedStatus = 2 PDEContributionRefundStatus = 3 PDEContributionMatchedNReturnedStatus = 4 PDETradeAcceptedStatus = 1 PDETradeRefundStatus = 2 PDECrossPoolTradeAcceptedStatus = 1 PDECrossPoolTradeRefundStatus = 2 PDEWithdrawalAcceptedStatus = 1 PDEWithdrawalRejectedStatus = 2 PDEFeeWithdrawalAcceptedStatus = 1 PDEFeeWithdrawalRejectedStatus = 2 MinTxFeesOnTokenRequirement = 10000000000000 // 10000 prv, this requirement is applied from beacon height 87301 mainnet BeaconBlockHeighMilestoneForMinTxFeesOnTokenRequirement = 87301 // milestone of beacon height, when apply min fee on token requirement //portal PortalCustodianDepositAcceptedStatus = 1 PortalCustodianDepositRefundStatus = 2 PortalReqPTokenAcceptedStatus = 1 PortalReqPTokenRejectedStatus = 2 PortalPortingTxRequestAcceptedStatus = 1 PortalPortingTxRequestRejectedStatus = 3 PortalPortingReqSuccessStatus = 1 PortalPortingReqWaitingStatus = 2 PortalPortingReqExpiredStatus = 3 PortalPortingReqLiquidatedStatus = 4 PortalRedeemReqSuccessStatus = 1 PortalRedeemReqWaitingStatus = 2 PortalRedeemReqMatchedStatus = 3 PortalRedeemReqLiquidatedStatus = 4 PortalRedeemReqCancelledByLiquidationStatus = 5 PortalRedeemRequestTxAcceptedStatus = 1 PortalRedeemRequestTxRejectedStatus = 2 PortalCustodianWithdrawReqAcceptedStatus = 1 PortalCustodianWithdrawReqRejectStatus = 2 PortalReqUnlockCollateralAcceptedStatus = 1 PortalReqUnlockCollateralRejectedStatus = 2 PortalLiquidateCustodianSuccessStatus = 1 PortalLiquidateCustodianFailedStatus = 2 PortalLiquidationTPExchangeRatesSuccessStatus = 1 PortalLiquidationTPExchangeRatesFailedStatus = 2 PortalReqWithdrawRewardAcceptedStatus = 1 PortalReqWithdrawRewardRejectedStatus = 2 PortalRedeemLiquidateExchangeRatesSuccessStatus = 1 PortalRedeemLiquidateExchangeRatesRejectedStatus = 2 PortalLiquidationCustodianDepositSuccessStatus = 1 PortalLiquidationCustodianDepositRejectedStatus = 2 PortalExpiredPortingReqSuccessStatus = 1 PortalExpiredPortingReqFailedStatus = 2 PortalExchangeRatesAcceptedStatus = 1 PortalExchangeRatesRejectedStatus = 2 PortalReqMatchingRedeemAcceptedStatus = 1 PortalReqMatchingRedeemRejectedStatus = 2 PortalTopUpWaitingPortingSuccessStatus = 1 PortalTopUpWaitingPortingRejectedStatus = 2 )
Bridge, PDE & Portal statuses for RPCs
const ( PDEContributionWaitingChainStatus = "waiting" PDEContributionMatchedChainStatus = "matched" PDEContributionRefundChainStatus = "refund" PDEContributionMatchedNReturnedChainStatus = "matchedNReturned" PDETradeAcceptedChainStatus = "accepted" PDETradeRefundChainStatus = "refund" PDEWithdrawalAcceptedChainStatus = "accepted" PDEWithdrawalRejectedChainStatus = "rejected" PDEFeeWithdrawalAcceptedChainStatus = "accepted" PDEFeeWithdrawalRejectedChainStatus = "rejected" PDEWithdrawalOnFeeAcceptedChainStatus = "onFeeAccepted" PDEWithdrawalOnPoolPairAcceptedChainStatus = "onPoolPairAccepted" PDEWithdrawalWithPRVFeeRejectedChainStatus = "withPRVFeeRejected" PDECrossPoolTradeFeeRefundChainStatus = "xPoolTradeRefundFee" PDECrossPoolTradeSellingTokenRefundChainStatus = "xPoolTradeRefundSellingToken" PDECrossPoolTradeAcceptedChainStatus = "xPoolTradeAccepted" )
PDE statuses for chain
const ( PortalCustodianDepositAcceptedChainStatus = "accepted" PortalCustodianDepositRefundChainStatus = "refund" PortalReqPTokensAcceptedChainStatus = "accepted" PortalReqPTokensRejectedChainStatus = "rejected" PortalPortingRequestAcceptedChainStatus = "accepted" PortalPortingRequestRejectedChainStatus = "rejected" PortalExchangeRatesAcceptedChainStatus = "accepted" PortalExchangeRatesRejectedChainStatus = "rejected" PortalRedeemRequestAcceptedChainStatus = "accepted" PortalRedeemRequestRejectedChainStatus = "rejected" PortalRedeemReqCancelledByLiquidationChainStatus = "cancelled" PortalCustodianWithdrawRequestAcceptedStatus = "accepted" PortalCustodianWithdrawRequestRejectedStatus = "rejected" PortalReqUnlockCollateralAcceptedChainStatus = "accepted" PortalReqUnlockCollateralRejectedChainStatus = "rejected" PortalLiquidateCustodianSuccessChainStatus = "success" PortalLiquidateCustodianFailedChainStatus = "failed" PortalLiquidateTPExchangeRatesSuccessChainStatus = "success" PortalLiquidateTPExchangeRatesFailedChainStatus = "rejected" PortalReqWithdrawRewardAcceptedChainStatus = "accepted" PortalReqWithdrawRewardRejectedChainStatus = "rejected" PortalRedeemLiquidateExchangeRatesSuccessChainStatus = "success" PortalRedeemLiquidateExchangeRatesRejectedChainStatus = "rejected" PortalLiquidationCustodianDepositSuccessChainStatus = "success" PortalLiquidationCustodianDepositRejectedChainStatus = "rejected" PortalExpiredWaitingPortingReqSuccessChainStatus = "success" PortalExpiredWaitingPortingReqFailedChainStatus = "failed" PortalReqMatchingRedeemAcceptedChainStatus = "accepted" PortalReqMatchingRedeemRejectedChainStatus = "rejected" PortalPickMoreCustodianRedeemSuccessChainStatus = "success" PortalPickMoreCustodianRedeemFailedChainStatus = "failed" PortalTopUpWaitingPortingSuccessChainStatus = "success" PortalTopUpWaitingPortingRejectedChainStatus = "rejected" )
Portal status for chain
const ( RelayingHeaderRejectedChainStatus = "rejected" RelayingHeaderConsideringChainStatus = "considering" )
Relaying header
const (
HexEmptyRoot = "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
)
const PRVIDStr = "0000000000000000000000000000000000000000000000000000000000000004"
const PortalBNBIDStr = "6abd698ea7ddd1f98b1ecaaddab5db0453b8363ff092f0d8d7d4c6b1155fb693"
const PortalBTCIDStr = "ef5947f70ead81a76a53c7c8b7317dd5245510c665d3a13921dc9a581188728b"
const TIMESLOT = 10
Variables ¶
var ( MaxTxSize = uint64(100) // unit KB = 100KB MaxBlockSize = uint64(2000) //unit kilobytes = 2 Megabyte )
var ( PRVCoinID = Hash{4} // To send PRV in custom token PRVCoinName = "PRV" // To send PRV in custom token )
special token ids (aka. PropertyID in custom token)
var CipherTextIsEmptyErr = errors.New("ciphertext is empty")
var (
EmptyRoot = HexToHash(HexEmptyRoot)
)
var InvalidAESKeyErr = errors.New("aes key is invalid")
var InvalidHashSizeErr = errors.New("invalid hash size")
var InvalidMaxHashSizeErr = errors.New("invalid max hash size")
var MinAmountPortalPToken = map[string]uint64{ PortalBTCIDStr: 10, PortalBNBIDStr: 10, }
set MinAmountPortalPToken to avoid attacking with amount is less than smallest unit of cryptocurrency such as satoshi in BTC
var NilHashErr = errors.New("input hash is nil")
var PlainTextIsEmptyErr = errors.New("plaintext is empty")
var PortalSupportedIncTokenIDs = []string{ PortalBTCIDStr, PortalBNBIDStr, }
Functions ¶
func AddPaddingBigInt ¶
AddPaddingBigInt adds padding to big int to it is fixed size and returns bytes array
func AppDataDir ¶
AppDataDir returns an operating system specific directory to be used for storing application data for an application.
The appName parameter is the name of the application the data directory is being requested for. This function will prepend a period to the appName for POSIX style operating systems since that is standard practice. An empty appName or one with a single dot is treated as requesting the current directory so only "." will be returned. Further, the first character of appName will be made lowercase for POSIX style operating systems and uppercase for Mac and Windows since that is standard practice.
The roaming parameter only applies to Windows where it specifies the roaming application data profile (%APPDATA%) should be used instead of the local one (%LOCALAPPDATA%) that is used by default.
Example results:
dir := AppDataDir("myapp", false) POSIX (Linux/BSD): ~/.myapp Mac OS: $HOME/Library/Application Support/Myapp Windows: %LOCALAPPDATA%\Myapp Plan 9: $home/myapp
func AppendSliceString ¶
AppendSliceString is a variadic function, receives some lists of array of strings and appends them to one list of array of strings
func AssertAndConvertStrToNumber ¶
AssertAndConvertStrToNumber asserts and convert a passed input to uint64 number
func BoolToByte ¶
BoolToByte receives a value in bool and returns a value in byte
func BytesToInt ¶
BytesToInt reverts an integer number from 2-byte array
func BytesToInt32 ¶
BytesToInt32 converts little endian 4-byte array to int32 number
func BytesToUint32 ¶
BytesToUint32 converts big endian 4-byte array to uint32 number
func BytesToUint64 ¶
BytesToUint64 converts little endian 8-byte array to uint64 number
func CalculateTimeSlot ¶
func CheckError ¶
CheckError receives a list of errors returns the first error which is not nil
func CleanAndExpandPath ¶
cleanAndExpandPath expands environment variables and leading ~ in the passed path, cleans the result, and returns it.
func CompareStringArray ¶
CompareStringArray receives 2 arrays of string and check whether 2 arrays is the same or not
func CompressDatabase ¶
func FromHex ¶
FromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x".
func GZipFromBytes ¶
GZipFromBytes receives bytes array and compresses that bytes array using gzip
func GZipToBytes ¶
GZipToBytes receives bytes array which is compressed data using gzip returns decompressed bytes array
func GetShardChainKey ¶
func GetShardIDFromLastByte ¶
GetShardIDFromLastByte receives a last byte of public key and returns a corresponding shardID
func GetValidStaker ¶
func IndexOfByte ¶
IndexOfByte receives a array of bytes and a item byte It checks whether a item is contained in array or not and returns the first index of the item in the array It returns -1 if the item is not in the array
func IndexOfHash ¶
func IndexOfStr ¶
IndexOfStr receives a list of strings and a item string It checks whether a item is contained in list or not and returns the first index of the item in the list It returns -1 if the item is not in the list
func IndexOfStrInHashMap ¶
IndexOfStrInHashMap receives a map[Hash]string and a value string It checks whether a value is contained in map or not It returns -1 if the item is not in the list and return 1 otherwise
func IndexOfUint64 ¶
func Int32ToBytes ¶
Int32ToBytes converts int32 number to little endian 4-byte array
func Int64ToBytes ¶
Int64ToBytes converts int64 number to little endian 8-byte array
func IntToBytes ¶
IntToBytes converts an integer number to 2-byte array in big endian
func InterfaceSlice ¶
func InterfaceSlice(slice interface{}) []interface{}
InterfaceSlice receives a slice which is a interface and converts it into slice of interface
func IsPortalToken ¶
func RandBigIntMaxRange ¶
RandBigIntMaxRange generates a big int with maximum value
func SliceExists ¶
SliceExists receives a slice and a item in interface type checks whether the slice contain the item or not
func Uint32ToBytes ¶
Uint32ToBytes converts uint32 number to big endian 4-byte array
func Uint64ToBytes ¶
Uint64ToBytes converts uint64 number to little endian 8-byte array
Types ¶
type BlockInterface ¶
type BlockInterface interface { GetVersion() int GetHeight() uint64 Hash() *Hash // AddValidationField(validateData string) error GetProducer() string GetValidationField() string GetRound() int GetRoundKey() string GetInstructions() [][]string GetConsensusType() string GetCurrentEpoch() uint64 GetProduceTime() int64 GetProposeTime() int64 GetPrevHash() Hash GetProposer() string }
type BlockPoolInterface ¶
type ChainInterface ¶
type ChainInterface interface {
GetShardID() int
}
type ErrorSaver ¶
type ErrorSaver struct {
// contains filtered or unexported fields
}
func (*ErrorSaver) Get ¶
func (s *ErrorSaver) Get() error
func (*ErrorSaver) Save ¶
func (s *ErrorSaver) Save(errs ...error) error
type Hash ¶
func BytesToHash ¶
func HashArrayInterface ¶
func HashArrayOfHashArray ¶
func HexToHash ¶
HexToHash sets byte representation of s to hash. If b is larger than len(h), b will be cropped from the left.
func Keccak256Hash ¶
Keccak256Hash calculates and returns the Keccak256 hash of the input data, converting it to an internal Hash data structure.
func (*Hash) Cmp ¶
Cmp compare two hashes hash = target : return 0 hash > target : return 1 hash < target : return -1
func (*Hash) Decode ¶
Decode decodes the byte-reversed hexadecimal string encoding of a Hash to a destination.
func (Hash) MarshalText ¶
MarshalText converts hashObj string to bytes array
func (Hash) NewHashFromStr ¶
NewHashFromStr creates a Hash from a hash string. The string should be the hexadecimal string of a byte-reversed hash, but any missing characters result in zero padding at the end of the Hash.
func (*Hash) UnmarshalJSON ¶
UnmarshalJSON unmarshal json data to hashObj
func (Hash) UnmarshalText ¶
UnmarshalText reverts bytes array to hashObj
type SimpleAddr ¶
type SimpleAddr struct {
Net, Addr string
}
SimpleAddr implements the net.Addr interface with two fields struct
func ParseListener ¶
func ParseListener(addr string, netType string) (*SimpleAddr, error)
ParseListener determines whether the listen address is IPv4 and IPv6 and returns a slice of appropriate net.Addrs to listen on with TCP. It also properly detects address which apply to "all interfaces" and adds the address as both IPv4 and IPv6.
func ParseListeners ¶
func ParseListeners(addrs []string, netType string) ([]SimpleAddr, error)
ParseListeners determines whether each listen address is IPv4 and IPv6 and returns a slice of appropriate net.Addrs to listen on with TCP. It also properly detects addresses which apply to "all interfaces" and adds the address as both IPv4 and IPv6.
func (SimpleAddr) Network ¶
func (a SimpleAddr) Network() string
Network returns the network. This is part of the net.Addr interface.
func (SimpleAddr) String ¶
func (a SimpleAddr) String() string
String returns the address. This is part of the net.Addr interface.
type StorageSize ¶
type StorageSize float64
StorageSize is a wrapper around a float value that supports user friendly formatting.
func (StorageSize) String ¶
func (s StorageSize) String() string
String implements the stringer interface.
func (StorageSize) TerminalString ¶
func (s StorageSize) TerminalString() string
TerminalString implements log.TerminalStringer, formatting a string for console output during logging.