Skip to content

Commit

Permalink
fix: decodeTxs ch block
Browse files Browse the repository at this point in the history
  • Loading branch information
irrun committed Feb 27, 2024
1 parent bfc662d commit 86f7079
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions core/types/bid.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (b *RawBid) DecodeTxs(signer Signer) ([]*Transaction, error) {
return []*Transaction{}, nil
}

txChan := make(chan int, TxDecodeConcurrencyForPerBid)
txChan := make(chan int, len(b.Txs))
bidTxs := make([]*Transaction, len(b.Txs))
decode := func(txBytes hexutil.Bytes) (*Transaction, error) {
tx := new(Transaction)
Expand All @@ -104,7 +104,13 @@ func (b *RawBid) DecodeTxs(signer Signer) ([]*Transaction, error) {
errChan := make(chan error, TxDecodeConcurrencyForPerBid)
for i := 0; i < TxDecodeConcurrencyForPerBid; i++ {
go func() {
for txIndex := range txChan {
for {
txIndex, ok := <-txChan
if !ok {
errChan <- nil
return
}

txBytes := b.Txs[txIndex]
tx, err := decode(txBytes)
if err != nil {
Expand All @@ -114,8 +120,6 @@ func (b *RawBid) DecodeTxs(signer Signer) ([]*Transaction, error) {

bidTxs[txIndex] = tx
}

errChan <- nil
}()
}

Expand Down

0 comments on commit 86f7079

Please sign in to comment.