burrow: github.com/hyperledger/burrow/vent/types Index | Files

package types

import "github.com/hyperledger/burrow/vent/types"

Index

Package Files

event_class.go event_data.go event_input_type.go event_tables.go sql_column_type.go sql_error_type.go sql_supported_databases.go sql_table.go sql_utils.go

Constants

const (
    EventFieldTypeInt     = "int"
    EventFieldTypeUInt    = "uint"
    EventFieldTypeAddress = "address"
    EventFieldTypeBytes   = "bytes"
    EventFieldTypeBool    = "bool"
    EventFieldTypeString  = "string"
)

Defined event input types - these are currently align with EVM types but they technically define a pair/mapping of EVM type -> SQL type

const (
    PostgresDB = "postgres"
    SQLiteDB   = "sqlite"
)

supported databases

const (
    // event related
    EventNameLabel  = "eventName"
    EventTypeLabel  = "eventType"
    EventIndexLabel = "eventIndex"

    // block related
    ChainIDLabel     = "chainID"
    BlockHeightLabel = "height"
    TxIndexLabel     = "txIndex"

    // transaction related
    TxTxHashLabel = "txHash"
)

labels for column mapping

Variables

var DefaultSQLColumnNames = SQLColumnNames{

    Id:          "_id",
    TimeStamp:   "_timestamp",
    TableName:   "_tablename",
    EventName:   "_eventname",
    EventFilter: "_eventfilter",
    Height:      "_height",
    TxHash:      "_txhash",
    Action:      "_action",
    DataRow:     "_datarow",
    SqlStmt:     "_sqlstmt",
    SqlValues:   "_sqlvalues",

    ColumnName:   "_columnname",
    ColumnType:   "_columntype",
    ColumnLength: "_columnlength",
    PrimaryKey:   "_primarykey",
    ColumnOrder:  "_columnorder",

    BurrowVersion: "_burrowversion",
    ChainID:       "_chainid",

    TxIndex:     "_txindex",
    EventIndex:  "_eventindex",
    EventType:   "_eventtype",
    BlockHeader: "_blockheader",
    TxType:      "_txtype",
    Envelope:    "_envelope",
    Events:      "_events",
    Result:      "_result",
    Receipt:     "_receipt",
    Origin:      "_origin",
    Exception:   "_exception",
}
var DefaultSQLNames = SQLNames{
    Tables:  DefaultSQLTableNames,
    Columns: DefaultSQLColumnNames,
}
var DefaultSQLTableNames = SQLTableNames{
    Log:        "_vent_log",
    Dictionary: "_vent_dictionary",
    Block:      "_vent_block",
    Tx:         "_vent_tx",
    ChainInfo:  "_vent_chain",
}

func ProjectionSpecSchema Uses

func ProjectionSpecSchema() *jsonschema.Schema

type DBAction Uses

type DBAction string

DBAction generic type

const (
    ActionDelete      DBAction = "DELETE"
    ActionUpsert      DBAction = "UPSERT"
    ActionRead        DBAction = "READ"
    ActionCreateTable DBAction = "CREATE"
    ActionAlterTable  DBAction = "ALTER"
)

type EventClass Uses

type EventClass struct {
    // Destination table in DB
    TableName string
    // Burrow event filter query in query peg grammar
    Filter string
    // The name of a solidity event field that when present indicates that the rest of the event should be interpreted
    // as requesting a row deletion (rather than upsert) in the projection table.
    DeleteMarkerField string `json:",omitempty"`
    // EventFieldMapping from solidity event field name to EventFieldMapping descriptor
    FieldMappings []*EventFieldMapping
    // contains filtered or unexported fields
}

EventClass struct (table name where to persist filtered events and it structure)

func (*EventClass) GetFieldMapping Uses

func (ec *EventClass) GetFieldMapping(fieldName string) *EventFieldMapping

func (*EventClass) GetFilter Uses

func (ec *EventClass) GetFilter() string

func (*EventClass) Query Uses

func (ec *EventClass) Query() (query.Query, error)

Get a (memoised) Query from the EventClass Filter string

func (*EventClass) Validate Uses

func (ec *EventClass) Validate() error

Validate checks the structure of an EventClass

type EventData Uses

type EventData struct {
    BlockHeight uint64
    Tables      map[string]EventDataTable
}

EventData contains data for each block of events already mapped to SQL columns & tables Tables map key is the table name

type EventDataRow Uses

type EventDataRow struct {
    Action  DBAction
    RowData map[string]interface{}
    // The EventClass that caused this row to be emitted (if it was caused by an specific event)
    EventClass *EventClass `json:"-"`
}

EventDataRow contains each SQL column name and a corresponding value to upsert map key is the column name and map value is the given column value if Action == 'delete' then the row has to be deleted

type EventDataTable Uses

type EventDataTable []EventDataRow

EventDataTable is an array of rows

type EventFieldMapping Uses

