2018-11-23 18:12:24 +00:00
|
|
|
// VulcanizeDB
|
|
|
|
// Copyright © 2018 Vulcanize
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
// 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/>.
|
|
|
|
|
|
|
|
package transformer
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
2018-11-24 04:26:07 +00:00
|
|
|
"strings"
|
2018-11-23 18:12:24 +00:00
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
2018-12-18 19:00:26 +00:00
|
|
|
gethTypes "github.com/ethereum/go-ethereum/core/types"
|
2018-11-23 18:12:24 +00:00
|
|
|
|
|
|
|
"github.com/vulcanize/vulcanizedb/pkg/core"
|
|
|
|
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
|
|
|
"github.com/vulcanize/vulcanizedb/pkg/omni/light/converter"
|
|
|
|
"github.com/vulcanize/vulcanizedb/pkg/omni/light/fetcher"
|
|
|
|
"github.com/vulcanize/vulcanizedb/pkg/omni/light/repository"
|
|
|
|
"github.com/vulcanize/vulcanizedb/pkg/omni/light/retriever"
|
|
|
|
"github.com/vulcanize/vulcanizedb/pkg/omni/shared/contract"
|
|
|
|
"github.com/vulcanize/vulcanizedb/pkg/omni/shared/parser"
|
|
|
|
"github.com/vulcanize/vulcanizedb/pkg/omni/shared/poller"
|
2018-11-24 04:26:07 +00:00
|
|
|
srep "github.com/vulcanize/vulcanizedb/pkg/omni/shared/repository"
|
|
|
|
"github.com/vulcanize/vulcanizedb/pkg/omni/shared/types"
|
2018-11-23 18:12:24 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Requires a light synced vDB (headers) and a running eth node (or infura)
|
2019-02-27 00:29:27 +00:00
|
|
|
type Transformer struct {
|
2018-11-23 18:12:24 +00:00
|
|
|
// Database interfaces
|
2018-11-24 04:26:07 +00:00
|
|
|
srep.EventRepository // Holds transformed watched event log data
|
2018-11-23 18:12:24 +00:00
|
|
|
repository.HeaderRepository // Interface for interaction with header repositories
|
|
|
|
|
|
|
|
// Pre-processing interfaces
|
|
|
|
parser.Parser // Parses events and methods out of contract abi fetched using contract address
|
|
|
|
retriever.BlockRetriever // Retrieves first block for contract and current block height
|
|
|
|
|
|
|
|
// Processing interfaces
|
|
|
|
fetcher.Fetcher // Fetches event logs, using header hashes
|
|
|
|
converter.Converter // Converts watched event logs into custom log
|
2019-01-04 18:15:22 +00:00
|
|
|
poller.Poller // Polls methods using arguments collected from events and persists them using a method datastore
|
2018-11-23 18:12:24 +00:00
|
|
|
|
|
|
|
// Ethereum network name; default "" is mainnet
|
|
|
|
Network string
|
|
|
|
|
|
|
|
// Store contract info as mapping to contract address
|
|
|
|
Contracts map[string]*contract.Contract
|
|
|
|
|
|
|
|
// Targeted subset of events/methods
|
2019-01-04 18:15:22 +00:00
|
|
|
// Stored as maps of contract address to events/method names of interest
|
2018-11-23 18:12:24 +00:00
|
|
|
WatchedEvents map[string][]string // Default/empty event list means all are watched
|
|
|
|
WantedMethods map[string][]string // Default/empty method list means none are polled
|
|
|
|
|
2019-01-04 18:15:22 +00:00
|
|
|
// Starting block number for each contract
|
|
|
|
ContractStart map[string]int64
|
2018-11-23 18:12:24 +00:00
|
|
|
|
2019-01-04 18:15:22 +00:00
|
|
|
// Lists of argument values to filter event or
|
|
|
|
// method data with; if empty no filter is applied
|
2018-12-07 15:38:46 +00:00
|
|
|
EventArgs map[string][]string
|
|
|
|
MethodArgs map[string][]string
|
|
|
|
|
2018-12-14 17:52:02 +00:00
|
|
|
// Whether or not to create a list of emitted address or hashes for the contract in postgres
|
2018-12-07 15:38:46 +00:00
|
|
|
CreateAddrList map[string]bool
|
2018-12-14 17:52:02 +00:00
|
|
|
CreateHashList map[string]bool
|
|
|
|
|
|
|
|
// Method piping on/off for a contract
|
|
|
|
Piping map[string]bool
|
2019-01-04 18:15:22 +00:00
|
|
|
|
|
|
|
// Internally configured transformer variables
|
|
|
|
contractAddresses []string // Holds all contract addresses, for batch fetching of logs
|
|
|
|
sortedEventIds map[string][]string // Map to sort event column ids by contract, for post fetch processing and persisting of logs
|
|
|
|
sortedMethodIds map[string][]string // Map to sort method column ids by contract, for post fetch method polling
|
|
|
|
eventIds []string // Holds event column ids across all contract, for batch fetching of headers
|
|
|
|
eventFilters []common.Hash // Holds topic0 hashes across all contracts, for batch fetching of logs
|
|
|
|
start int64 // Hold the lowest starting block and the highest ending block
|
2018-11-23 18:12:24 +00:00
|
|
|
}
|
|
|
|
|
2018-12-14 17:52:02 +00:00
|
|
|
// Order-of-operations:
|
|
|
|
// 1. Create new transformer
|
|
|
|
// 2. Load contract addresses and their parameters
|
|
|
|
// 3. Init
|
2019-01-04 18:15:22 +00:00
|
|
|
// 4. Execute
|
2018-12-14 17:52:02 +00:00
|
|
|
|
2018-11-23 18:12:24 +00:00
|
|
|
// Transformer takes in config for blockchain, database, and network id
|
2019-02-27 00:29:27 +00:00
|
|
|
func NewTransformer(network string, bc core.BlockChain, db *postgres.DB) *Transformer {
|
2018-11-23 18:12:24 +00:00
|
|
|
|
2019-02-27 00:29:27 +00:00
|
|
|
return &Transformer{
|
2018-11-24 04:26:07 +00:00
|
|
|
Poller: poller.NewPoller(bc, db, types.LightSync),
|
2018-11-23 18:12:24 +00:00
|
|
|
Fetcher: fetcher.NewFetcher(bc),
|
|
|
|
Parser: parser.NewParser(network),
|
|
|
|
HeaderRepository: repository.NewHeaderRepository(db),
|
|
|
|
BlockRetriever: retriever.NewBlockRetriever(db),
|
|
|
|
Converter: converter.NewConverter(&contract.Contract{}),
|
|
|
|
Contracts: map[string]*contract.Contract{},
|
2018-11-24 04:26:07 +00:00
|
|
|
EventRepository: srep.NewEventRepository(db, types.LightSync),
|
2018-11-23 18:12:24 +00:00
|
|
|
WatchedEvents: map[string][]string{},
|
|
|
|
WantedMethods: map[string][]string{},
|
2019-01-04 18:15:22 +00:00
|
|
|
ContractStart: map[string]int64{},
|
2018-12-07 15:38:46 +00:00
|
|
|
EventArgs: map[string][]string{},
|
|
|
|
MethodArgs: map[string][]string{},
|
|
|
|
CreateAddrList: map[string]bool{},
|
2018-12-14 17:52:02 +00:00
|
|
|
CreateHashList: map[string]bool{},
|
|
|
|
Piping: map[string]bool{},
|
2019-01-04 18:15:22 +00:00
|
|
|
Network: network,
|
2018-11-23 18:12:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Use after creating and setting transformer
|
|
|
|
// Loops over all of the addr => filter sets
|
|
|
|
// Uses parser to pull event info from abi
|
|
|
|
// Use this info to generate event filters
|
2019-02-27 00:29:27 +00:00
|
|
|
func (tr *Transformer) Init() error {
|
2019-01-04 18:15:22 +00:00
|
|
|
// Initialize internally configured transformer settings
|
|
|
|
tr.contractAddresses = make([]string, 0) // Holds all contract addresses, for batch fetching of logs
|
|
|
|
tr.sortedEventIds = make(map[string][]string) // Map to sort event column ids by contract, for post fetch processing and persisting of logs
|
|
|
|
tr.sortedMethodIds = make(map[string][]string) // Map to sort method column ids by contract, for post fetch method polling
|
|
|
|
tr.eventIds = make([]string, 0) // Holds event column ids across all contract, for batch fetching of headers
|
|
|
|
tr.eventFilters = make([]common.Hash, 0) // Holds topic0 hashes across all contracts, for batch fetching of logs
|
|
|
|
tr.start = 100000000000 // Hold the lowest starting block and the highest ending block
|
|
|
|
|
2018-11-24 04:26:07 +00:00
|
|
|
// Iterate through all internal contract addresses
|
2018-11-23 18:12:24 +00:00
|
|
|
for contractAddr, subset := range tr.WatchedEvents {
|
|
|
|
// Get Abi
|
|
|
|
err := tr.Parser.Parse(contractAddr)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-11-24 04:26:07 +00:00
|
|
|
// Get first block and most recent block number in the header repo
|
2018-11-23 18:12:24 +00:00
|
|
|
firstBlock, err := tr.BlockRetriever.RetrieveFirstBlock()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
lastBlock, err := tr.BlockRetriever.RetrieveMostRecentBlock()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-11-24 04:26:07 +00:00
|
|
|
// Set to specified range if it falls within the bounds
|
2019-01-04 18:15:22 +00:00
|
|
|
if firstBlock < tr.ContractStart[contractAddr] {
|
|
|
|
firstBlock = tr.ContractStart[contractAddr]
|
2018-11-23 18:12:24 +00:00
|
|
|
}
|
|
|
|
|
2018-11-24 04:26:07 +00:00
|
|
|
// Get contract name if it has one
|
2018-11-23 18:12:24 +00:00
|
|
|
var name = new(string)
|
2019-02-27 00:29:27 +00:00
|
|
|
tr.Poller.FetchContractData(tr.Abi(), contractAddr, "name", nil, name, lastBlock)
|
2018-11-23 18:12:24 +00:00
|
|
|
|
2018-12-07 15:38:46 +00:00
|
|
|
// Remove any potential accidental duplicate inputs in arg filter values
|
|
|
|
eventArgs := map[string]bool{}
|
|
|
|
for _, arg := range tr.EventArgs[contractAddr] {
|
|
|
|
eventArgs[arg] = true
|
2018-11-23 18:12:24 +00:00
|
|
|
}
|
2018-12-07 15:38:46 +00:00
|
|
|
methodArgs := map[string]bool{}
|
|
|
|
for _, arg := range tr.MethodArgs[contractAddr] {
|
|
|
|
methodArgs[arg] = true
|
2018-11-23 18:12:24 +00:00
|
|
|
}
|
|
|
|
|
2018-12-07 15:38:46 +00:00
|
|
|
// Aggregate info into contract object and store for execution
|
2019-01-04 18:15:22 +00:00
|
|
|
con := contract.Contract{
|
2018-11-23 18:12:24 +00:00
|
|
|
Name: *name,
|
|
|
|
Network: tr.Network,
|
|
|
|
Address: contractAddr,
|
2018-12-19 18:42:59 +00:00
|
|
|
Abi: tr.Parser.Abi(),
|
|
|
|
ParsedAbi: tr.Parser.ParsedAbi(),
|
2018-11-23 18:12:24 +00:00
|
|
|
StartingBlock: firstBlock,
|
2019-01-04 18:15:22 +00:00
|
|
|
LastBlock: -1,
|
2018-12-19 18:42:59 +00:00
|
|
|
Events: tr.Parser.GetEvents(subset),
|
|
|
|
Methods: tr.Parser.GetSelectMethods(tr.WantedMethods[contractAddr]),
|
2018-12-07 15:38:46 +00:00
|
|
|
FilterArgs: eventArgs,
|
|
|
|
MethodArgs: methodArgs,
|
|
|
|
CreateAddrList: tr.CreateAddrList[contractAddr],
|
2018-12-14 17:52:02 +00:00
|
|
|
CreateHashList: tr.CreateHashList[contractAddr],
|
|
|
|
Piping: tr.Piping[contractAddr],
|
2018-12-07 15:38:46 +00:00
|
|
|
}.Init()
|
2019-01-04 18:15:22 +00:00
|
|
|
tr.Contracts[contractAddr] = con
|
|
|
|
tr.contractAddresses = append(tr.contractAddresses, con.Address)
|
2018-11-23 18:12:24 +00:00
|
|
|
|
2019-01-04 18:15:22 +00:00
|
|
|
// Create checked_headers columns for each event id and append to list of all event ids
|
|
|
|
tr.sortedEventIds[con.Address] = make([]string, 0, len(con.Events))
|
2018-11-23 18:12:24 +00:00
|
|
|
for _, event := range con.Events {
|
2018-11-24 04:26:07 +00:00
|
|
|
eventId := strings.ToLower(event.Name + "_" + con.Address)
|
2018-12-14 17:52:02 +00:00
|
|
|
err := tr.HeaderRepository.AddCheckColumn(eventId)
|
|
|
|
if err != nil {
|
2018-11-24 04:26:07 +00:00
|
|
|
return err
|
|
|
|
}
|
2018-12-18 19:00:26 +00:00
|
|
|
// Keep track of this event id; sorted and unsorted
|
2019-01-04 18:15:22 +00:00
|
|
|
tr.sortedEventIds[con.Address] = append(tr.sortedEventIds[con.Address], eventId)
|
|
|
|
tr.eventIds = append(tr.eventIds, eventId)
|
2018-12-18 19:00:26 +00:00
|
|
|
// Append this event sig to the filters
|
2019-01-04 18:15:22 +00:00
|
|
|
tr.eventFilters = append(tr.eventFilters, event.Sig())
|
2018-12-18 19:00:26 +00:00
|
|
|
}
|
2018-12-19 18:42:59 +00:00
|
|
|
|
2019-01-04 18:15:22 +00:00
|
|
|
// Create checked_headers columns for each method id and append list of all method ids
|
|
|
|
tr.sortedMethodIds[con.Address] = make([]string, 0, len(con.Methods))
|
2018-12-19 18:42:59 +00:00
|
|
|
for _, m := range con.Methods {
|
|
|
|
methodId := strings.ToLower(m.Name + "_" + con.Address)
|
|
|
|
err := tr.HeaderRepository.AddCheckColumn(methodId)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-01-04 18:15:22 +00:00
|
|
|
tr.sortedMethodIds[con.Address] = append(tr.sortedMethodIds[con.Address], methodId)
|
2018-12-19 18:42:59 +00:00
|
|
|
}
|
|
|
|
|
2019-01-04 18:15:22 +00:00
|
|
|
// Update start to the lowest block
|
|
|
|
if con.StartingBlock < tr.start {
|
|
|
|
tr.start = con.StartingBlock
|
2018-12-18 17:31:21 +00:00
|
|
|
}
|
2018-12-18 19:00:26 +00:00
|
|
|
}
|
|
|
|
|
2019-01-04 18:15:22 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-02-27 00:29:27 +00:00
|
|
|
func (tr *Transformer) Execute() error {
|
2019-01-04 18:15:22 +00:00
|
|
|
if len(tr.Contracts) == 0 {
|
|
|
|
return errors.New("error: transformer has no initialized contracts")
|
|
|
|
}
|
|
|
|
|
|
|
|
// Map to sort batch fetched logs by which contract they belong to, for post fetch processing
|
|
|
|
sortedLogs := make(map[string][]gethTypes.Log)
|
|
|
|
for _, con := range tr.Contracts {
|
|
|
|
sortedLogs[con.Address] = []gethTypes.Log{}
|
|
|
|
}
|
|
|
|
|
2018-12-19 18:42:59 +00:00
|
|
|
// Find unchecked headers for all events across all contracts; these are returned in asc order
|
2019-01-04 18:15:22 +00:00
|
|
|
missingHeaders, err := tr.HeaderRepository.MissingHeadersForAll(tr.start, -1, tr.eventIds)
|
2018-12-18 19:00:26 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-11-24 04:26:07 +00:00
|
|
|
|
2018-12-18 19:00:26 +00:00
|
|
|
// Iterate over headers
|
|
|
|
for _, header := range missingHeaders {
|
|
|
|
// And fetch all event logs across contracts at this header
|
2019-01-04 18:15:22 +00:00
|
|
|
allLogs, err := tr.Fetcher.FetchLogs(tr.contractAddresses, tr.eventFilters, header)
|
2018-12-18 17:31:21 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-12-18 19:00:26 +00:00
|
|
|
|
2019-01-04 18:15:22 +00:00
|
|
|
// If no logs are found mark the header checked for all of these eventIDs
|
|
|
|
// and continue to method polling and onto the next iteration
|
2018-12-18 19:00:26 +00:00
|
|
|
if len(allLogs) < 1 {
|
2019-01-04 18:15:22 +00:00
|
|
|
err = tr.HeaderRepository.MarkHeaderCheckedForAll(header.Id, tr.eventIds)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
err = tr.methodPolling(header, tr.sortedMethodIds)
|
2018-11-23 18:12:24 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-01-04 18:15:22 +00:00
|
|
|
continue
|
2018-12-18 19:00:26 +00:00
|
|
|
}
|
2018-11-23 18:12:24 +00:00
|
|
|
|
2018-12-18 19:00:26 +00:00
|
|
|
// Sort logs by the contract they belong to
|
|
|
|
for _, log := range allLogs {
|
2019-01-04 18:15:22 +00:00
|
|
|
addr := strings.ToLower(log.Address.Hex())
|
|
|
|
sortedLogs[addr] = append(sortedLogs[addr], log)
|
2018-12-18 19:00:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Process logs for each contract
|
|
|
|
for conAddr, logs := range sortedLogs {
|
2019-01-04 18:15:22 +00:00
|
|
|
if logs == nil {
|
|
|
|
continue
|
|
|
|
}
|
2018-12-18 19:00:26 +00:00
|
|
|
// Configure converter with this contract
|
|
|
|
con := tr.Contracts[conAddr]
|
|
|
|
tr.Converter.Update(con)
|
2018-11-23 18:12:24 +00:00
|
|
|
|
2019-01-04 18:15:22 +00:00
|
|
|
// Convert logs into batches of log mappings (eventName => []types.Logs
|
2018-12-18 17:31:21 +00:00
|
|
|
convertedLogs, err := tr.Converter.ConvertBatch(logs, con.Events, header.Id)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-12-18 19:00:26 +00:00
|
|
|
// Cycle through each type of event log and persist them
|
|
|
|
for eventName, logs := range convertedLogs {
|
2018-12-19 18:42:59 +00:00
|
|
|
// If logs for this event are empty, mark them checked at this header and continue
|
2018-11-23 18:12:24 +00:00
|
|
|
if len(logs) < 1 {
|
2018-12-18 19:00:26 +00:00
|
|
|
eventId := strings.ToLower(eventName + "_" + con.Address)
|
2018-12-14 17:52:02 +00:00
|
|
|
err = tr.HeaderRepository.MarkHeaderChecked(header.Id, eventId)
|
2018-11-23 18:12:24 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
continue
|
|
|
|
}
|
2018-11-24 04:26:07 +00:00
|
|
|
// If logs aren't empty, persist them
|
2018-12-19 18:42:59 +00:00
|
|
|
// Header is marked checked in the transactions
|
2018-12-18 19:00:26 +00:00
|
|
|
err = tr.EventRepository.PersistLogs(logs, con.Events[eventName], con.Address, con.Name)
|
2018-11-24 04:26:07 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
2018-11-23 18:12:24 +00:00
|
|
|
}
|
2018-12-14 17:52:02 +00:00
|
|
|
}
|
2018-12-19 18:42:59 +00:00
|
|
|
}
|
2018-12-07 15:38:46 +00:00
|
|
|
|
2018-12-19 18:42:59 +00:00
|
|
|
// Poll contracts at this block height
|
2019-01-04 18:15:22 +00:00
|
|
|
err = tr.methodPolling(header, tr.sortedMethodIds)
|
2018-12-19 18:42:59 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2018-12-14 17:52:02 +00:00
|
|
|
|
2018-12-19 18:42:59 +00:00
|
|
|
return nil
|
|
|
|
}
|
2018-12-18 19:00:26 +00:00
|
|
|
|
2018-12-19 18:42:59 +00:00
|
|
|
// Used to poll contract methods at a given header
|
2019-02-27 00:29:27 +00:00
|
|
|
func (tr *Transformer) methodPolling(header core.Header, sortedMethodIds map[string][]string) error {
|
2018-12-19 18:42:59 +00:00
|
|
|
for _, con := range tr.Contracts {
|
|
|
|
// Skip method polling processes if no methods are specified
|
|
|
|
// Also don't try to poll methods below this contract's specified starting block
|
|
|
|
if len(con.Methods) == 0 || header.BlockNumber < con.StartingBlock {
|
|
|
|
continue
|
|
|
|
}
|
2018-12-14 17:52:02 +00:00
|
|
|
|
2018-12-19 18:42:59 +00:00
|
|
|
// Poll all methods for this contract at this header
|
|
|
|
err := tr.Poller.PollContractAt(*con, header.BlockNumber)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-12-18 17:31:21 +00:00
|
|
|
|
2018-12-19 18:42:59 +00:00
|
|
|
// Mark this header checked for the methods
|
|
|
|
err = tr.HeaderRepository.MarkHeaderCheckedForAll(header.Id, sortedMethodIds[con.Address])
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2018-11-23 18:12:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Used to set which contract addresses and which of their events to watch
|
2019-02-27 00:29:27 +00:00
|
|
|
func (tr *Transformer) SetEvents(contractAddr string, filterSet []string) {
|
2019-01-04 18:15:22 +00:00
|
|
|
tr.WatchedEvents[strings.ToLower(contractAddr)] = filterSet
|
2018-11-23 18:12:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Used to set subset of account addresses to watch events for
|
2019-02-27 00:29:27 +00:00
|
|
|
func (tr *Transformer) SetEventArgs(contractAddr string, filterSet []string) {
|
2019-01-04 18:15:22 +00:00
|
|
|
tr.EventArgs[strings.ToLower(contractAddr)] = filterSet
|
2018-11-23 18:12:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Used to set which contract addresses and which of their methods to call
|
2019-02-27 00:29:27 +00:00
|
|
|
func (tr *Transformer) SetMethods(contractAddr string, filterSet []string) {
|
2019-01-04 18:15:22 +00:00
|
|
|
tr.WantedMethods[strings.ToLower(contractAddr)] = filterSet
|
2018-11-23 18:12:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Used to set subset of account addresses to poll methods on
|
2019-02-27 00:29:27 +00:00
|
|
|
func (tr *Transformer) SetMethodArgs(contractAddr string, filterSet []string) {
|
2019-01-04 18:15:22 +00:00
|
|
|
tr.MethodArgs[strings.ToLower(contractAddr)] = filterSet
|
2018-11-23 18:12:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Used to set the block range to watch for a given address
|
2019-02-27 00:29:27 +00:00
|
|
|
func (tr *Transformer) SetStartingBlock(contractAddr string, start int64) {
|
2019-01-04 18:15:22 +00:00
|
|
|
tr.ContractStart[strings.ToLower(contractAddr)] = start
|
2018-11-23 18:12:24 +00:00
|
|
|
}
|
2018-12-07 15:38:46 +00:00
|
|
|
|
2018-12-14 17:52:02 +00:00
|
|
|
// Used to set whether or not to persist an account address list
|
2019-02-27 00:29:27 +00:00
|
|
|
func (tr *Transformer) SetCreateAddrList(contractAddr string, on bool) {
|
2019-01-04 18:15:22 +00:00
|
|
|
tr.CreateAddrList[strings.ToLower(contractAddr)] = on
|
2018-12-07 15:38:46 +00:00
|
|
|
}
|
2018-12-14 17:52:02 +00:00
|
|
|
|
|
|
|
// Used to set whether or not to persist an hash list
|
2019-02-27 00:29:27 +00:00
|
|
|
func (tr *Transformer) SetCreateHashList(contractAddr string, on bool) {
|
2019-01-04 18:15:22 +00:00
|
|
|
tr.CreateHashList[strings.ToLower(contractAddr)] = on
|
2018-12-14 17:52:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Used to turn method piping on for a contract
|
2019-02-27 00:29:27 +00:00
|
|
|
func (tr *Transformer) SetPiping(contractAddr string, on bool) {
|
2019-01-04 18:15:22 +00:00
|
|
|
tr.Piping[strings.ToLower(contractAddr)] = on
|
2018-12-14 17:52:02 +00:00
|
|
|
}
|