commit
2a11d8fb8e
@ -24,7 +24,7 @@ const (
|
|||||||
VersionMajor = 1 // Major version component of the current release
|
VersionMajor = 1 // Major version component of the current release
|
||||||
VersionMinor = 10 // Minor version component of the current release
|
VersionMinor = 10 // Minor version component of the current release
|
||||||
VersionPatch = 2 // Patch 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.
|
// Version holds the textual version string.
|
||||||
|
@ -73,8 +73,7 @@ type BlockTx struct {
|
|||||||
dbtx *sqlx.Tx
|
dbtx *sqlx.Tx
|
||||||
BlockNumber uint64
|
BlockNumber uint64
|
||||||
headerID int64
|
headerID int64
|
||||||
err error
|
Close func(err error) error
|
||||||
Close func() error
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reporting function to run as goroutine
|
// Reporting function to run as goroutine
|
||||||
@ -128,11 +127,12 @@ func (sdi *StateDiffIndexer) PushBlock(block *types.Block, receipts types.Receip
|
|||||||
blocktx := BlockTx{
|
blocktx := BlockTx{
|
||||||
dbtx: tx,
|
dbtx: tx,
|
||||||
// handle transaction commit or rollback for any return case
|
// handle transaction commit or rollback for any return case
|
||||||
Close: func() error {
|
Close: func(err error) error {
|
||||||
var err error
|
|
||||||
if p := recover(); p != nil {
|
if p := recover(); p != nil {
|
||||||
shared.Rollback(tx)
|
shared.Rollback(tx)
|
||||||
panic(p)
|
panic(p)
|
||||||
|
} else if err != nil {
|
||||||
|
shared.Rollback(tx)
|
||||||
} else {
|
} else {
|
||||||
tDiff := time.Since(t)
|
tDiff := time.Since(t)
|
||||||
indexerMetrics.tStateStoreCodeProcessing.Update(tDiff)
|
indexerMetrics.tStateStoreCodeProcessing.Update(tDiff)
|
||||||
|
@ -117,7 +117,7 @@ func setup(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer tx.Close()
|
defer tx.Close(err)
|
||||||
for _, node := range mocks.StateDiffs {
|
for _, node := range mocks.StateDiffs {
|
||||||
err = ind.PushStateNode(tx, node)
|
err = ind.PushStateNode(tx, node)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -23,14 +23,13 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/eth/ethconfig"
|
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core"
|
"github.com/ethereum/go-ethereum/core"
|
||||||
"github.com/ethereum/go-ethereum/core/state"
|
"github.com/ethereum/go-ethereum/core/state"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/eth"
|
"github.com/ethereum/go-ethereum/eth"
|
||||||
|
"github.com/ethereum/go-ethereum/eth/ethconfig"
|
||||||
"github.com/ethereum/go-ethereum/event"
|
"github.com/ethereum/go-ethereum/event"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/metrics"
|
"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())
|
// log.Info("Writing state diff", "block height", block.Number().Uint64())
|
||||||
var totalDifficulty *big.Int
|
var totalDifficulty *big.Int
|
||||||
var receipts types.Receipts
|
var receipts types.Receipts
|
||||||
|
var err error
|
||||||
|
var tx *ind.BlockTx
|
||||||
if params.IncludeTD {
|
if params.IncludeTD {
|
||||||
totalDifficulty = sds.BlockChain.GetTdByHash(block.Hash())
|
totalDifficulty = sds.BlockChain.GetTdByHash(block.Hash())
|
||||||
}
|
}
|
||||||
if params.IncludeReceipts {
|
if params.IncludeReceipts {
|
||||||
receipts = sds.BlockChain.GetReceiptsByHash(block.Hash())
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// defer handling of commit/rollback for any return case
|
|
||||||
defer tx.Close()
|
|
||||||
output := func(node StateNode) error {
|
output := func(node StateNode) error {
|
||||||
return sds.indexer.PushStateNode(tx, node)
|
return sds.indexer.PushStateNode(tx, node)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user