Documentation ¶
Overview ¶
Package model contains the general data models and interfaces for the crawler.
Package model contains the general data models and interfaces.
Package model contains the general data models and interfaces.
Index ¶
- func AbiJSON(contractName string) (abi.ABI, error)
- func ReturnEventFromABI(_abi abi.ABI, eventType string) (abi.Event, error)
- type ContractFilterers
- type ContractWatchers
- type Event
- func (e *Event) BlockHash() common.Hash
- func (e *Event) BlockNumber() uint64
- func (e *Event) ContractAddress() common.Address
- func (e *Event) ContractName() string
- func (e *Event) EventPayload() map[string]interface{}
- func (e *Event) EventType() string
- func (e *Event) Hash() string
- func (e *Event) LogData() []byte
- func (e *Event) LogIndex() uint
- func (e *Event) LogPayload() *types.Log
- func (e *Event) LogPayloadToString() string
- func (e *Event) LogRemoved() bool
- func (e *Event) LogTopics() []common.Hash
- func (e *Event) RetrievalMethod() RetrievalMethod
- func (e *Event) SetTimestamp(ts int64)
- func (e *Event) Timestamp() int64
- func (e *Event) TxHash() common.Hash
- func (e *Event) TxIndex() uint
- type EventDataPersister
- type EventPayload
- type EventPayloadValue
- func (v *EventPayloadValue) Address() (common.Address, bool)
- func (v *EventPayloadValue) BigInt() (*big.Int, bool)
- func (v *EventPayloadValue) Bytes32() ([32]byte, bool)
- func (v *EventPayloadValue) Int64() (int64, bool)
- func (v *EventPayloadValue) Kind() reflect.Kind
- func (v *EventPayloadValue) Log() (*types.Log, bool)
- func (v *EventPayloadValue) String() (string, bool)
- func (v *EventPayloadValue) Val() interface{}
- type ListenerMetaDataPersister
- type RetrievalMethod
- type RetrieveEventsCriteria
- type RetrieverMetaDataPersister
- type VersionDataPersister
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ContractFilterers ¶
type ContractFilterers interface { ContractName() string ContractAddress() common.Address EventTypes() []string UpdateStartBlock(eventType string, startBlock uint64) LastEvents() []*Event StartFilterers(client bind.ContractBackend, pastEvents []*Event, nonSubOnly bool) ([]*Event, error) }
ContractFilterers defines an interface that starts up a particular set of filterers
type ContractWatchers ¶
type ContractWatchers interface { ContractName() string ContractAddress() common.Address StartWatchers(client bind.ContractBackend, eventRecvChan chan *Event, errs chan error) ([]utils.WatcherSubscription, error) StopWatchers(unsub bool) error }
ContractWatchers defines an interface that starts up a particular set of listeners watcher loops.
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
Event represents a single smart contract event log item. Represents any event type from the sol/abi generated code and creates a single type to handle in the watcher/filterer.
func NewEvent ¶
func NewEvent(eventType string, contractName string, contractAddress common.Address, timestamp int64, retrievalMethod RetrievalMethod, eventPayload map[string]interface{}, logPayload *types.Log) (*Event, error)
NewEvent is a convenience function to create a new Event
func NewEventFromContractEvent ¶
func NewEventFromContractEvent(eventType string, contractName string, contractAddress common.Address, eventData interface{}, timestamp int64, retrievalMethod RetrievalMethod) (*Event, error)
NewEventFromContractEvent creates a new event after converting eventData to interface{}
func (*Event) BlockNumber ¶
BlockNumber is the block number for this event
func (*Event) ContractAddress ¶
ContractAddress returns the contractAddress for the Event
func (*Event) ContractName ¶
ContractName returns the contract name
func (*Event) EventPayload ¶
EventPayload returns the event payload for the Event
func (*Event) LogPayload ¶
LogPayload returns the log payload from the block
func (*Event) LogPayloadToString ¶
LogPayloadToString is a string representation of some fields of log
func (*Event) LogRemoved ¶
LogRemoved is true if log was reverted due to chain reorganization.
func (*Event) RetrievalMethod ¶
func (e *Event) RetrievalMethod() RetrievalMethod
RetrievalMethod returns the method that was used to retrieve this event
func (*Event) SetTimestamp ¶
SetTimestamp returns the timestamp for the Event
type EventDataPersister ¶
type EventDataPersister interface { // SaveEvents stores a list of Event(s) SaveEvents(events []*Event) []error // RetrieveEvents retrieves the Events from the persistence layer based // on date in which it was received RetrieveEvents(criteria *RetrieveEventsCriteria) ([]*Event, error) }
EventDataPersister handles storing the received Event data.
type EventPayload ¶
type EventPayload struct {
// contains filtered or unexported fields
}
EventPayload represents the data from a contract event
func NewEventPayload ¶
func NewEventPayload(eventData interface{}) *EventPayload
NewEventPayload creates a new event payload
func (*EventPayload) Keys ¶
func (p *EventPayload) Keys() []string
Keys retrieves all the available key names in the event payload
func (*EventPayload) ToString ¶
func (p *EventPayload) ToString() string
ToString returns a string representation for the payload
func (*EventPayload) Value ¶
func (p *EventPayload) Value(key string) (*EventPayloadValue, bool)
Value returns the EventPayloadValue of the given key
type EventPayloadValue ¶
type EventPayloadValue struct {
// contains filtered or unexported fields
}
EventPayloadValue represents a single value for a key in the payload
func (*EventPayloadValue) Address ¶
func (v *EventPayloadValue) Address() (common.Address, bool)
Address returns the value as common.Address Returns bool as false if unable to assert value as type common.Address
func (*EventPayloadValue) BigInt ¶
func (v *EventPayloadValue) BigInt() (*big.Int, bool)
BigInt returns the value as a big.Int Returns bool as false if unable to assert value as type big.Int
func (*EventPayloadValue) Bytes32 ¶
func (v *EventPayloadValue) Bytes32() ([32]byte, bool)
Bytes32 returns the value as a bytes32 object Returns bool as false if unable to assert value
func (*EventPayloadValue) Int64 ¶
func (v *EventPayloadValue) Int64() (int64, bool)
Int64 returns the value as a int64. Returns bool as false if unable to assert value as type int64
func (*EventPayloadValue) Kind ¶
func (v *EventPayloadValue) Kind() reflect.Kind
Kind returns the value's basic type as described with reflect.Kind
func (*EventPayloadValue) Log ¶
func (v *EventPayloadValue) Log() (*types.Log, bool)
Log returns the value as types.Log Returns bool as false if unable to assert value as type types.Log
func (*EventPayloadValue) String ¶
func (v *EventPayloadValue) String() (string, bool)
String returns the value as a string Returns bool as false if unable to assert value as type string
func (*EventPayloadValue) Val ¶
func (v *EventPayloadValue) Val() interface{}
Val returns the value as an unknown type interface{}
type ListenerMetaDataPersister ¶
type ListenerMetaDataPersister interface { // LastBlockNumber returns the last block number seen by the listener for // an event type and contract address LastBlockNumber(eventType string, contractAddress common.Address) uint64 // LastBlockHash returns the last block hash seen by the listener for an // event type and contract address LastBlockHash(eventType string, contractAddress common.Address) common.Hash // UpdateLastBlockData should update the last block data from the Event(s) UpdateLastBlockData(events []*Event) error }
ListenerMetaDataPersister handles storing any metadata related to running the listener.
type RetrievalMethod ¶
type RetrievalMethod int
RetrievalMethod is the enum for the type of retrieval method
const ( // Filterer is the enum value for a retrieval method of type "filterer" Filterer RetrievalMethod = iota // Watcher is the enum value for a retrieval method of type "watcher" Watcher )
type RetrieveEventsCriteria ¶
type RetrieveEventsCriteria struct { Hash string `db:"hash"` ContractAddress string `db:"contract_address"` Offset int `db:"offset"` Count int `db:"count"` ExcludeHashes []string `db:"exclude_hashes"` // Reverse reverses by id in DB Reverse bool `db:"reverse"` FromTs int64 `db:"fromts"` BeforeTs int64 `db:"beforets"` EventType string `db:"eventtype"` }
RetrieveEventsCriteria contains the retrieval criteria for a RetrieveEvents query.
type RetrieverMetaDataPersister ¶
type RetrieverMetaDataPersister interface { // LastBlockNumber returns the last block number seen by the retriever for // an event type and contract address LastBlockNumber(eventType string, contractAddress common.Address) uint64 // LastBlockHash returns the last block hash seen by the retriever for an event // type and contract address LastBlockHash(eventType string, contractAddress common.Address) common.Hash // UpdateLastBlockData should update the last block Number from the Event(s) UpdateLastBlockData(events []*Event) error }
RetrieverMetaDataPersister handles storing any metadata related to running the retriever.
type VersionDataPersister ¶
type VersionDataPersister interface { // PersisterVersion retrieves the latest version for the table type PersisterVersion(tableType string) (string, error) // SaveVersion saves the version number for this table type with the current timestamp SaveVersion(tableType string, versionNumber string) error // OldVersions retrieves all the versions except for most recent for this service name OldVersions(serviceName string) ([]string, error) }
VersionDataPersister handles storing and receiving version table data.