Documentation ¶
Index ¶
- Variables
- func BigIntToInt64(value *big.Int) int64
- func BigIntToString(value *big.Int) string
- func ConvertInt256HexToBigInt(hex string) *big.Int
- func ConvertIntStringToHex(n string) (string, error)
- func ConvertUint256HexToBigInt(hex string) *big.Int
- func Create(models []InsertionModel, db *postgres.DB) error
- func DecodeHexToText(payload string) string
- func FormatRollbackError(field, err string) error
- func GenerateInsertionQuery(model InsertionModel) string
- func GetEventTransformerConfig(transformerLabel, signature string) transformer.EventTransformerConfig
- func GetLogNoteArgumentAtIndex(index int, logData []byte) ([]byte, error)
- func GetMemoizedQuery(model InsertionModel) string
- func GetOrCreateAddress(address string, db *postgres.DB) (int64, error)
- func GetOrCreateAddressInTransaction(address string, tx *sqlx.Tx) (int64, error)
- func GetOrCreateIlk(ilk string, db *postgres.DB) (int64, error)
- func GetOrCreateIlkInTransaction(ilk string, tx *sqlx.Tx) (int64, error)
- func GetOrCreateUrn(guy string, hexIlk string, db *postgres.DB) (urnID int64, err error)
- func GetOrCreateUrnInTransaction(guy string, hexIlk string, tx *sqlx.Tx) (urnID int64, err error)
- func MinInt64(ints []int64) (min int64)
- func PopulateForeignKeyIDs(fkToValue ForeignKeyValues, columnToValue ColumnValues, tx *sqlx.Tx) error
- func VerifyLog(log types.Log, expectedNumTopics int, isDataRequired bool) error
- type ColumnValues
- type Converter
- type EventTransformer
- type ForeignKeyValues
- type InsertionModel
- type SharedRepository
Constants ¶
This section is empty.
Variables ¶
var ( ErrLogMissingTopics = func(expectedNumTopics, actualNumTopics int) error { return fmt.Errorf("log missing topics: has %d, want %d", actualNumTopics, expectedNumTopics) } ErrLogMissingData = errors.New("log missing data") ErrCouldNotCreateFK = func(err error) error { return fmt.Errorf("converter could not create FK: %v", err) } )
var ErrInvalidIndex = func(index int) error { return errors.New(fmt.Sprintf("unsupported log data index: %d", index)) }
var ModelToQuery = map[string]string{}
Stores memoised insertion queries to minimise computation
Functions ¶
func BigIntToInt64 ¶
func BigIntToString ¶
func ConvertInt256HexToBigInt ¶ added in v0.2.3
func ConvertIntStringToHex ¶ added in v0.2.2
func ConvertUint256HexToBigInt ¶ added in v0.2.3
func Create ¶ added in v0.2.8
func Create(models []InsertionModel, db *postgres.DB) error
Given an instance of InsertionModel, example below, generates an insertion query and fills in
foreign keys automatically after getting from the DB. These "special fields" are populated in the columnToValue mapping, and are treated like any other in the insertion.
testModel = shared.InsertionModel{ SchemaName: "maker" TableName: "testEvent", OrderedColumns: []string{"header_id", "log_id", constants.IlkFK, constants.UrnFK, "variable1"}, ColumnValues: ColumnValues{ "log_id": "1", "variable1": "value1", }, ForeignKeyValues: shared.ForeignKeyValues{ constants.IlkFK: test_helpers.FakeIlk.Hex, constants.UrnFK: "0x12345", }, }
func DecodeHexToText ¶ added in v0.2.4
func FormatRollbackError ¶ added in v0.2.12
func GenerateInsertionQuery ¶ added in v0.2.12
func GenerateInsertionQuery(model InsertionModel) string
Creates an insertion query from an insertion model. This is called through GetMemoizedQuery, so the query is not generated on each call to Create. Note: With extraction of event metadata, one would not have to supply header_id, tx_idx, etc in InsertionModel.OrderedColumns? Note: I have a feeling we can actually do away with the OrderedColumns field, but the tricky part is that some fields
needed aren't present in the map in the beginning
func GetEventTransformerConfig ¶ added in v0.2.10
func GetEventTransformerConfig(transformerLabel, signature string) transformer.EventTransformerConfig
Creates a transformer config by pulling values from configuration environment
func GetLogNoteArgumentAtIndex ¶ added in v0.2.6
func GetMemoizedQuery ¶ added in v0.2.12
func GetMemoizedQuery(model InsertionModel) string
func GetOrCreateAddress ¶ added in v0.2.12
func GetOrCreateAddressInTransaction ¶ added in v0.2.12
func GetOrCreateUrn ¶ added in v0.2.2
func GetOrCreateUrnInTransaction ¶ added in v0.2.2
func PopulateForeignKeyIDs ¶ added in v0.2.12
func PopulateForeignKeyIDs(fkToValue ForeignKeyValues, columnToValue ColumnValues, tx *sqlx.Tx) error
Gets or creates the FK for the key/values supplied, and inserts the resulting ID into the columnToValue mapping
Types ¶
type ColumnValues ¶ added in v0.2.8
type ColumnValues map[string]interface{}
type Converter ¶ added in v0.2.13
type Converter interface {
ToModels(contractAbi string, ethLog []core.HeaderSyncLog) ([]InsertionModel, error)
}
TODO purge when everything moved to vDB interface
type EventTransformer ¶ added in v0.2.13
type EventTransformer struct { Config transformer.EventTransformerConfig Converter Converter Repository SharedRepository }
func (EventTransformer) Execute ¶ added in v0.2.13
func (tr EventTransformer) Execute(logs []core.HeaderSyncLog) error
func (EventTransformer) GetConfig ¶ added in v0.2.13
func (tr EventTransformer) GetConfig() transformer.EventTransformerConfig
func (EventTransformer) GetName ¶ added in v0.2.13
func (tr EventTransformer) GetName() string
func (EventTransformer) NewEventTransformer ¶ added in v0.2.13
func (tr EventTransformer) NewEventTransformer(db *postgres.DB) transformer.EventTransformer
type ForeignKeyValues ¶ added in v0.2.8
type ForeignKeyValues map[constants.ForeignKeyField]string
type InsertionModel ¶ added in v0.2.8
type InsertionModel struct { SchemaName string TableName string // For MarkHeaderChecked, insert query OrderedColumns []string // Defines the fields to insert, and in which order the table expects them // ColumnValues needs to be typed interface{}, since `raw_log` is a slice of bytes and not a string ColumnValues ColumnValues // Associated values for columns, headerID, FKs and event metadata populated automatically ForeignKeyValues ForeignKeyValues // FK name and value to get/create ID for }
type SharedRepository ¶ added in v0.2.8
type SharedRepository interface {}