Documentation ¶
Index ¶
- Constants
- Variables
- func AddOneDay(day string) (string, error)
- func AddPrefix(value string) string
- func AppendToFile(filePath, content string) error
- func Bytes1(val uint64) []byte
- func Bytes16(x uint64) []byte
- func Bytes2(val uint64) []byte
- func Bytes32(x uint64) []byte
- func Bytes4(x uint64) []byte
- func Bytes64(x uint64) []byte
- func Bytes8(x uint64) []byte
- func EndSlotOfEpoch(config beacon.Eth2Config, epoch uint64) uint64
- func EpochAtTimestamp(config beacon.Eth2Config, time uint64) uint64
- func ErrToLogStr(err error) string
- func EventTopics(a abi.ABI, names ...string) ([]common.Hash, error)
- func ExecuteFns(fns ...func() error) (err error)
- func FloatToStr(f float64) string
- func FromHexString(data string) ([]byte, error)
- func GetDropRate(startDayStr, nowDayStr string) (string, error)
- func GetDropRateFromTimestamp(startDay, stamp string) (string, error)
- func GetGaspriceFromBeacon() (base uint64, err error)
- func GetGaspriceFromEthgasstation() (base, priority uint64, err error)
- func GetNewDayUtc8Seconds() int64
- func GetNowUTC8Date() string
- func GetSwapHash(swapType, sender string, created int64) string
- func GetUserNodePlatformReward(...) (decimal.Decimal, decimal.Decimal, decimal.Decimal)
- func GetYesterdayUTC8Date() string
- func IsDir(path string) (bool, error)
- func IsImageExt(extName string) bool
- func Max[T constraints.Ordered](a, b T) T
- func Min[T constraints.Ordered](n1 T, nums ...T) T
- func NodeRewardsFileNameAtEpoch(lsdToken string, chainID uint64, epoch uint64) string
- func NodeRewardsFileNameAtEpochOld(lsdToken string, epoch uint64) string
- func PriceSymbolValid(symbol string) bool
- func ProposalId(to common.Address, callData []byte, proposalFactor *big.Int) [32]byte
- func PulseChainConfig() *params.BeaconChainConfig
- func PulseChainTestnetV4Config() *params.BeaconChainConfig
- func ReadLastLine(filePath string) (string, error)
- func RemovePrefix(value string) string
- func SafeGo(x func())
- func SafeGoWithRestart(x func())
- func ShutdownListener() context.Context
- func Sleep(stop <-chan struct{}, dur time.Duration)
- func SlotAtTimestamp(config beacon.Eth2Config, time uint64) uint64
- func Stack(skip int) []byte
- func StartSlotOfEpoch(config beacon.Eth2Config, epoch uint64) uint64
- func StartTimestampOfEpoch(config beacon.Eth2Config, epoch uint64) uint64
- func StrToFloat(str string) float64
- func StrToInt64(str string) (int64, error)
- func SubOneDay(day string) (string, error)
- func SymbolValid(symbol string) bool
- func TimestampOfSlot(config beacon.Eth2Config, slot uint64) uint64
- func ToBytes16(val []byte) [16]byte
- func ToBytes32(val []byte) [32]byte
- func ToBytes48(val []byte) [48]byte
- func ToBytes64(val []byte) [64]byte
- func ToBytes8(val []byte) [8]byte
- func ToBytes96(val []byte) [96]byte
- func ToUpperList(list []string) []string
- func UnpackEvent(a abi.ABI, v interface{}, name string, data []byte, topics []common.Hash) error
- func Uuid() string
- func VerifyProof(leafNode NodeHash, proof []NodeHash, root NodeHash) bool
- func XOR(data []byte) []byte
- type KeyedMutex
- type MerkleTree
- type Node
- type NodeHash
- type NodeHashList
- type ResGasPrice
- type ResGasPriceFromBeacon
Constants ¶
const ( ValidatorStatusUnInitial = uint8(0) ValidatorStatusDeposited = uint8(1) // lightnode + trust node related ValidatorStatusWithdrawMatch = uint8(2) ValidatorStatusStaked = uint8(3) ValidatorStatusWithdrawUnmatch = uint8(4) // status on beacon chain ValidatorStatusWaiting = uint8(5) ValidatorStatusActive = uint8(6) ValidatorStatusExited = uint8(7) ValidatorStatusWithdrawable = uint8(8) ValidatorStatusWithdrawDone = uint8(9) // after distribute reward ValidatorStatusDistributed = uint8(10) // distribute full withdrawal // after slash ValidatorStatusActiveSlash = uint8(51) ValidatorStatusExitedSlash = uint8(52) ValidatorStatusWithdrawableSlash = uint8(53) ValidatorStatusWithdrawDoneSlash = uint8(54) ValidatorStatusDistributedSlash = uint8(55) // distribute full withdrawal )
1 deposited { 2 withdrawl match 3 staked 4 withdrawl unmatch } { 5 offboard 6 OffBoard can withdraw 7 OffBoard withdrawed } 8 waiting 9 active 10 exited 11 withdrawable 12 withdrawdone { 13 distributed } 51 active+slash 52 exit+slash 53 withdrawable+slash 54 withdrawdone+slash 55 distributed+slash
const ( NodeTypeSolo = uint8(1) NodeTypeTrust = uint8(2) )
1 Solo node 2 trust node
const ( NodeClaimTypeNone = uint8(0) NodeClaimTypeClaimReward = uint8(1) NodeClaimTypeClaimDeposit = uint8(2) NodeClaimTypeClaimTotal = uint8(3) DistributeTypeNone = uint8(0) DistributeTypeWithdrawals = uint8(1) DistributeTypePriorityFee = uint8(2) )
const ( StakerWithdrawalClaimableTimestamp = uint64(1) MinValidatorWithdrawabilityDelay = uint64(256 + 5) MaxDistributeWaitSeconds = uint64(8 * 60 * 60) MaxDistributeWaitEpoch = uint64(75) EjectorUptimeInterval = uint64(10 * 60) )
const ( RetryLimit = 600 RetryInterval = 6 * time.Second )
const ( SymbolDot = "DOT" SymbolKsm = "KSM" SymbolAtom = "ATOM" SymbolEth = "ETH" SymbolFis = "FIS" )
const Day = time.Hour * 24
const DropRate10 = "10000000000000000000"
const DropRate4 = "4000000000000000000"
const DropRate7 = "7000000000000000000"
const PulseChainTestnetV4Name = "pulsechain-testnet-v4"
Variables ¶
var ( GweiDeci = decimal.NewFromInt(1e9) Percent5Deci = decimal.NewFromFloat(0.05) Percent90Deci = decimal.NewFromFloat(0.9) StandardEffectiveBalance uint64 // unit Gwei StandardEffectiveBalanceDeci decimal.Decimal // unit Wei MaxPartialWithdrawalAmount uint64 // unit Gwei MaxPartialWithdrawalAmountDeci decimal.Decimal // unit Wei )
var ( ErrPairNotExist = errors.New("PairNotExist") ErrLeafNodeNotExist = errors.New("LeafNodeNotExist") ErrInvalidTree = errors.New("InvalidateTree") )
var OneWeekSeconds = 7 * 24 * 60 * 60
var ShutdownRequestChannel = make(chan struct{})
shutdownRequestChannel is used to initiate shutdown from one of the subsystems using the same code paths as when an interrupt signal is received.
Functions ¶
func AppendToFile ¶
func Bytes1 ¶
Bytes1 returns the first byte of the little-endian representation of the supplied value.
func Bytes16 ¶
Bytes16 returns the first sixteen bytes of the little-endian representation of the supplied value.
func Bytes2 ¶
Bytes2 returns the first two bytes of the little-endian representation of the supplied value.
func Bytes32 ¶
Bytes32 returns the first thirty-two bytes of the little-endian representation of the supplied value.
func Bytes4 ¶
Bytes4 returns the first four bytes of the little-endian representation of the supplied value.
func Bytes64 ¶
Bytes64 returns the first thirty-two bytes of the little-endian representation of the supplied value.
func Bytes8 ¶
Bytes8 returns the first eight bytes of the little-endian representation of the supplied value.
func EndSlotOfEpoch ¶
func EndSlotOfEpoch(config beacon.Eth2Config, epoch uint64) uint64
func EpochAtTimestamp ¶
func EpochAtTimestamp(config beacon.Eth2Config, time uint64) uint64
Get an eth2 epoch number by time
func ErrToLogStr ¶
func ExecuteFns ¶
func FloatToStr ¶
func FromHexString ¶
FromHexString returns a byte array given a hex string
func GetDropRate ¶
func GetGaspriceFromBeacon ¶
func GetNewDayUtc8Seconds ¶
func GetNewDayUtc8Seconds() int64
func GetNowUTC8Date ¶
func GetNowUTC8Date() string
func GetSwapHash ¶
func GetUserNodePlatformReward ¶
func GetUserNodePlatformReward(nodeCommissionRate, platformCommissionRate, nodeDepositAmountDeci, rewardDeci decimal.Decimal) (decimal.Decimal, decimal.Decimal, decimal.Decimal)
user = 90%*(1-nodedeposit/32) node = 5% + (90% * nodedeposit/32) platform = 5% nodeDepositAmount decimals 18 rewardDeci decimals 18 return (user reward, node reward, platform fee) decimals 18
func GetYesterdayUTC8Date ¶
func GetYesterdayUTC8Date() string
func IsImageExt ¶
func Max ¶
func Max[T constraints.Ordered](a, b T) T
func Min ¶
func Min[T constraints.Ordered](n1 T, nums ...T) T
func PriceSymbolValid ¶
func ProposalId ¶
bytes32 proposalId = keccak256(abi.encodePacked("execProposal", _to, _callData, _proposalFactor));
func PulseChainConfig ¶
func PulseChainConfig() *params.BeaconChainConfig
PulseChainConfig defines the config for the PulseChain beacon chain mainnet.
func PulseChainTestnetV4Config ¶
func PulseChainTestnetV4Config() *params.BeaconChainConfig
PulseChainTestnetV4Config defines the config for the PulseChain beacon chain testnet.
func ReadLastLine ¶
func RemovePrefix ¶
Remove a prefix from a hex string if present
func SafeGoWithRestart ¶
func SafeGoWithRestart(x func())
func ShutdownListener ¶
shutdowntListener listens for OS Signals such as SIGINT (Ctrl+C) and shutdown requests from shutdownRequestChannel. It returns a context that is canceled when either signal is received.
func SlotAtTimestamp ¶
func SlotAtTimestamp(config beacon.Eth2Config, time uint64) uint64
func StartSlotOfEpoch ¶
func StartSlotOfEpoch(config beacon.Eth2Config, epoch uint64) uint64
Get an eth2 first slot number by epoch
func StartTimestampOfEpoch ¶
func StartTimestampOfEpoch(config beacon.Eth2Config, epoch uint64) uint64
func StrToFloat ¶
func StrToInt64 ¶
func SymbolValid ¶
func TimestampOfSlot ¶
func TimestampOfSlot(config beacon.Eth2Config, slot uint64) uint64
func ToBytes16 ¶
ToBytes16 returns a 16-byte array with the supplied value placed in the low-order indices.
func ToBytes32 ¶
ToBytes32 returns a 32-byte array with the supplied value placed in the low-order indices.
func ToBytes48 ¶
ToBytes48 returns a 48-byte array with the supplied value placed in the low-order indices.
func ToBytes64 ¶
ToBytes64 returns a 64-byte array with the supplied value placed in the low-order indices.
func ToBytes8 ¶
ToBytes8 returns an 8-byte array with the supplied value placed in the low-order indices.
func ToBytes96 ¶
ToBytes96 returns a 96-byte array with the supplied value placed in the low-order indices.
func ToUpperList ¶
func UnpackEvent ¶
Types ¶
type KeyedMutex ¶
type KeyedMutex[T comparable] struct { // contains filtered or unexported fields }
func (*KeyedMutex[T]) Delete ¶
func (m *KeyedMutex[T]) Delete(key T)
func (*KeyedMutex[T]) Lock ¶
func (m *KeyedMutex[T]) Lock(key T) func()
type MerkleTree ¶
type MerkleTree struct {
// contains filtered or unexported fields
}
leafNodes on layers[0], rootNode on layers[len(layers)-1]
func NewMerkleTree ¶
func NewMerkleTree(nodeHashList NodeHashList) *MerkleTree
func (*MerkleTree) GetLayers ¶
func (m *MerkleTree) GetLayers() [][]*Node
func (*MerkleTree) GetProof ¶
func (m *MerkleTree) GetProof(leafNodeHash NodeHash) ([]NodeHash, error)
func (*MerkleTree) GetRootHash ¶
func (m *MerkleTree) GetRootHash() (NodeHash, error)
type NodeHash ¶
type NodeHash []byte
func ConbinedHash ¶
func GetNodeHash ¶
func NodeHashFromHexString ¶
type NodeHashList ¶
type NodeHashList []NodeHash
func (NodeHashList) Len ¶
func (nodeHashList NodeHashList) Len() int
func (NodeHashList) Less ¶
func (nodeHashList NodeHashList) Less(i, j int) bool
func (NodeHashList) Swap ¶
func (nodeHashList NodeHashList) Swap(i, j int)
type ResGasPrice ¶
type ResGasPrice struct { BaseFee int `json:"baseFee"` BlockNumber int `json:"blockNumber"` BlockTime float64 `json:"blockTime"` GasPrice struct { Fast int `json:"fast"` Instant int `json:"instant"` Standard int `json:"standard"` } `json:"gasPrice"` NextBaseFee int `json:"nextBaseFee"` PriorityFee struct { Fast int `json:"fast"` Instant int `json:"instant"` Standard int `json:"standard"` } `json:"priorityFee"` }