Skip to content

Commit

Permalink
refactor: reduce contract calls
Browse files Browse the repository at this point in the history
  • Loading branch information
hopeyen committed Dec 2, 2024
1 parent fdf599b commit b8566be
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/eth/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (cs *ChainState) GetOperatorState(ctx context.Context, blockNumber uint, qu
return nil, err
}

socketMap, err := cs.buildSocketMap(ctx, operatorsByQuorum, uint32(blockNumber))
socketMap, err := cs.buildSocketMap(ctx, operatorsByQuorum)
if err != nil {
return nil, err
}
Expand All @@ -72,10 +72,14 @@ func (cs *ChainState) GetOperatorSocket(ctx context.Context, blockNumber uint, o
}

// buildSocketMap returns a map from operatorID to socket address for the operators in the operatorsByQuorum
func (cs *ChainState) buildSocketMap(ctx context.Context, operatorsByQuorum core.OperatorStakes, blockNumber uint32) (map[core.OperatorID]string, error) {
func (cs *ChainState) buildSocketMap(ctx context.Context, operatorsByQuorum core.OperatorStakes) (map[core.OperatorID]string, error) {
socketMap := make(map[core.OperatorID]string)
for _, quorum := range operatorsByQuorum {
for _, op := range quorum {
// if the socket is already in the map, skip
if _, ok := socketMap[op.OperatorID]; ok {
continue
}
socket, err := cs.Tx.GetOperatorSocket(ctx, op.OperatorID)
if err != nil {
return nil, err
Expand Down

0 comments on commit b8566be

Please sign in to comment.