Add WriteStateSnapshot #15
@ -85,7 +85,6 @@ func (tx *BatchTx) BlockNumber() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (tx *BatchTx) RollbackOnFailure(err error) {
|
func (tx *BatchTx) RollbackOnFailure(err error) {
|
||||||
|
|
||||||
if p := recover(); p != nil {
|
if p := recover(); p != nil {
|
||||||
defer tx.close()
|
defer tx.close()
|
||||||
log.Info("panic detected before tx submission, rolling back the tx", "panic", p)
|
log.Info("panic detected before tx submission, rolling back the tx", "panic", p)
|
||||||
|
@ -54,8 +54,11 @@ type StateDiffIndexer interface {
|
|||||||
|
|
||||||
// Batch required for indexing data atomically
|
// Batch required for indexing data atomically
|
||||||
type Batch interface {
|
type Batch interface {
|
||||||
|
// Submit commits the batch transaction
|
||||||
Submit() error
|
Submit() error
|
||||||
|
// BlockNumber is the block number of the header this batch contains
|
||||||
BlockNumber() string
|
BlockNumber() string
|
||||||
|
// RollbackOnFailure rolls back the batch transaction if the error is not nil
|
||||||
RollbackOnFailure(error)
|
RollbackOnFailure(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -823,6 +823,7 @@ func (sds *Service) writeStateDiff(block *types.Block, parentRoot common.Hash, p
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
defer tx.RollbackOnFailure(err)
|
||||||
|
|
||||||
// TODO: review/remove the need to sync here
|
// TODO: review/remove the need to sync here
|
||||||
var nodeMtx, ipldMtx sync.Mutex
|
var nodeMtx, ipldMtx sync.Mutex
|
||||||
|
Loading…
Reference in New Issue
Block a user