From 51479adbcfb39690fc49004241de5ca21c4ce568 Mon Sep 17 00:00:00 2001 From: adlrocha Date: Tue, 7 Mar 2023 18:42:10 +0100 Subject: [PATCH] get checkpoint and votes from subnet actor (#13) --- subnetactor/subnet-actor.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/subnetactor/subnet-actor.go b/subnetactor/subnet-actor.go index 373cd44..5ddfd6d 100644 --- a/subnetactor/subnet-actor.go +++ b/subnetactor/subnet-actor.go @@ -28,7 +28,7 @@ type State struct { Genesis []byte FinalityThreshold abi.ChainEpoch CheckPeriod abi.ChainEpoch - Checkpoints cid.Cid // TCid> + Checkpoints cid.Cid // TCid> WindowChecks cid.Cid // TCid>, ValidatorSet *validator.Set MinValidators uint64 @@ -45,8 +45,12 @@ func (st *State) GetStake(s adt.Store, id address.Address) (abi.TokenAmount, err return *out, err } -func (st *State) GetCheckpoint(s adt.Store, id address.Address) (*gateway.Checkpoint, bool, error) { - return utils.GetOutOfHamt[gateway.Checkpoint](st.Stake, s, abi.AddrKey(id)) +func (st *State) GetCheckpoint(s adt.Store, epoch abi.ChainEpoch) (*gateway.Checkpoint, bool, error) { + return utils.GetOutOfHamt[gateway.Checkpoint](st.Stake, s, abi.UIntKey(uint64(epoch))) +} + +func (st *State) GetCheckpointVotes(s adt.Store, checkCid cid.Cid) (*Votes, bool, error) { + return utils.GetOutOfHamt[Votes](st.WindowChecks, s, abi.CidKey(checkCid)) } func (st *State) HasMajorityVote(s adt.Store, v Votes) (bool, error) {