ba071ef13f
- Migrate various mocks of core namespaces to shared version in `fakes` pkg - Err on the side of making test doubles less sophisticated - Don't pull over mocks of namespaces that are only used in example code
28 lines
659 B
Go
28 lines
659 B
Go
package shared
|
|
|
|
import (
|
|
"github.com/vulcanize/vulcanizedb/pkg/core"
|
|
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
|
)
|
|
|
|
type Watcher struct {
|
|
Transformers []Transformer
|
|
DB postgres.DB
|
|
Blockchain core.BlockChain
|
|
}
|
|
|
|
func (watcher *Watcher) AddTransformers(us []TransformerInitializer) {
|
|
for _, transformerInitializer := range us {
|
|
transformer := transformerInitializer(&watcher.DB, watcher.Blockchain)
|
|
watcher.Transformers = append(watcher.Transformers, transformer)
|
|
}
|
|
}
|
|
|
|
func (watcher *Watcher) Execute() error {
|
|
var err error
|
|
for _, transformer := range watcher.Transformers {
|
|
err = transformer.Execute()
|
|
}
|
|
return err
|
|
}
|