Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleCensus ¶
HandleCensus handles the import of census merkle trees published in Ethereum
func HandleVochainOracle ¶
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 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 ¶
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) }