forked from cerc-io/ipld-eth-server
11dd641a84
- If we recognize a storage diff as coming from a watched contract but don't recognize the key, queue it for retrying later (after we've seen an event that might help us recognize the key) - Remove unused errs and args - Panic on unrecognized types (should not happen)
27 lines
717 B
Go
27 lines
717 B
Go
package shared
|
|
|
|
import (
|
|
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/shared"
|
|
)
|
|
|
|
type IStorageQueue interface {
|
|
Add(row shared.StorageDiffRow) error
|
|
}
|
|
|
|
type StorageQueue struct {
|
|
db *postgres.DB
|
|
}
|
|
|
|
func NewStorageQueue(db *postgres.DB) StorageQueue {
|
|
return StorageQueue{db: db}
|
|
}
|
|
|
|
func (queue StorageQueue) Add(row shared.StorageDiffRow) error {
|
|
_, err := queue.db.Exec(`INSERT INTO public.queued_storage (contract,
|
|
block_hash, block_height, storage_key, storage_value) VALUES
|
|
($1, $2, $3, $4, $5)`, row.Contract.Bytes(), row.BlockHash.Bytes(),
|
|
row.BlockHeight, row.StorageKey.Bytes(), row.StorageValue.Bytes())
|
|
return err
|
|
}
|