state

package
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2025 License: Apache-2.0, UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileState

type FileState struct {
	Height    int64  `json:"height" comment:"the height of the last sign"`
	Round     int    `json:"round" comment:"the round of the last sign"`
	Step      Step   `json:"step" comment:"the step of the last sign"`
	SignBytes []byte `json:"signbytes,omitempty" comment:"the raw signature bytes of the last sign"`
	Signature []byte `json:"signature,omitempty" comment:"the signature of the last sign"`
	// contains filtered or unexported fields
}

FileState stores the state of the last signing operation in a file. NOTE: keep in sync with gno.land/cmd/gnoland/secrets.go NOTE: this was migrated from tm2/pkg/bft/privval/file.go

func GeneratePersistedFileState

func GeneratePersistedFileState(filePath string) (*FileState, error)

GeneratePersistedFileState generates a new FileState persisted to disk.

func LoadFileState

func LoadFileState(filePath string) (*FileState, error)

LoadFileState reads a FileState from the given file path.

func LoadOrMakeFileState

func LoadOrMakeFileState(filePath string) (*FileState, error)

LoadOrMakeFileState returns a new FileState instance from the given file path. If the file does not exist, a new FileState is generated and persisted to disk.

func (*FileState) CheckHRS

func (fs *FileState) CheckHRS(height int64, round int, step Step) (bool, error)

checkHRS checks the given height, round, step (HRS) against the last state. It returns an error if the arguments constitute a regression, or if HRS match but the SignBytes are not set. The returned boolean indicates whether the last Signature should be reused or not. It will be true if the HRS match and the SignBytes and Signature are already set in the last state (indicating we have already signed for this HRS).

func (*FileState) CheckProposalsOnlyDifferByTimestamp

func (fs *FileState) CheckProposalsOnlyDifferByTimestamp(signBytes []byte) (time.Time, bool)

checkProposalsOnlyDifferByTimestamp returns the timestamp from the last state SignBytes and a boolean indicating if the only difference in the proposals is their timestamp.

func (*FileState) CheckVotesOnlyDifferByTimestamp

func (fs *FileState) CheckVotesOnlyDifferByTimestamp(signBytes []byte) (time.Time, bool)

checkVotesOnlyDifferByTimestamp returns the timestamp from the last state SignBytes and a boolean indicating if the only difference in the votes is their timestamp.

func (*FileState) String

func (fs *FileState) String() string

String implements fmt.Stringer.

func (*FileState) Update

func (fs *FileState) Update(height int64, round int, step Step, signBytes, signature []byte) error

update updates the FileState then persists it to disk.

type Step

type Step uint8

Step is the step in the consensus process.

const (
	StepPropose   Step = 1 // Only used in proposal signing
	StepPrevote   Step = 2 // Only used in vote signing
	StepPrecommit Step = 3 // Only used in vote signing
)

func VoteTypeToStep

func VoteTypeToStep(voteType types.SignedMsgType) Step

A vote type is either stepPrevote or stepPrecommit.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL