ipld-eth-server/libraries/shared/watcher.go
Rob Mulholand ba071ef13f Consolidate test doubles
- 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
2018-11-03 13:49:23 -05:00

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
}