forked from cerc-io/ipld-eth-server
fixes for review comments
This commit is contained in:
+2
-2
@@ -22,10 +22,10 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||
)
|
||||
|
||||
type GenericTransformer interface {
|
||||
type ContractTransformer interface {
|
||||
Init() error
|
||||
Execute() error
|
||||
GetConfig() config.ContractConfig
|
||||
}
|
||||
|
||||
type GenericTransformerInitializer func(db *postgres.DB, bc core.BlockChain) GenericTransformer
|
||||
type ContractTransformerInitializer func(db *postgres.DB, bc core.BlockChain) ContractTransformer
|
||||
+12
-12
@@ -14,10 +14,10 @@
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Dynamic watcher is built with a more generic interface
|
||||
// that allows offloading more of the operatinal logic to
|
||||
// Contract watcher is built with a more generic interface
|
||||
// that allows offloading more of the operational logic to
|
||||
// the transformers, allowing them to act more dynamically
|
||||
// Built to work primarily with the omni pkging
|
||||
// Built to work primarily with the contract_watcher packaging
|
||||
package watcher
|
||||
|
||||
import (
|
||||
@@ -30,26 +30,26 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||
)
|
||||
|
||||
type GenericWatcher struct {
|
||||
Transformers []transformer.GenericTransformer
|
||||
type ContractWatcher struct {
|
||||
Transformers []transformer.ContractTransformer
|
||||
DB *postgres.DB
|
||||
BlockChain core.BlockChain
|
||||
}
|
||||
|
||||
func NewGenericWatcher(db *postgres.DB, bc core.BlockChain) GenericWatcher {
|
||||
return GenericWatcher{
|
||||
func NewContractWatcher(db *postgres.DB, bc core.BlockChain) ContractWatcher {
|
||||
return ContractWatcher{
|
||||
DB: db,
|
||||
BlockChain: bc,
|
||||
}
|
||||
}
|
||||
|
||||
func (watcher *GenericWatcher) AddTransformers(inits interface{}) error {
|
||||
initializers, ok := inits.([]transformer.GenericTransformerInitializer)
|
||||
func (watcher *ContractWatcher) AddTransformers(inits interface{}) error {
|
||||
initializers, ok := inits.([]transformer.ContractTransformerInitializer)
|
||||
if !ok {
|
||||
return fmt.Errorf("initializers of type %T, not %T", inits, []transformer.GenericTransformerInitializer{})
|
||||
return fmt.Errorf("initializers of type %T, not %T", inits, []transformer.ContractTransformerInitializer{})
|
||||
}
|
||||
|
||||
watcher.Transformers = make([]transformer.GenericTransformer, 0, len(initializers))
|
||||
watcher.Transformers = make([]transformer.ContractTransformer, 0, len(initializers))
|
||||
for _, initializer := range initializers {
|
||||
t := initializer(watcher.DB, watcher.BlockChain)
|
||||
watcher.Transformers = append(watcher.Transformers, t)
|
||||
@@ -65,7 +65,7 @@ func (watcher *GenericWatcher) AddTransformers(inits interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (watcher *GenericWatcher) Execute(interface{}) error {
|
||||
func (watcher *ContractWatcher) Execute(interface{}) error {
|
||||
for _, transformer := range watcher.Transformers {
|
||||
err := transformer.Execute()
|
||||
if err != nil {
|
||||
Reference in New Issue
Block a user