Documentation
¶
Index ¶
- Constants
- func MistToSui(mist string) (int64, error)
- type AddressToValidator
- type Checkpoints
- type EndOfEpochInfo
- type Epoch
- type EpochInfo
- type EpochsHistory
- type Errors
- type GasPrice
- type MetricValue
- type Metrics
- func (metrics *Metrics) CalculateCertificatesRatio()
- func (metrics *Metrics) CalculateCheckpointsRatio()
- func (metrics *Metrics) CalculateRoundsRatio()
- func (metrics *Metrics) CalculateTransactionsRatio()
- func (metrics *Metrics) GetEpochLabel() string
- func (metrics *Metrics) GetEpochProgress() (int, error)
- func (metrics *Metrics) GetMillisecondsTillNextEpoch() (int64, error)
- func (metrics *Metrics) GetTimeUntilNextEpochDisplay() []string
- func (metrics *Metrics) GetValue(metric enums.MetricType) MetricValue
- func (metrics *Metrics) IsHealthy(metric enums.MetricType, valueRPC any) bool
- func (metrics *Metrics) IsUnhealthy(metric enums.MetricType, valueRPC any) bool
- func (metrics *Metrics) SetEpochsHistoryValue(value any) error
- func (metrics *Metrics) SetSystemStateValue(value any) error
- func (metrics *Metrics) SetValidatorsApyValue(value any) error
- func (metrics *Metrics) SetValue(metric enums.MetricType, value any) error
- type Peers
- type Rounds
- type SuiSystemState
- type Transactions
- type Validator
- type ValidatorAtRisk
- type ValidatorReport
- type ValidatorReporter
- type Validators
- func (validators Validators) GetMaxRefGasPrice() (int, error)
- func (validators Validators) GetMeanRefGasPrice() (int, error)
- func (validators Validators) GetMedianRefGasPrice() (int, error)
- func (validators Validators) GetMinRefGasPrice() (int, error)
- func (validators Validators) GetNextRefGasPrice() (int, error)
- func (validators Validators) GetWeightedMeanRefGasPrice() (int, error)
- type ValidatorsApy
- type ValidatorsApyParsed
- type ValidatorsAtRisk
- type ValidatorsReports
Constants ¶
const ( TransactionsPerSecondWindow = 5 CheckpointsPerSecondWindow = 5 RoundsPerSecondWindow = 5 CertificatesPerSecondWindow = 5 TransactionsPerSecondLag = 5 CheckpointsPerSecondLag = 10 LatestCheckpointLag = 30 HighestSyncedCheckpointLag = 30 TotalTransactionsSyncPercentage = 99 TotalCheckpointsSyncPercentage = 99 )
const ( ErrUnexpectedMetricValueType = "unexpected value type for %s: %T" ErrUnsupportedValidatorsAtRiskAttr = "unsupported validatorsAtRisk attribute type: %v" ErrUnsupportedValidatorsReportAttr = "unsupported validatorsReport attribute type: %v" ErrUnsupportedSuiAddressAttr = "unsupported suiAddress attribute type: %v" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AddressToValidator ¶
Validators represents a validator nodes on the Sui blockchain network.
type Checkpoints ¶
type Checkpoints struct { LatestCheckpoint int HighestKnownCheckpoint int HighestSyncedCheckpoint int LastExecutedCheckpoint int CheckpointsPerSecond int CheckpointExecBacklog int CheckpointSyncBacklog int CheckSyncPercentage int CheckpointsHistory []int }
Checkpoints represents information about checkpoints on the Sui blockchain network.
type EndOfEpochInfo ¶
type EndOfEpochInfo struct { LastCheckpointID string `json:"lastCheckpointId"` EpochEndTimestamp string `json:"epochEndTimestamp"` ProtocolVersion string `json:"protocolVersion"` ReferenceGasPrice string `json:"referenceGasPrice"` TotalStake string `json:"totalStake"` StorageFundReinvestment string `json:"storageFundReinvestment"` StorageCharge string `json:"storageCharge"` StorageRebate string `json:"storageRebate"` StorageFundBalance string `json:"storageFundBalance"` StakeSubsidyAmount string `json:"stakeSubsidyAmount"` TotalGasFees string `json:"totalGasFees"` TotalStakeRewardsDistributed string `json:"totalStakeRewardsDistributed"` LeftoverStorageFundInflow string `json:"leftoverStorageFundInflow"` }
EndOfEpochInfo represents information about the end of epoch.
type Epoch ¶
type Epoch struct { CurrentEpoch int EpochStartTimeUTC string EpochTotalDuration int EpochDurationHHMM string DurationTillEpochEndHHMM string EpochPercentage int TimeTillNextEpoch int64 }
Epoch represents information about the current epoch on the Sui blockchain network.
type EpochInfo ¶
type EpochInfo struct { Epoch string `json:"epoch"` Validators []interface{} `json:"validators"` EpochTotalTransactions string `json:"epochTotalTransactions"` FirstCheckpointID string `json:"firstCheckpointId"` EpochStartTimestamp string `json:"epochStartTimestamp"` EndOfEpochInfo *EndOfEpochInfo `json:"endOfEpochInfo"` }
EpochInfo represents information about the epoch.
type EpochsHistory ¶
type EpochsHistory struct {
Data []EpochInfo `json:"data"`
}
EpochsHistory represents a list of epoch data returned by an API.
type GasPrice ¶
type GasPrice struct { MinReferenceGasPrice int // The minimum gas price (in wei) that transactions should pay in order to be included in the next block. MaxReferenceGasPrice int // The maximum gas price (in wei) that transactions should pay in order to avoid overpaying and wasting funds. MeanReferenceGasPrice int // The average gas price (in wei) of transactions that were included in the last few blocks. StakeWeightedMeanReferenceGasPrice int // The average gas price (in wei) weighted by the amount of stake that each validator has on the network. MedianReferenceGasPrice int // The middle value of the sorted list of gas prices (in wei) that were included in the last few blocks. EstimatedNextReferenceGasPrice int // The gas price (in wei) that is estimated to be included in the next block based on recent network activity and congestion. }
GasPrice represents the different reference gas prices used on the network.
type MetricValue ¶
type MetricValue interface{}
type Metrics ¶
type Metrics struct { Updated bool SystemState SuiSystemState ValidatorsApyParsed ValidatorsApyParsed EpochsHistory []EpochInfo Uptime string Version string Commit string Transactions Checkpoints Rounds Peers Epoch GasPrice Errors }
Metrics represents various metrics about the Sui blockchain network.
func NewMetrics ¶
func NewMetrics() *Metrics
NewMetrics initializes a new instance of Metrics with default values.
func (*Metrics) CalculateCertificatesRatio ¶
func (metrics *Metrics) CalculateCertificatesRatio()
CalculateCertificatesRatio calculates the current certificates per second (CPS) based on the number of certificates created within the current period. The CPS value is then stored in the Metrics struct.
func (*Metrics) CalculateCheckpointsRatio ¶
func (metrics *Metrics) CalculateCheckpointsRatio()
CalculateCheckpointsRatio calculates the current checkpoints per second (CPS) based on the number of checkpoints generated within the current period. The CPS value is then stored in the Metrics struct.
func (*Metrics) CalculateRoundsRatio ¶
func (metrics *Metrics) CalculateRoundsRatio()
CalculateRoundsRatio calculates the current rounds per second (RPS) based on the number of rounds processed within the current period. The RPS value is then stored in the Metrics struct.
func (*Metrics) CalculateTransactionsRatio ¶
func (metrics *Metrics) CalculateTransactionsRatio()
CalculateTransactionsRatio calculates the current transaction per second (TPS) based on the number of transactions processed within the current period. The TPS value is then stored in the Metrics struct.
func (*Metrics) GetEpochLabel ¶
GetEpochLabel returns a string representing the current epoch number.
func (*Metrics) GetEpochProgress ¶
GetEpochProgress calculates and returns the percentage of current epoch progress.
func (*Metrics) GetMillisecondsTillNextEpoch ¶
GetMillisecondsTillNextEpoch returns the milliseconds till the next epoch.
func (*Metrics) GetTimeUntilNextEpochDisplay ¶
GetTimeUntilNextEpochDisplay returns the remaining time till the next epoch in human-readable format.
func (*Metrics) GetValue ¶
func (metrics *Metrics) GetValue(metric enums.MetricType) MetricValue
GetValue returns the metric value for the given metric type.
func (*Metrics) IsHealthy ¶
func (metrics *Metrics) IsHealthy(metric enums.MetricType, valueRPC any) bool
IsHealthy checks if the given metric's value satisfies the threshold defined for it. If the metric type is not recognized, returns true. The valueRPC argument is the value retrieved from the Sui RPC endpoint for the corresponding metric. Returns true if the metric value is healthy, false otherwise.
func (*Metrics) IsUnhealthy ¶
func (metrics *Metrics) IsUnhealthy(metric enums.MetricType, valueRPC any) bool
func (*Metrics) SetEpochsHistoryValue ¶
SetEpochsHistoryValue sets the epochs history based on the parsed data.
func (*Metrics) SetSystemStateValue ¶
SetSystemStateValue sets the SUI system state metrics based on the parsed data.
func (*Metrics) SetValidatorsApyValue ¶
SetValidatorsApyValue sets the validators apy metrics based on the parsed data.
type Rounds ¶
type Rounds struct { CurrentRound int HighestProcessedRound int RoundsPerSecond int LastCommittedRound int RoundsHistory []int }
Rounds represents information about rounds on the Sui blockchain network.
type SuiSystemState ¶
type SuiSystemState struct { Epoch string `json:"epoch"` ProtocolVersion string `json:"protocolVersion"` SystemStateVersion string `json:"systemStateVersion"` StorageFundTotalObjectStorageRebates string `json:"storageFundTotalObjectStorageRebates"` StorageFundNonRefundableBalance string `json:"storageFundNonRefundableBalance"` ReferenceGasPrice string `json:"referenceGasPrice"` SafeMode bool `json:"safeMode"` SafeModeStorageRewards string `json:"safeModeStorageRewards"` SafeModeComputationRewards string `json:"safeModeComputationRewards"` SafeModeStorageRebates string `json:"safeModeStorageRebates"` SafeModeNonRefundableStorageFee string `json:"safeModeNonRefundableStorageFee"` EpochStartTimestampMs string `json:"epochStartTimestampMs"` EpochDurationMs string `json:"epochDurationMs"` StakeSubsidyStartEpoch string `json:"stakeSubsidyStartEpoch"` MaxValidatorCount string `json:"maxValidatorCount"` MinValidatorJoiningStake string `json:"minValidatorJoiningStake"` ValidatorLowStakeThreshold string `json:"validatorLowStakeThreshold"` ValidatorVeryLowStakeThreshold string `json:"validatorVeryLowStakeThreshold"` ValidatorLowStakeGracePeriod string `json:"validatorLowStakeGracePeriod"` StakeSubsidyBalance string `json:"stakeSubsidyBalance"` StakeSubsidyDistributionCounter string `json:"stakeSubsidyDistributionCounter"` StakeSubsidyCurrentDistributionAmount string `json:"stakeSubsidyCurrentDistributionAmount"` StakeSubsidyPeriodLength string `json:"stakeSubsidyPeriodLength"` StakeSubsidyDecreaseRate int `json:"stakeSubsidyDecreaseRate"` TotalStake string `json:"totalStake"` ActiveValidators Validators `json:"activeValidators"` PendingActiveValidatorsID string `json:"pendingActiveValidatorsId"` PendingActiveValidatorsSize string `json:"pendingActiveValidatorsSize"` PendingRemovals []interface{} `json:"pendingRemovals"` StakingPoolMappingsID string `json:"stakingPoolMappingsId"` StakingPoolMappingsSize string `json:"stakingPoolMappingsSize"` InactivePoolsID string `json:"inactivePoolsId"` InactivePoolsSize string `json:"inactivePoolsSize"` ValidatorCandidatesID string `json:"validatorCandidatesId"` ValidatorCandidatesSize string `json:"validatorCandidatesSize"` AtRiskValidators [][]interface{} `json:"atRiskValidators"` ValidatorReportRecords [][]interface{} `json:"validatorReportRecords"` AddressToValidator AddressToValidator ValidatorsAtRiskParsed ValidatorsAtRisk ValidatorReportsParsed ValidatorsReports }
SuiSystemState represents the current state of the Sui blockchain system.
type Transactions ¶
type Transactions struct { TotalTransactionsBlocks int TotalTransactionCertificates int CertificatesCreated int CertificatesPerSecond int NonConsensusLatency int TotalTransactionEffects int TransactionsPerSecond int TxSyncPercentage int TransactionsHistory []int CertificatesHistory []int }
Transactions represents information about transactions on the Sui blockchain network.
type Validator ¶
type Validator struct { SuiAddress string `json:"suiAddress"` ProtocolPubkeyBytes string `json:"protocolPubkeyBytes"` NetworkPubkeyBytes string `json:"networkPubkeyBytes"` WorkerPubkeyBytes string `json:"workerPubkeyBytes"` ProofOfPossessionBytes string `json:"proofOfPossessionBytes"` Name string `json:"name"` Description string `json:"description"` ImageURL string `json:"imageUrl"` ProjectURL string `json:"projectUrl"` NetAddress string `json:"netAddress"` P2PAddress string `json:"p2pAddress"` PrimaryAddress string `json:"primaryAddress"` WorkerAddress string `json:"workerAddress"` NextEpochProtocolPubkeyBytes interface{} `json:"nextEpochProtocolPubkeyBytes"` NextEpochProofOfPossession interface{} `json:"nextEpochProofOfPossession"` NextEpochNetworkPubkeyBytes interface{} `json:"nextEpochNetworkPubkeyBytes"` NextEpochWorkerPubkeyBytes interface{} `json:"nextEpochWorkerPubkeyBytes"` NextEpochNetAddress interface{} `json:"nextEpochNetAddress"` NextEpochP2PAddress interface{} `json:"nextEpochP2pAddress"` NextEpochPrimaryAddress interface{} `json:"nextEpochPrimaryAddress"` NextEpochWorkerAddress interface{} `json:"nextEpochWorkerAddress"` VotingPower string `json:"votingPower"` OperationCapID string `json:"operationCapId"` GasPrice string `json:"gasPrice"` CommissionRate string `json:"commissionRate"` NextEpochStake string `json:"nextEpochStake"` NextEpochGasPrice string `json:"nextEpochGasPrice"` NextEpochCommissionRate string `json:"nextEpochCommissionRate"` StakingPoolID string `json:"stakingPoolId"` StakingPoolActivationEpoch string `json:"stakingPoolActivationEpoch"` StakingPoolDeactivationEpoch interface{} `json:"stakingPoolDeactivationEpoch"` StakingPoolSuiBalance string `json:"stakingPoolSuiBalance"` RewardsPool string `json:"rewardsPool"` PoolTokenBalance string `json:"poolTokenBalance"` PendingStake string `json:"pendingStake"` PendingTotalSuiWithdraw string `json:"pendingTotalSuiWithdraw"` PendingPoolTokenWithdraw string `json:"pendingPoolTokenWithdraw"` ExchangeRatesID string `json:"exchangeRatesId"` ExchangeRatesSize string `json:"exchangeRatesSize"` APY string }
Validators represents a validator nodes on the Sui blockchain network.
type ValidatorAtRisk ¶
ValidatorAtRisk represents a validator node at risk on the Sui blockchain network.
func NewValidatorAtRisk ¶
func NewValidatorAtRisk(name, address, epochsAtRisk string) ValidatorAtRisk
NewValidatorAtRisk creates a new ValidatorAtRisk instance with the specified name, address, and epochs at risk.
type ValidatorReport ¶
type ValidatorReport struct { Name string SlashingPercentage float64 Reporters []ValidatorReporter }
ValidatorReport represents validator reporters
func NewValidatorReport ¶
func NewValidatorReport(name string, slashingPct float64, reporters []ValidatorReporter) ValidatorReport
NewValidatorReport creates a new ValidatorReport instance with the specified name, slashing percentage, and reporters.
type ValidatorReporter ¶
ValidatorReporter contains information about a validator reporter
func NewValidatorReporter ¶
func NewValidatorReporter(name, address string, votingPower int) ValidatorReporter
NewValidatorReporter creates a new ValidatorReporter instance with the specified name, address, and voting power.
type Validators ¶
type Validators []*Validator
Validators represents a validator nodes on the Sui blockchain network.
func (Validators) GetMaxRefGasPrice ¶
func (validators Validators) GetMaxRefGasPrice() (int, error)
GetMaxRefGasPrice returns the maximum reference gas price among all validators. If there are no validators or if all validators have an invalid gas price, it returns an error.
func (Validators) GetMeanRefGasPrice ¶
func (validators Validators) GetMeanRefGasPrice() (int, error)
GetMeanRefGasPrice calculates the mean reference gas price among all validators. If there are no validators or if all validators have an invalid gas price, it returns an error.
func (Validators) GetMedianRefGasPrice ¶
func (validators Validators) GetMedianRefGasPrice() (int, error)
GetMedianRefGasPrice calculates the median reference gas price among all validators. If there are no validators or if all validators have an invalid gas price, it returns an error.
func (Validators) GetMinRefGasPrice ¶
func (validators Validators) GetMinRefGasPrice() (int, error)
GetMinRefGasPrice returns the minimum reference gas price among all validators. If there are no validators or if all validators have an invalid gas price, it returns an error.
func (Validators) GetNextRefGasPrice ¶
func (validators Validators) GetNextRefGasPrice() (int, error)
GetNextRefGasPrice calculates the next reference gas price for the Sui blockchain network. The reference gas price is determined by sorting the validators by their gas prices and selecting the gas price for which the cumulative voting power of validators exceeds two-thirds of the total voting power. If there are no validators or if all validators have an invalid gas price or voting power, it returns an error.
func (Validators) GetWeightedMeanRefGasPrice ¶
func (validators Validators) GetWeightedMeanRefGasPrice() (int, error)
GetWeightedMeanRefGasPrice calculates the stake-weighted mean reference gas price among all validators. If there are no validators or if all validators have an invalid gas price or stake, it returns an error.
type ValidatorsApy ¶
type ValidatorsApy struct { Apys []struct { Address string `json:"address"` Apy float64 `json:"apy"` } `json:"apys"` }
ValidatorsApy represents the APYs of validators.
type ValidatorsApyParsed ¶
type ValidatorsAtRisk ¶
type ValidatorsAtRisk []ValidatorAtRisk
type ValidatorsReports ¶
type ValidatorsReports []ValidatorReport
ValidatorsReports is a map where the key is the address of a validator and the value is a ValidatorReports instance containing all the reports for that validator