ethevents

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2020 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleCensus

func HandleCensus(ctx context.Context, event *ethtypes.Log, e *EthereumEvents) error

HandleCensus handles the import of census merkle trees published in Ethereum

func HandleVochainOracle

func HandleVochainOracle(ctx context.Context, event *ethtypes.Log, e *EthereumEvents) error

HandleVochainOracle handles the new process creation on ethereum for the Oracle. Once a new process is created, the Oracle sends a transaction on the Vochain to create such process

Types

type CensusManager

type CensusManager interface {
	AddToImportQueue(censusID, censusURI string)
	// TODO(mvdan): is this too wide? maybe just URIprefix?
	Data() data.Storage
}

type EthereumEvents

type EthereumEvents struct {
	// voting process contract address
	ContractAddress common.Address
	// voting process contract abi
	ContractABI abi.ABI
	// voting process contract handle
	ProcessHandle *chain.ProcessHandle
	// dial web3 address
	DialAddr string
	// list of handler functions that will be called on events
	EventHandlers []EventHandler
	// ethereum subscribed events
	Signer *ethereum.SignKeys
	// VochainApp is a pointer to the Vochain BaseApplication allowing to call SendTx method
	VochainApp *vochain.BaseApplication
	// Census is the census manager service
	Census CensusManager
	// EventProcessor handles events pending to process
	EventProcessor *EventProcessor
}

EthereumEvents type is used to monitorize an Ethereum smart contract and call custom EventHandler functions

func NewEthEvents

func NewEthEvents(contractAddressHex string, signer *ethereum.SignKeys, w3Endpoint string, cens *census.Manager, vocapp *vochain.BaseApplication) (*EthereumEvents, error)

NewEthEvents creates a new Ethereum events handler

func (*EthereumEvents) AddEventHandler

func (ev *EthereumEvents) AddEventHandler(h EventHandler)

AddEventHandler adds a new handler even log function

func (*EthereumEvents) SubscribeEthereumEventLogs

func (ev *EthereumEvents) SubscribeEthereumEventLogs(ctx context.Context, fromBlock *int64)

SubscribeEthereumEventLogs enables the subscription of Ethereum events for new blocks. Events are Queued for 60 seconds before processed in order to avoid possible blockchain reversions. If fromBlock nil, subscription will start on current block Blocking function (use go routine).

type EventHandler

type EventHandler func(ctx context.Context, event *ethtypes.Log, ethEvents *EthereumEvents) error

EventHandler function type is executed on each Ethereum event

type EventProcessor

type EventProcessor struct {
	Events                chan ethtypes.Log
	EventProcessThreshold time.Duration
	// contains filtered or unexported fields
}

EventProcessor is in charge of processing Ethereum event logs asynchronously. Uses a Queue mechanism and waits for EventProcessThreshold before processing a queued event. If during this time window the Ethereum block is reversed, the event will be deleted.

type VochainClient

type VochainClient interface {
	// TODO(mvdan): do we want a more generic API?
	BroadcastTxSync(tx ttypes.Tx) (*cttypes.ResultBroadcastTx, error)
}

Jump to

Keyboard shortcuts

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