simulation

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindSlotLeader

func FindSlotLeader(timeslot jamtime.Timeslot, currentState *state.State, keys []ValidatorKeys) (string, crypto.BandersnatchPrivateKey, error)

Figures out the current slot leader by checking each of the validator keys. Useful only for testing.

func IsSlotLeader

func IsSlotLeader(timeslot jamtime.Timeslot, currentState *state.State, privateKey crypto.BandersnatchPrivateKey) (bool, error)

Determines if the given private key is the slot leader for the given timeslot.

func NextSafroleState

func NextSafroleState(currentState *state.State, nextTimeslot jamtime.Timeslot) (
	validator.ValidatorState,
	statetransition.SafroleOutput,
	error)

Determines the next SAFROLE state. Useful for functions that need to determine the SAFROLE state outside of the main UpdateState function.

func ProduceBlock

func ProduceBlock(
	timeslot jamtime.Timeslot,
	parentHash crypto.Hash,
	currentState *state.State,
	trie *store.Trie,
	privateKey crypto.BandersnatchPrivateKey,
	extrinsics block.Extrinsic,
) (block.Block, error)

Produces a block. This function will stabilize over time and eventually be moved into a node package. Right now it can correctly package tickets but other extrinsics are just added to the block as is.

Types

type ValidatorKeys

type ValidatorKeys struct {
	Name                string                        `json:"name"`
	Seed                string                        `json:"seed"`
	Ed25519Private      ed25519.PrivateKey            `json:"ed25519_private"`
	Ed25519Public       ed25519.PublicKey             `json:"ed25519_public"`
	BandersnatchPrivate crypto.BandersnatchPrivateKey `json:"bandersnatch_private"`
	BandersnatchPublic  crypto.BandersnatchPublicKey  `json:"bandersnatch_public"`
	DnsAltName          string                        `json:"dns_alt_name"`
}

Stores validator keys for testing purposes.

func (*ValidatorKeys) MarshalJSON

func (v *ValidatorKeys) MarshalJSON() ([]byte, error)

func (*ValidatorKeys) UnmarshalJSON

func (v *ValidatorKeys) UnmarshalJSON(data []byte) error

type ValidatorKeysEncoded

type ValidatorKeysEncoded struct {
	Name                string `json:"name"`
	Seed                string `json:"seed"`
	Ed25519Private      string `json:"ed25519_private"`
	Ed25519Public       string `json:"ed25519_public"`
	BandersnatchPrivate string `json:"bandersnatch_private"`
	BandersnatchPublic  string `json:"bandersnatch_public"`
	DnsAltName          string `json:"dns_alt_name"`
}

Jump to

Keyboard shortcuts

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