Skip to content

Commit

Permalink
Index operator state by quorum id not quorum index
Browse files Browse the repository at this point in the history
  • Loading branch information
mooselumph committed Mar 27, 2024
1 parent 3b72e3d commit 7168a56
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions core/eth/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ func NewChainState(tx core.Transactor, client common.EthClient) *ChainState {
var _ core.ChainState = (*ChainState)(nil)

func (cs *ChainState) GetOperatorStateByOperator(ctx context.Context, blockNumber uint, operator core.OperatorID) (*core.OperatorState, error) {
operatorsByQuorum, quorumIds, err := cs.Tx.GetOperatorStakes(ctx, operator, uint32(blockNumber))
operatorsByQuorum, _, err := cs.Tx.GetOperatorStakes(ctx, operator, uint32(blockNumber))
if err != nil {
return nil, err
}

return getOperatorState(operatorsByQuorum, quorumIds, uint32(blockNumber))
return getOperatorState(operatorsByQuorum, uint32(blockNumber))

}

Expand All @@ -38,7 +38,7 @@ func (cs *ChainState) GetOperatorState(ctx context.Context, blockNumber uint, qu
return nil, err
}

return getOperatorState(operatorsByQuorum, quorums, uint32(blockNumber))
return getOperatorState(operatorsByQuorum, uint32(blockNumber))
}

func (cs *ChainState) GetCurrentBlockNumber() (uint, error) {
Expand All @@ -51,7 +51,7 @@ func (cs *ChainState) GetCurrentBlockNumber() (uint, error) {
return uint(header.Number.Uint64()), nil
}

func getOperatorState(operatorsByQuorum core.OperatorStakes, quorumIds []core.QuorumID, blockNumber uint32) (*core.OperatorState, error) {
func getOperatorState(operatorsByQuorum core.OperatorStakes, blockNumber uint32) (*core.OperatorState, error) {
operators := make(map[core.QuorumID]map[core.OperatorID]*core.OperatorInfo)
totals := make(map[core.QuorumID]*core.OperatorInfo)

Expand Down
6 changes: 3 additions & 3 deletions core/eth/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,11 @@ func (t *Transactor) GetOperatorStakes(ctx context.Context, operator core.Operat
return nil, nil, err
}

quorumIds := BitmapToQuorumIds(quorumBitmap)

state := make(core.OperatorStakes, len(state_))
for i := range state_ {
quorumID := core.QuorumID(i)
quorumID := quorumIds[i]
state[quorumID] = make(map[core.OperatorIndex]core.OperatorStake, len(state_[i]))
for j, op := range state_[i] {
operatorIndex := core.OperatorIndex(j)
Expand All @@ -383,8 +385,6 @@ func (t *Transactor) GetOperatorStakes(ctx context.Context, operator core.Operat
}
}

quorumIds := BitmapToQuorumIds(quorumBitmap)

return state, quorumIds, nil
}

Expand Down

0 comments on commit 7168a56

Please sign in to comment.