ipld-eth-server/libraries/shared/HandlerREADME.md
Matt Krump 06f78e0083 Handle events
- Adds interfaces for developers to build handlers that update data in
response to log events
- Resolves #29
2018-03-05 10:01:50 -06:00

1012 B

Handlers

Description

Handlers must be defined in order to define what events should trigger data updates and how those are performed.

Interface

Initializer

Accepts DB and Blockchain from Vulcanize and returns a new handler. E.g. for a new object "Cup": func NewCupHandler(db *postgres.DB, blockchain core.ContractDataFetcher) handlers.Handler

Execute

Triggers operations to take in response to a given log event. Can persist data from logs, fetch and persist arbitrary data from outside services (e.g. contract state), or take any number of other actions. E.g.: func (cupHandler *CupHandler) Execute() error

Additional Requirements

Handlers must define log filters and create them so that relevant watched events can be identified and retrieved. E.g.:

	{
		Name:      "CupsBite",
		FromBlock: 0,
		ToBlock:   -1,
		Address:   "0x448a5065aebb8e423f0896e6c5d525c040f59af3",
		Topics:    core.Topics{"0x40cc885400000000000000000000000000000000000000000000000000000000"},
	},