Skip to content

Commit

Permalink
Merge pull request #63 from vulcanize/v1.10.2-statediff-0.0.18
Browse files Browse the repository at this point in the history
hot fix
  • Loading branch information
i-norden authored Apr 15, 2021
2 parents e842aad + 7b12783 commit 2a11d8f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion params/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions statediff/indexer/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion statediff/indexer/indexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 6 additions & 5 deletions statediff/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 2a11d8f

Please sign in to comment.