State
State Objects
The x/epochs
module keeps the following objects in state
:
EpochInfo
Epoch info bytecode
[]byte{identifier}
[]byte{epochInfo}
KV
EpochInfo
An EpochInfo
defines several variables:
identifier
keeps an epoch identification stringstart_time
keeps the start time for epoch counting: if block height passesstart_time
, thenepoch_counting_started
is setduration
keeps the target epoch durationcurrent_epoch
keeps the current active epoch numbercurrent_epoch_start_time
keeps the start time of the current epochepoch_counting_started
is a flag set withstart_time
, at which pointepoch_number
will be countedcurrent_epoch_start_height
keeps the start block height of the current epoch
message EpochInfo {
string identifier = 1;
google.protobuf.Timestamp start_time = 2 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"start_time\""
];
google.protobuf.Duration duration = 3 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true,
(gogoproto.jsontag) = "duration,omitempty",
(gogoproto.moretags) = "yaml:\"duration\""
];
int64 current_epoch = 4;
google.protobuf.Timestamp current_epoch_start_time = 5 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"current_epoch_start_time\""
];
bool epoch_counting_started = 6;
reserved 7;
int64 current_epoch_start_height = 8;
}
The epochs
module keeps these EpochInfo
objects in state, which are initialized at genesis and are modified on begin blockers or end blockers.
Genesis State
The x/epochs
module's GenesisState
defines the state necessary for initializing the chain from a previously exported height. It contains a slice containing all the EpochInfo
objects kept in state:
// Genesis State defines the epoch module's genesis state
type GenesisState struct {
// list of EpochInfo structs corresponding to all epochs
Epochs []EpochInfo `protobuf:"bytes,1,rep,name=epochs,proto3" json:"epochs"`
}
Last updated