Set state node diff
field to false for snapshots
This commit is contained in:
parent
b8fec4b571
commit
b50e636204
@ -43,7 +43,7 @@ import (
|
|||||||
|
|
||||||
var _ interfaces.StateDiffIndexer = &StateDiffIndexer{}
|
var _ interfaces.StateDiffIndexer = &StateDiffIndexer{}
|
||||||
|
|
||||||
// StateDiffIndexer satisfies the indexer.StateDiffIndexer interface for ethereum statediff objects on top of an SQL sql
|
// StateDiffIndexer satisfies the indexer.StateDiffIndexer interface for ethereum statediff objects on top of an SQL DB.
|
||||||
type StateDiffIndexer struct {
|
type StateDiffIndexer struct {
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
chainConfig *params.ChainConfig
|
chainConfig *params.ChainConfig
|
||||||
@ -51,11 +51,25 @@ type StateDiffIndexer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewStateDiffIndexer creates a sql implementation of interfaces.StateDiffIndexer
|
// NewStateDiffIndexer creates a sql implementation of interfaces.StateDiffIndexer
|
||||||
func NewStateDiffIndexer(ctx context.Context, chainConfig *params.ChainConfig, db Database) (*StateDiffIndexer, error) {
|
func NewStateDiffIndexer(
|
||||||
|
ctx context.Context, chainConfig *params.ChainConfig, db Database,
|
||||||
|
) (*StateDiffIndexer, error) {
|
||||||
return &StateDiffIndexer{
|
return &StateDiffIndexer{
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
chainConfig: chainConfig,
|
chainConfig: chainConfig,
|
||||||
dbWriter: NewWriter(db),
|
dbWriter: NewWriter(db, true),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewStateDiffIndexer creates a sql implementation of interfaces.StateDiffIndexer for writing full
|
||||||
|
// snapshots (meaning inserted nodes have the `diff` field set to false).
|
||||||
|
func NewSnapshotIndexer(
|
||||||
|
ctx context.Context, chainConfig *params.ChainConfig, db Database,
|
||||||
|
) (*StateDiffIndexer, error) {
|
||||||
|
return &StateDiffIndexer{
|
||||||
|
ctx: ctx,
|
||||||
|
chainConfig: chainConfig,
|
||||||
|
dbWriter: NewWriter(db, false),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,12 +35,14 @@ import (
|
|||||||
// Writer handles processing and writing of indexed IPLD objects to Postgres
|
// Writer handles processing and writing of indexed IPLD objects to Postgres
|
||||||
type Writer struct {
|
type Writer struct {
|
||||||
db Database
|
db Database
|
||||||
|
isDiff bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewWriter creates a new pointer to a Writer
|
// NewWriter creates a new pointer to a Writer. `diff` indicates whether this is part of an
|
||||||
func NewWriter(db Database) *Writer {
|
// incremental diff (as opposed to a snapshot).
|
||||||
|
func NewWriter(db Database, diff bool) *Writer {
|
||||||
return &Writer{
|
return &Writer{
|
||||||
db: db,
|
db: db, isDiff: diff,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,7 +320,7 @@ func (w *Writer) upsertStateCID(tx Tx, stateNode models.StateNodeModel) error {
|
|||||||
stateNode.HeaderID,
|
stateNode.HeaderID,
|
||||||
stateNode.StateKey,
|
stateNode.StateKey,
|
||||||
stateNode.CID,
|
stateNode.CID,
|
||||||
true,
|
w.isDiff,
|
||||||
bal,
|
bal,
|
||||||
stateNode.Nonce,
|
stateNode.Nonce,
|
||||||
stateNode.CodeHash,
|
stateNode.CodeHash,
|
||||||
|
Loading…
Reference in New Issue
Block a user