forked from cerc-io/ipld-eth-server
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")
|
log.Error("header cid retrieval error")
|
||||||
return nil, nil, err
|
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
|
var allTxCIDs [][]models.TxModel
|
||||||
txCIDs, err := ecr.RetrieveTxCIDsByBlockNumber(tx, blockNumber)
|
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")
|
log.Debug("fetching header iplds")
|
||||||
headerIPLDs := make([]models.IPLDModel, len(cids))
|
headerIPLDs := make([]models.IPLDModel, len(cids))
|
||||||
|
|
||||||
|
if len(cids) < 1 {
|
||||||
|
return headerIPLDs, nil
|
||||||
|
}
|
||||||
|
|
||||||
blockNumbers := make([]uint64, len(cids))
|
blockNumbers := make([]uint64, len(cids))
|
||||||
mhKeys := make([]string, len(cids))
|
mhKeys := make([]string, len(cids))
|
||||||
for i, c := range cids {
|
for i, c := range cids {
|
||||||
|
@ -36,6 +36,7 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/statediff/indexer/models"
|
"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/eth"
|
||||||
|
"github.com/vulcanize/ipld-eth-server/v3/pkg/shared"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -1288,6 +1289,16 @@ func (r *Resolver) AllEthHeaderCids(ctx context.Context, args struct {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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)
|
headerIPLDs, err := r.backend.Fetcher.FetchHeaders(tx, headerCIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1357,6 +1368,16 @@ func (r *Resolver) EthTransactionCidByTxHash(ctx context.Context, args struct {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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})
|
txIPLDs, err := r.backend.Fetcher.FetchTrxs(tx, []models.TxModel{txCID})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -29,8 +29,6 @@ const schema string = `
|
|||||||
scalar BigInt
|
scalar BigInt
|
||||||
# Long is a 64 bit unsigned integer.
|
# Long is a 64 bit unsigned integer.
|
||||||
scalar Long
|
scalar Long
|
||||||
# BigFloat is a floating point number.
|
|
||||||
scalar BigFloat
|
|
||||||
|
|
||||||
schema {
|
schema {
|
||||||
query: Query
|
query: Query
|
||||||
@ -313,10 +311,7 @@ const schema string = `
|
|||||||
parentHash: String!
|
parentHash: String!
|
||||||
timestamp: BigInt!
|
timestamp: BigInt!
|
||||||
stateRoot: String!
|
stateRoot: String!
|
||||||
|
|
||||||
# TODO: Use BigFloat
|
|
||||||
td: BigInt!
|
td: BigInt!
|
||||||
|
|
||||||
txRoot: String!
|
txRoot: String!
|
||||||
receiptRoot: String!
|
receiptRoot: String!
|
||||||
uncleRoot: String!
|
uncleRoot: String!
|
||||||
|
Loading…
Reference in New Issue
Block a user