Merge pull request #63 from vulcanize/v1.10.2-statediff-0.0.18

hot fix
This commit is contained in:
Ian Norden 2021-04-15 10:57:15 -05:00 committed by GitHub
commit 2a11d8fb8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 11 deletions

View File

@ -24,7 +24,7 @@ const (
VersionMajor = 1 // Major version component of the current release
VersionMinor = 10 // Minor version component of the current release
VersionPatch = 2 // Patch version component of the current release
VersionMeta = "statediff-0.0.17" // Version metadata to append to the version string
VersionMeta = "statediff-0.0.18" // Version metadata to append to the version string
)
// Version holds the textual version string.

View File

@ -73,8 +73,7 @@ type BlockTx struct {
dbtx *sqlx.Tx
BlockNumber uint64
headerID int64
err error
Close func() error
Close func(err error) error
}
// Reporting function to run as goroutine
@ -128,11 +127,12 @@ func (sdi *StateDiffIndexer) PushBlock(block *types.Block, receipts types.Receip
blocktx := BlockTx{
dbtx: tx,
// handle transaction commit or rollback for any return case
Close: func() error {
var err error
Close: func(err error) error {
if p := recover(); p != nil {
shared.Rollback(tx)
panic(p)
} else if err != nil {
shared.Rollback(tx)
} else {
tDiff := time.Since(t)
indexerMetrics.tStateStoreCodeProcessing.Update(tDiff)

View File

@ -117,7 +117,7 @@ func setup(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer tx.Close()
defer tx.Close(err)
for _, node := range mocks.StateDiffs {
err = ind.PushStateNode(tx, node)
if err != nil {

View File

@ -23,14 +23,13 @@ import (
"sync"
"sync/atomic"
"github.com/ethereum/go-ethereum/eth/ethconfig"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/eth/ethconfig"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
@ -626,18 +625,20 @@ func (sds *Service) writeStateDiff(block *types.Block, parentRoot common.Hash, p
// log.Info("Writing state diff", "block height", block.Number().Uint64())
var totalDifficulty *big.Int
var receipts types.Receipts
var err error
var tx *ind.BlockTx
if params.IncludeTD {
totalDifficulty = sds.BlockChain.GetTdByHash(block.Hash())
}
if params.IncludeReceipts {
receipts = sds.BlockChain.GetReceiptsByHash(block.Hash())
}
tx, err := sds.indexer.PushBlock(block, receipts, totalDifficulty)
tx, err = sds.indexer.PushBlock(block, receipts, totalDifficulty)
// defer handling of commit/rollback for any return case
defer tx.Close(err)
if err != nil {
return err
}
// defer handling of commit/rollback for any return case
defer tx.Close()
output := func(node StateNode) error {
return sds.indexer.PushStateNode(tx, node)
}