@@ -1640,11 +1640,11 @@ func (p *BlobPool) AvailableBlobs(vhashes []common.Hash) int {
1640
1640
return available
1641
1641
}
1642
1642
1643
- // preCheck performs the static validation upon the provided txs and converts
1643
+ // preCheck performs the static validation upon the provided tx and converts
1644
1644
// the legacy sidecars if Osaka fork has been activated with a short time window.
1645
1645
//
1646
1646
// This function is pure static and lock free.
1647
- func (p * BlobPool ) preCheck (txs [] * types.Transaction ) ([] * types. Transaction , [] error ) {
1647
+ func (p * BlobPool ) preCheck (tx * types.Transaction ) error {
1648
1648
var (
1649
1649
head = p .head .Load ()
1650
1650
isOsaka = p .chain .Config ().IsOsaka (head .Number , head .Time )
@@ -1653,56 +1653,46 @@ func (p *BlobPool) preCheck(txs []*types.Transaction) ([]*types.Transaction, []e
1653
1653
if isOsaka {
1654
1654
deadline = time .Unix (int64 (* p .chain .Config ().OsakaTime ), 0 ).Add (conversionTimeWindow )
1655
1655
}
1656
- var errs []error
1657
- for _ , tx := range txs {
1658
- // Validate the transaction statically at first to avoid unnecessary
1659
- // conversion. This step doesn't require lock protection.
1660
- if err := p .ValidateTxBasics (tx ); err != nil {
1661
- errs = append (errs , err )
1662
- continue
1663
- }
1664
- // Before the Osaka fork, reject the blob txs with cell proofs
1665
- if ! isOsaka {
1666
- if tx .BlobTxSidecar ().Version == types .BlobSidecarVersion0 {
1667
- errs = append (errs , nil )
1668
- } else {
1669
- errs = append (errs , errors .New ("cell proof is not supported yet" ))
1670
- }
1671
- continue
1672
- }
1673
- // After the Osaka fork, reject the legacy blob txs if the conversion
1674
- // time window is passed.
1675
- if tx .BlobTxSidecar ().Version == types .BlobSidecarVersion1 {
1676
- errs = append (errs , nil )
1677
- continue
1678
- }
1679
- if head .Time > uint64 (deadline .Unix ()) {
1680
- errs = append (errs , errors .New ("legacy blob tx is not supported" ))
1681
- continue
1656
+ // Validate the transaction statically at first to avoid unnecessary
1657
+ // conversion. This step doesn't require lock protection.
1658
+ if err := p .ValidateTxBasics (tx ); err != nil {
1659
+ return err
1660
+ }
1661
+ // Before the Osaka fork, reject the blob txs with cell proofs
1662
+ if ! isOsaka {
1663
+ if tx .BlobTxSidecar ().Version == types .BlobSidecarVersion0 {
1664
+ return nil
1665
+ } else {
1666
+ return errors .New ("cell proof is not supported yet" )
1682
1667
}
1683
- // Convert the legacy sidecar after Osaka fork. This could be a long
1684
- // procedure which takes a few seconds, even minutes if there is a long
1685
- // queue. Fortunately it will only block the routine of the source peer
1686
- // announcing the tx, without affecting other parts.
1687
- errs = append (errs , p .cQueue .convert (tx ))
1688
1668
}
1689
- return txs , errs
1669
+ // After the Osaka fork, reject the legacy blob txs if the conversion
1670
+ // time window is passed.
1671
+ if tx .BlobTxSidecar ().Version == types .BlobSidecarVersion1 {
1672
+ return nil
1673
+ }
1674
+ if head .Time > uint64 (deadline .Unix ()) {
1675
+ return errors .New ("legacy blob tx is not supported" )
1676
+ }
1677
+ // Convert the legacy sidecar after Osaka fork. This could be a long
1678
+ // procedure which takes a few seconds, even minutes if there is a long
1679
+ // queue. Fortunately it will only block the routine of the source peer
1680
+ // announcing the tx, without affecting other parts.
1681
+ return p .cQueue .convert (tx )
1690
1682
}
1691
1683
1692
1684
// Add inserts a set of blob transactions into the pool if they pass validation (both
1693
1685
// consensus validity and pool restrictions).
1694
1686
func (p * BlobPool ) Add (txs []* types.Transaction , sync bool ) []error {
1695
1687
var (
1696
- errs []error
1697
- adds = make ([]* types.Transaction , 0 , len (txs ))
1688
+ errs []error = make ([] error , len ( txs ))
1689
+ adds = make ([]* types.Transaction , 0 , len (txs ))
1698
1690
)
1699
- txs , errs = p .preCheck (txs )
1700
1691
for i , tx := range txs {
1701
- if errs [i ] != nil {
1692
+ if errs [i ] = p . preCheck ( tx ); errs [ i ] != nil {
1702
1693
continue
1703
1694
}
1704
- errs [i ] = p .add (tx )
1705
- if errs [i ] == nil {
1695
+ if errs [i ] = p .add (tx ); errs [i ] == nil {
1706
1696
adds = append (adds , tx .WithoutBlobTxSidecar ())
1707
1697
}
1708
1698
}
0 commit comments