shared

package
v0.2.10-docker Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2019 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InsertIlkQuery = `INSERT INTO maker.ilks (ilk, identifier) VALUES ($1, $2) RETURNING id`
	InsertUrnQuery = `INSERT INTO maker.urns (identifier, ilk_id) VALUES ($1, $2) RETURNING id`
)

Variables

View Source
var ErrInvalidIndex = func(index int) error {
	return errors.New(fmt.Sprintf("unsupported log data index: %d", index))
}

Functions

func BigIntToInt64

func BigIntToInt64(value *big.Int) int64

func BigIntToString

func BigIntToString(value *big.Int) string

func ConvertInt256HexToBigInt added in v0.2.3

func ConvertInt256HexToBigInt(hex string) *big.Int

func ConvertIntStringToHex added in v0.2.2

func ConvertIntStringToHex(n string) (string, error)

func ConvertUint256HexToBigInt added in v0.2.3

func ConvertUint256HexToBigInt(hex string) *big.Int

func Create added in v0.2.8

func Create(headerID int64, 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{
			TableName:      "testEvent",
			OrderedColumns: []string{"header_id", "log_idx", "tx_idx", "raw_log", constants.IlkFK, constants.UrnFK, "variable1"},
			ColumnValues: ColumnValues{
				"log_idx":   "1",
				"tx_idx":    "2",
				"raw_log":   fakeLog,
				"variable1": "value1",
			},
			ForeignKeyValues: shared.ForeignKeyValues{
				constants.IlkFK: test_helpers.FakeIlk.Hex,
				constants.UrnFK: "0x12345",
			},
		}

func DecodeHexToText added in v0.2.4

func DecodeHexToText(payload string) string

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 GetLogNoteArgumentAtIndex(index int, logData []byte) ([]byte, error)

func GetOrCreateIlk

func GetOrCreateIlk(ilk string, db *postgres.DB) (int, error)

func GetOrCreateIlkInTransaction

func GetOrCreateIlkInTransaction(ilk string, tx *sqlx.Tx) (int, error)

func GetOrCreateUrn added in v0.2.2

func GetOrCreateUrn(guy string, hexIlk string, db *postgres.DB) (urnID int, err error)

func GetOrCreateUrnInTransaction added in v0.2.2

func GetOrCreateUrnInTransaction(guy string, hexIlk string, tx *sqlx.Tx) (urnID int, err error)

func MinInt64

func MinInt64(ints []int64) (min int64)

Types

type ColumnValues added in v0.2.8

type ColumnValues map[string]interface{}

type ForeignKeyValues added in v0.2.8

type ForeignKeyValues map[constants.ForeignKeyField]string

type InsertionModel added in v0.2.8

type InsertionModel struct {
	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 LogNoteConverter added in v0.2.3

type LogNoteConverter interface {
	ToModels(ethLog []types.Log) ([]InsertionModel, error)
}

type LogNoteTransformer added in v0.2.3

type LogNoteTransformer struct {
	Config     transformer.EventTransformerConfig
	Converter  LogNoteConverter
	Repository SharedRepository
}

func (LogNoteTransformer) Execute added in v0.2.3

func (tr LogNoteTransformer) Execute(logs []types.Log, header core.Header) error

func (LogNoteTransformer) GetConfig added in v0.2.3

func (LogNoteTransformer) GetName added in v0.2.3

func (tr LogNoteTransformer) GetName() string

func (LogNoteTransformer) NewLogNoteTransformer added in v0.2.3

func (tr LogNoteTransformer) NewLogNoteTransformer(db *postgres.DB) transformer.EventTransformer

type SharedRepository added in v0.2.8

type SharedRepository interface {
	Create(headerID int64, models []InsertionModel) error
	MarkHeaderChecked(headerID int64) error
	SetDB(db *postgres.DB)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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