transformer

package
v0.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2019 License: AGPL-3.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Transformer

type Transformer struct {
	// Database interfaces
	FilterRepository           datastore.FilterRepository       // Log filters repo; accepts filters generated by Contract.GenerateFilters()
	WatchedEventRepository     datastore.WatchedEventRepository // Watched event log views, created by the log filters
	TransformedEventRepository repository.EventRepository       // Holds transformed watched event log data

	// Pre-processing interfaces
	Parser    parser.Parser            // Parses events and methods out of contract abi fetched using contract address
	Retriever retriever.BlockRetriever // Retrieves first block for contract and current block height

	// Processing interfaces
	Converter converter.ConverterInterface // Converts watched event logs into custom log
	Poller    poller.Poller                // Polls methods using contract's token holder addresses and persists them using method datastore

	// Store contract configuration information
	Config config.ContractConfig

	// Store contract info as mapping to contract address
	Contracts map[string]*contract.Contract

	// Latest block in the block repository
	LastBlock int64
}

Transformer is the top level struct for transforming watched contract data Requires a fully synced vDB and a running eth node (or infura)

func NewTransformer

func NewTransformer(con config.ContractConfig, BC core.BlockChain, DB *postgres.DB) *Transformer

NewTransformer takes in contract config, blockchain, and database, and returns a new Transformer

func (*Transformer) Execute

func (tr *Transformer) Execute() error

Execute runs the transformation processes Iterates through stored, initialized contract objects Iterates through contract's event filters, grabbing watched event logs Uses converter to convert logs into custom log type Persists converted logs into custom postgres tables Calls selected methods, using token holder address generated during event log conversion

func (*Transformer) GetConfig

func (tr *Transformer) GetConfig() config.ContractConfig

GetConfig returns the transformers config; satisfies the transformer interface

func (*Transformer) Init

func (tr *Transformer) Init() error

Init initializes the transformer 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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL