From 86f7079775ae1c106c466295d700cd49da941e7d Mon Sep 17 00:00:00 2001 From: raina Date: Tue, 27 Feb 2024 18:38:45 +0800 Subject: [PATCH] fix: decodeTxs ch block --- core/types/bid.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/core/types/bid.go b/core/types/bid.go index b6b75cdd3d..57f641dcca 100644 --- a/core/types/bid.go +++ b/core/types/bid.go @@ -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) @@ -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 { @@ -114,8 +120,6 @@ func (b *RawBid) DecodeTxs(signer Signer) ([]*Transaction, error) { bidTxs[txIndex] = tx } - - errChan <- nil }() }