mirror of
https://github.com/luxfi/sdk.git
synced 2026-10-30 15:19:23 +00:00
Lux Partners Limited is not the entity behind this work. Every place the old name stood — copyright lines, site footers, brand config, legal and compliance text — now names the company that actually holds it. lux.fund is the exception and is not renamed to match: that site belongs to Lux Assets Management LLC, a different company, and it says so. Two kinds of line were left for a person rather than rewritten. A dated news item recording that Lux Partners Limited was established in the Isle of Man is a historical fact, and renaming it would falsify the record. And a sentence asserting that the company is domiciled in the Isle of Man is a claim about a jurisdiction, not a name — an Inc or an LLC is not an Isle of Man company, so swapping the name there would assert something untrue. Co-authored-by: Hanzo Dev <[email protected]>
38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
// Copyright (C) 2025, Lux Industries Inc All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package validatormanager
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/luxfi/constants"
|
|
"github.com/luxfi/evm/plugin/evm/client"
|
|
"github.com/luxfi/ids"
|
|
"github.com/luxfi/net"
|
|
)
|
|
|
|
// GetL1ValidatorUptimeSeconds returns the uptime of the L1 validator
|
|
func GetL1ValidatorUptimeSeconds(rpcURL string, nodeID ids.NodeID) (uint64, error) {
|
|
ctx, cancel := apiRequestContext()
|
|
defer cancel()
|
|
networkEndpoint, blockchainID, err := netutil.SplitLuxgoRPCURI(rpcURL)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
evmCli := client.NewClient(networkEndpoint, blockchainID)
|
|
validators, err := evmCli.GetCurrentValidators(ctx, []ids.NodeID{nodeID})
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
if len(validators) > 0 {
|
|
deductibleSeconds := uint64(constants.ValidatorUptimeDeductible.Seconds())
|
|
if validators[0].UptimeSeconds > deductibleSeconds {
|
|
return validators[0].UptimeSeconds - deductibleSeconds, nil
|
|
}
|
|
return 0, nil
|
|
}
|
|
|
|
return 0, errors.New("nodeID not found in validator set: " + nodeID.String())
|
|
}
|