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{}
|
||||
|
||||
// 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 {
|
||||
ctx context.Context
|
||||
chainConfig *params.ChainConfig
|
||||
@ -51,11 +51,25 @@ type StateDiffIndexer struct {
|
||||
}
|
||||
|
||||
// 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{
|
||||
ctx: ctx,
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -34,13 +34,15 @@ import (
|
||||
|
||||
// Writer handles processing and writing of indexed IPLD objects to Postgres
|
||||
type Writer struct {
|
||||
db Database
|
||||
db Database
|
||||
isDiff bool
|
||||
}
|
||||
|
||||
// NewWriter creates a new pointer to a Writer
|
||||
func NewWriter(db Database) *Writer {
|
||||
// NewWriter creates a new pointer to a Writer. `diff` indicates whether this is part of an
|
||||
// incremental diff (as opposed to a snapshot).
|
||||
func NewWriter(db Database, diff bool) *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.StateKey,
|
||||
stateNode.CID,
|
||||
true,
|
||||
w.isDiff,
|
||||
bal,
|
||||
stateNode.Nonce,
|
||||
stateNode.CodeHash,
|
||||
|
Loading…
Reference in New Issue
Block a user