Delegate log chunks to respective transformers

This commit is contained in:
Edvard 2018-12-04 17:40:39 +01:00
parent 8bebcdc064
commit 9789648cc2
5 changed files with 10 additions and 4 deletions

View File

@ -71,9 +71,7 @@ func (watcher *Watcher) Execute() error {
chunkedLogs := watcher.Chunker.ChunkLogs(logs)
for _, transformer := range watcher.Transformers {
// TODO delegate log chunks to respective transformers
// Need to get the transformer name... :/
logChunk := chunkedLogs["transformerName"]
logChunk := chunkedLogs[transformer.Name()]
err = transformer.Execute(logChunk, header)
}
}

View File

@ -59,3 +59,7 @@ func (transformer LogNoteTransformer) Execute(logs []types.Log, header core.Head
}
return nil
}
func (transformer LogNoteTransformer) Name() string {
return transformer.Config.TransformerName
}

View File

@ -66,3 +66,7 @@ func (transformer Transformer) Execute(logs []types.Log, header core.Header) err
return nil
}
func (transformer Transformer) Name() string {
return transformer.Config.TransformerName
}

View File

@ -26,7 +26,6 @@ func MarkHeaderCheckedInTransaction(headerID int64, tx *sql.Tx, checkedHeadersCo
}
// Treats a header as missing if it's not in the headers table, or not checked for some log type
// TODO Revisit definition of "checked header
func MissingHeaders(startingBlockNumber, endingBlockNumber int64, db *postgres.DB, notCheckedSQL string) ([]core.Header, error) {
var result []core.Header
var query string

View File

@ -24,6 +24,7 @@ import (
type Transformer interface {
Execute(logs []types.Log, header core.Header) error
Name() string
}
type TransformerInitializer func(db *postgres.DB) Transformer