Return empty headerCIDs and commit db tx
This commit is contained in:
parent
9550d60467
commit
217cfc63ec
@ -644,9 +644,6 @@ func (ecr *CIDRetriever) RetrieveHeaderAndTxCIDsByBlockNumber(blockNumber int64)
|
||||
log.Error("header cid retrieval error")
|
||||
return nil, nil, err
|
||||
}
|
||||
if len(headerCIDs) < 1 {
|
||||
return nil, nil, fmt.Errorf("header cid retrieval error, no header CIDs found at block %d", blockNumber)
|
||||
}
|
||||
|
||||
var allTxCIDs [][]models.TxModel
|
||||
txCIDs, err := ecr.RetrieveTxCIDsByBlockNumber(tx, blockNumber)
|
||||
|
@ -119,6 +119,10 @@ func (f *IPLDFetcher) FetchHeaders(tx *sqlx.Tx, cids []models.HeaderModel) ([]mo
|
||||
log.Debug("fetching header iplds")
|
||||
headerIPLDs := make([]models.IPLDModel, len(cids))
|
||||
|
||||
if len(cids) < 1 {
|
||||
return headerIPLDs, nil
|
||||
}
|
||||
|
||||
blockNumbers := make([]uint64, len(cids))
|
||||
mhKeys := make([]string, len(cids))
|
||||
for i, c := range cids {
|
||||
|
@ -36,6 +36,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/statediff/indexer/models"
|
||||
|
||||
"github.com/vulcanize/ipld-eth-server/v3/pkg/eth"
|
||||
"github.com/vulcanize/ipld-eth-server/v3/pkg/shared"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -1288,6 +1289,16 @@ func (r *Resolver) AllEthHeaderCids(ctx context.Context, args struct {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer func() {
|
||||
if p := recover(); p != nil {
|
||||
shared.Rollback(tx)
|
||||
panic(p)
|
||||
} else if err != nil {
|
||||
shared.Rollback(tx)
|
||||
} else {
|
||||
err = tx.Commit()
|
||||
}
|
||||
}()
|
||||
|
||||
headerIPLDs, err := r.backend.Fetcher.FetchHeaders(tx, headerCIDs)
|
||||
if err != nil {
|
||||
@ -1357,6 +1368,16 @@ func (r *Resolver) EthTransactionCidByTxHash(ctx context.Context, args struct {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer func() {
|
||||
if p := recover(); p != nil {
|
||||
shared.Rollback(tx)
|
||||
panic(p)
|
||||
} else if err != nil {
|
||||
shared.Rollback(tx)
|
||||
} else {
|
||||
err = tx.Commit()
|
||||
}
|
||||
}()
|
||||
|
||||
txIPLDs, err := r.backend.Fetcher.FetchTrxs(tx, []models.TxModel{txCID})
|
||||
if err != nil {
|
||||
|
@ -29,8 +29,6 @@ const schema string = `
|
||||
scalar BigInt
|
||||
# Long is a 64 bit unsigned integer.
|
||||
scalar Long
|
||||
# BigFloat is a floating point number.
|
||||
scalar BigFloat
|
||||
|
||||
schema {
|
||||
query: Query
|
||||
@ -313,10 +311,7 @@ const schema string = `
|
||||
parentHash: String!
|
||||
timestamp: BigInt!
|
||||
stateRoot: String!
|
||||
|
||||
# TODO: Use BigFloat
|
||||
td: BigInt!
|
||||
|
||||
txRoot: String!
|
||||
receiptRoot: String!
|
||||
uncleRoot: String!
|
||||
|
Loading…
Reference in New Issue
Block a user