Change transformer.Execute to single header
This commit is contained in:
parent
38c745e8c3
commit
8bebcdc064
@ -74,7 +74,7 @@ func (watcher *Watcher) Execute() error {
|
||||
// TODO delegate log chunks to respective transformers
|
||||
// Need to get the transformer name... :/
|
||||
logChunk := chunkedLogs["transformerName"]
|
||||
err = transformer.Execute(logChunk, missingHeaders)
|
||||
err = transformer.Execute(logChunk, header)
|
||||
}
|
||||
}
|
||||
return err
|
||||
|
@ -34,10 +34,9 @@ func (transformer LogNoteTransformer) NewLogNoteTransformer(db *postgres.DB) sha
|
||||
return transformer
|
||||
}
|
||||
|
||||
func (transformer LogNoteTransformer) Execute(logs []types.Log, missingHeaders []core.Header) error {
|
||||
func (transformer LogNoteTransformer) Execute(logs []types.Log, header core.Header) error {
|
||||
transformerName := transformer.Config.TransformerName
|
||||
|
||||
for _, header := range missingHeaders {
|
||||
// No matching logs, mark the header as checked for this type of logs
|
||||
if len(logs) < 1 {
|
||||
err := transformer.Repository.MarkHeaderChecked(header.Id)
|
||||
@ -45,8 +44,6 @@ func (transformer LogNoteTransformer) Execute(logs []types.Log, missingHeaders [
|
||||
log.Printf("Error marking header as checked in %v: %v", transformerName, err)
|
||||
return err
|
||||
}
|
||||
// Continue with the next header; nothing to persist
|
||||
continue
|
||||
}
|
||||
|
||||
models, err := transformer.Converter.ToModels(logs)
|
||||
@ -60,6 +57,5 @@ func (transformer LogNoteTransformer) Execute(logs []types.Log, missingHeaders [
|
||||
log.Printf("Error persisting %v record: %v", transformerName, err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -34,19 +34,16 @@ func (transformer Transformer) NewTransformer(db *postgres.DB) shared.Transforme
|
||||
return transformer
|
||||
}
|
||||
|
||||
func (transformer Transformer) Execute(logs []types.Log, missingHeaders []core.Header) error {
|
||||
func (transformer Transformer) Execute(logs []types.Log, header core.Header) error {
|
||||
transformerName := transformer.Config.TransformerName
|
||||
config := transformer.Config
|
||||
|
||||
for _, header := range missingHeaders {
|
||||
if len(logs) < 1 {
|
||||
err := transformer.Repository.MarkHeaderChecked(header.Id)
|
||||
if err != nil {
|
||||
log.Printf("Error marking header as checked in %v: %v", transformerName, err)
|
||||
return err
|
||||
}
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
entities, err := transformer.Converter.ToEntities(config.ContractAbi, logs)
|
||||
@ -67,7 +64,5 @@ func (transformer Transformer) Execute(logs []types.Log, missingHeaders []core.H
|
||||
return err
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ import (
|
||||
)
|
||||
|
||||
type Transformer interface {
|
||||
Execute(logs []types.Log, missingHeaders []core.Header) error
|
||||
Execute(logs []types.Log, header core.Header) error
|
||||
}
|
||||
|
||||
type TransformerInitializer func(db *postgres.DB) Transformer
|
||||
|
Loading…
Reference in New Issue
Block a user