Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jianoaix committed Mar 19, 2024
1 parent 1a9c51d commit 49e3aa7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
11 changes: 8 additions & 3 deletions core/eth/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"crypto/ecdsa"
"encoding/json"
"fmt"
"math/big"
"slices"

Expand Down Expand Up @@ -580,8 +581,10 @@ func (t *Transactor) GetQuorumBitmapForOperatorsAtBlockNumber(ctx context.Contex
// Get the bitmap indices for all the given operators.
type BitmapIndexOrError struct {
bitmapIndex int
index int
err error
// The index is referring to the position of operator in operatorIds slice,
// i.e. the bitmap here (if err is nil) is for operatorIds[index].
index int
err error
}
indexChan := make(chan BitmapIndexOrError, len(operatorIds))
indexPool := workerpool.New(maxNumWorkerPoolThreads)
Expand All @@ -604,6 +607,7 @@ func (t *Transactor) GetQuorumBitmapForOperatorsAtBlockNumber(ctx context.Contex
}
indexPool.StopWait()
close(indexChan)
// quorumBitmapIndices[i] is the bitmap index for operatorIds[i].
quorumBitmapIndices := make([]int, len(operatorIds))
for result := range indexChan {
if result.err != nil {
Expand All @@ -629,7 +633,7 @@ func (t *Transactor) GetQuorumBitmapForOperatorsAtBlockNumber(ctx context.Contex
op := operatorIds[i]
pool.Submit(func() {
if bitmapIndex == -1 {
resultChan <- BitmapOrError{bitmap: nil, index: i, err: errors.New("no bitmap found for operator")}
resultChan <- BitmapOrError{bitmap: nil, index: i, err: fmt.Errorf("no bitmap index found for operator: %s", op.Hex())}
return
}
bm, err := t.Bindings.RegistryCoordinator.GetQuorumBitmapAtBlockNumberByIndex(&bind.CallOpts{
Expand All @@ -644,6 +648,7 @@ func (t *Transactor) GetQuorumBitmapForOperatorsAtBlockNumber(ctx context.Contex
bitmaps := make([]*big.Int, len(quorumBitmapIndices))
for result := range resultChan {
if result.err != nil {
// For operators not found bitmap, set the bitmap to empty.
bitmaps[result.index] = big.NewInt(0)
} else {
bitmaps[result.index] = result.bitmap
Expand Down
5 changes: 4 additions & 1 deletion core/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ type Transactor interface {

// GetQuorumBitmapForOperatorsAtBlockNumber returns the quorum bitmaps for the operators
// at the given block number.
GetQuorumBitmapForOperatorsAtBlockNumber(ctx context.Context, operatorId []OperatorID, blockNumber uint32) ([]*big.Int, error)
// The result slice will be of same length as "operatorIds", with the i-th entry be the
// result for the operatorIds[i]. If an operator failed to find bitmap, the corresponding
// result entry will be an empty bitmap.
GetQuorumBitmapForOperatorsAtBlockNumber(ctx context.Context, operatorIds []OperatorID, blockNumber uint32) ([]*big.Int, error)

// GetOperatorSetParams returns operator set params for the quorum.
GetOperatorSetParams(ctx context.Context, quorumID QuorumID) (*OperatorSetParam, error)
Expand Down

0 comments on commit 49e3aa7

Please sign in to comment.