type EventFieldMapping struct {
    // EVM event field name to process
    Field string
    // EVM type of this field - used to derive SQL type
    Type string
    // Destination SQL column name to which to map this event field
    ColumnName string
    // Whether this event field should map to a primary key
    Primary bool `json:",omitempty"`
    // Whether to convert this event field from bytes32 to string
    BytesToString bool `json:",omitempty"`
    // Whether to convert this event field from bytes32 to hex-encoded string
    BytesToHex bool `json:",omitempty"`
    // Notification channels on which submit (via a trigger) a payload that contains this column's new value (upsert) or
    // old value (delete). The payload will contain all other values with the same channel set as a JSON object.
    Notify []string `json:",omitempty"`
}

EventFieldMapping struct (table column definition)

func (EventFieldMapping) Validate Uses

func (evColumn EventFieldMapping) Validate() error

Validate checks the structure of an EventFieldMapping

type EventTables Uses

type EventTables map[string]*SQLTable

EventTables contains SQL tables definition Map from TableName to SQLTable

type ProjectionSpec Uses

type ProjectionSpec []*EventClass

ProjectionSpec contains all event class specifications

type SQLCleanDBQuery Uses

type SQLCleanDBQuery struct {
    SelectChainIDQry    string
    DeleteChainIDQry    string
    InsertChainIDQry    string
    SelectDictionaryQry string
    DeleteDictionaryQry string
    DeleteLogQry        string
}

SQLCleanDBQuery stores queries needed to clean the database

type SQLColumnNames Uses

type SQLColumnNames struct {
    // log
    Id          string
    TimeStamp   string
    TableName   string
    EventName   string
    EventFilter string
    Height      string
    TxHash      string
    Action      string
    DataRow     string
    SqlStmt     string
    SqlValues   string
    // dictionary
    ColumnName   string
    ColumnType   string
    ColumnLength string
    PrimaryKey   string
    ColumnOrder  string
    // chain info
    BurrowVersion string
    ChainID       string
    // context
    TxIndex     string
    EventIndex  string
    EventType   string
    BlockHeader string
    TxType      string
    Envelope    string
    Events      string
    Result      string
    Receipt     string
    Origin      string
    Exception   string
}

type SQLColumnType Uses

type SQLColumnType int

SQLColumnType to store generic SQL column types

const (
    SQLColumnTypeBool SQLColumnType = iota
    SQLColumnTypeByteA
    SQLColumnTypeInt
    SQLColumnTypeSerial
    SQLColumnTypeText
    SQLColumnTypeVarchar
    SQLColumnTypeTimeStamp
    SQLColumnTypeNumeric
    SQLColumnTypeJSON
    SQLColumnTypeBigInt
)

generic SQL column types

func (SQLColumnType) IsNumeric Uses

func (ct SQLColumnType) IsNumeric() bool

IsNumeric determines if an sqlColumnType is numeric

func (SQLColumnType) String Uses

func (ct SQLColumnType) String() string

type SQLConnection Uses

type SQLConnection struct {
    DBAdapter string
    DBURL     string
    DBSchema  string
    Log       *logging.Logger
}

SQLConnection stores parameters to build a new db connection & initialize the database

type SQLErrorType Uses

type SQLErrorType int

SQLErrorType stores generic SQL error types

const (
    SQLErrorTypeDuplicatedSchema SQLErrorType = iota
    SQLErrorTypeDuplicatedColumn
    SQLErrorTypeDuplicatedTable
    SQLErrorTypeInvalidType
    SQLErrorTypeUndefinedTable
    SQLErrorTypeUndefinedColumn
    SQLErrorTypeGeneric
)

generic SQL error types

type SQLNames Uses

type SQLNames struct {
    Tables  SQLTableNames
    Columns SQLColumnNames
}

type SQLTable Uses

type SQLTable struct {
    Name    string
    Columns []*SQLTableColumn
    // Map of channel name -> columns to be sent as payload on that channel
    NotifyChannels map[string][]string
    // contains filtered or unexported fields
}

SQLTable contains the structure of a SQL table,

func (*SQLTable) GetColumn Uses

func (table *SQLTable) GetColumn(columnName string) *SQLTableColumn

type SQLTableColumn Uses

type SQLTableColumn struct {
    Name    string
    Type    SQLColumnType
    Primary bool
    // Length of variable column type where applicable 0 indicates variable/unbounded length
    Length int
}

SQLTableColumn contains the definition of a SQL table column, the Order is given to be able to sort the columns to be created

func (*SQLTableColumn) Equals Uses

func (col *SQLTableColumn) Equals(otherCol *SQLTableColumn) bool

func (*SQLTableColumn) String Uses

func (col *SQLTableColumn) String() string

type SQLTableNames Uses

type SQLTableNames struct {
    Log        string
    Dictionary string
    Block      string
    Tx         string
    ChainInfo  string
}

type UpsertDeleteQuery Uses

type UpsertDeleteQuery struct {
    Query    string
    Values   string
    Pointers []interface{}
}

UpsertDeleteQuery contains query and values to upsert or delete row data

Package types imports 5 packages (graph) and is imported by 10 packages. Updated 2020-08-04. Refresh now. Tools for package owners.