Files
evm/warp/messages/validator_uptime.go
zeekayandHanzo Dev 9f89eaeda3 strip 26 dead serialize:"true" tags (message/validators/warp)
The message/validators/warp marshalers are hand-rolled per-type packers
(marshalValue type switch) that ignore struct tags — the linearcodec that read
them is gone. Pure dead metadata. Golden round-trip tests green (byte-identical).

Co-authored-by: Hanzo Dev <[email protected]>
2026-07-14 15:14:32 -07:00

52 lines
1.3 KiB
Go

// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package messages
import (
"fmt"
"github.com/luxfi/ids"
)
// ValidatorUptime is signed when the ValidationID is known and the validator
// has been up for TotalUptime seconds.
type ValidatorUptime struct {
ValidationID ids.ID
TotalUptime uint64 // in seconds
bytes []byte
}
// NewValidatorUptime creates a new *ValidatorUptime and initializes it.
func NewValidatorUptime(validationID ids.ID, totalUptime uint64) (*ValidatorUptime, error) {
bhp := &ValidatorUptime{
ValidationID: validationID,
TotalUptime: totalUptime,
}
return bhp, initialize(bhp)
}
// ParseValidatorUptime converts a slice of bytes into an initialized ValidatorUptime.
func ParseValidatorUptime(b []byte) (*ValidatorUptime, error) {
payloadIntf, err := Parse(b)
if err != nil {
return nil, err
}
payload, ok := payloadIntf.(*ValidatorUptime)
if !ok {
return nil, fmt.Errorf("%w: %T", errWrongType, payloadIntf)
}
return payload, nil
}
// Bytes returns the binary representation of this payload. It assumes that the
// payload is initialized from either NewValidatorUptime or Parse.
func (b *ValidatorUptime) Bytes() []byte {
return b.bytes
}
func (b *ValidatorUptime) initialize(bytes []byte) {
b.bytes = bytes
}