entity

package
v0.0.0-...-efbdb50 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ONE_BI = new(big.Int).SetUint64(1)

Functions

func B

func B(v bool) *bool

func ConvertTokenToDecimal

func ConvertTokenToDecimal(amount *big.Int, decimals int64) *big.Float

func ExponentToBigFloat

func ExponentToBigFloat(decimals int64) *big.Float

func GetTableName

func GetTableName(entity Interface) string

func GetTableNameFromType

func GetTableNameFromType(entity reflect.Type) string

func S

func S(str string) *string

Types

type Base

type Base struct {
	ID              string      `db:"id" csv:"id"`         // text key
	VID             uint64      `db:"vid" csv:"-" poi:"-"` // version
	BlockRange      *BlockRange `db:"block_range" csv:"block_range"`
	UpdatedBlockNum uint64      `db:"_updated_block_number" csv:"updated_block_number" poi:"-"`

	MutatedOnStep int `db:"-" csv:"-" poi:"-"`
	// contains filtered or unexported fields
}

func NewBase

func NewBase(id string) Base

func (*Base) Exists

func (e *Base) Exists() bool

func (*Base) GetBlockRange

func (e *Base) GetBlockRange() *BlockRange

func (*Base) GetID

func (e *Base) GetID() string

func (*Base) GetVID

func (e *Base) GetVID() uint64

func (*Base) SetBlockRange

func (e *Base) SetBlockRange(br *BlockRange)

func (*Base) SetExists

func (e *Base) SetExists(exists bool)

func (*Base) SetID

func (e *Base) SetID(id string)

func (*Base) SetMutated

func (e *Base) SetMutated(step int)

func (*Base) SetUpdatedBlockNum

func (e *Base) SetUpdatedBlockNum(blockNum uint64)

func (*Base) SetVID

func (e *Base) SetVID(vid uint64)

type BaseEvent

type BaseEvent struct {
	Block       *Block
	Transaction *Transaction
}

func (*BaseEvent) SetBlockAndTransaction

func (e *BaseEvent) SetBlockAndTransaction(b *pbcodec.Block, t *pbcodec.TransactionTrace)

type Block

type Block struct {
	Hash             eth.Hash
	Parent           eth.Hash
	UnclesHash       eth.Hash
	StateRoot        eth.Hash
	TransactionsRoot eth.Hash
	ReceiptsRoot     eth.Hash
	Number           uint64
	GasUsed          uint64
	GasLimit         uint64
	Timestamp        int64
	Difficulty       *big.Int
	Size             uint64
}

type BlockRange

type BlockRange struct {
	StartBlock uint64
	EndBlock   uint64
}

func (*BlockRange) MarshalCSV

func (b *BlockRange) MarshalCSV() ([]byte, error)

func (*BlockRange) ParseBytes

func (b *BlockRange) ParseBytes(bs []byte) error

func (*BlockRange) Scan

func (b *BlockRange) Scan(value interface{}) error

func (*BlockRange) String

func (b *BlockRange) String() string

func (*BlockRange) UnmarshalJSON

func (b *BlockRange) UnmarshalJSON(data []byte) error

func (*BlockRange) Value

func (b *BlockRange) Value() (driver.Value, error)

type Bool

type Bool bool

func NewBool

func NewBool(v bool) Bool

func (Bool) Ptr

func (b Bool) Ptr() *Bool

func (*Bool) Scan

func (b *Bool) Scan(value interface{}) error

func (*Bool) Value

func (b *Bool) Value() (driver.Value, error)

type Bytes

type Bytes []byte

func (Bytes) MarshalCSV

func (b Bytes) MarshalCSV() ([]byte, error)

func (*Bytes) Scan

func (b *Bytes) Scan(value interface{}) error

func (*Bytes) UnmarshalCSV

func (b *Bytes) UnmarshalCSV(hexStr []byte) error

func (Bytes) Value

func (b Bytes) Value() (driver.Value, error)

type CSVProcessing

type CSVProcessing interface {
	Process(previous Interface)
}

type Cacheable

type Cacheable interface {
	SkipDBLookup() bool
}

type Enum

type Enum string

func (*Enum) Scan

func (e *Enum) Scan(value interface{}) error

func (Enum) String

func (e Enum) String() string

func (*Enum) Value

func (e *Enum) Value() (driver.Value, error)

type ExportedEntities

type ExportedEntities struct {
	BlockNum       uint64
	BlockTimestamp time.Time
	EntityName     string
	Entities       Map

	TypeGetter interface {
		GetType(string) (reflect.Type, bool)
	} `json:"-"`
}

func (*ExportedEntities) UnmarshalJSON

func (ee *ExportedEntities) UnmarshalJSON(in []byte) error

type FieldTag

type FieldTag struct {
	Name       string
	Base       bool
	ColumnName string
	Optional   bool
}

func DBFields

func DBFields(entityType reflect.Type) (out []*FieldTag)

type Finalizable

type Finalizable interface {
	IsFinal(blockNum uint64, blockTime time.Time) bool
}

An entity which is finalizeable is one that you guarantee will not be read nor written to anymore. In this case, you could purge it from a cache or write them early to a store

type Float

type Float struct {
	// contains filtered or unexported fields
}

func FloatAdd

func FloatAdd(a, b Float) Float

func FloatMul

func FloatMul(a, b Float) Float

func FloatQuo

func FloatQuo(a, b Float) Float

func FloatSub

func FloatSub(a, b Float) Float

func NewFloat

func NewFloat(f *big.Float) Float

func NewFloatFromLiteral

func NewFloatFromLiteral(f float64) Float

func Z

func Z() Float

func (*Float) Float

func (b *Float) Float() *big.Float

func (Float) MarshalCSV

func (b Float) MarshalCSV() ([]byte, error)

func (Float) MarshalJSON

func (b Float) MarshalJSON() ([]byte, error)

func (Float) Ptr

func (b Float) Ptr() *Float

func (*Float) Scan

func (b *Float) Scan(value interface{}) error

func (Float) String

func (b Float) String() string

func (Float) StringRounded

func (b Float) StringRounded(digits int) string

func (*Float) UnmarshalJSON

func (b *Float) UnmarshalJSON(data []byte) error

func (Float) Value

func (b Float) Value() (driver.Value, error)

type Int

type Int struct {
	// contains filtered or unexported fields
}

func I

func I() Int

func Inc

func Inc(v Int) Int

func IntAdd

func IntAdd(a, b Int) Int

func IntMul

func IntMul(a, b Int) Int

func IntQuo

func IntQuo(a, b Int) Int

func IntSub

func IntSub(a, b Int) Int

func NewInt

func NewInt(i *big.Int) Int

func NewIntFromLiteral

func NewIntFromLiteral(i int64) Int

func NewIntFromLiteralUnsigned

func NewIntFromLiteralUnsigned(i uint64) Int

func (Int) AsFloat

func (b Int) AsFloat() Float

func (*Int) Int

func (i *Int) Int() *big.Int

To "copy" an Int value, an existing (or newly allocated) Int must be set to a new value using the Int.Set method; shallow copies of Ints are not supported and may lead to errors.

func (Int) MarshalCSV

func (b Int) MarshalCSV() ([]byte, error)

func (Int) MarshalJSON

func (b Int) MarshalJSON() ([]byte, error)

func (Int) Ptr

func (i Int) Ptr() *Int

func (*Int) Scan

func (b *Int) Scan(value interface{}) error

func (Int) String

func (b Int) String() string

func (*Int) UnmarshalJSON

func (b *Int) UnmarshalJSON(data []byte) error

func (Int) Value

func (b Int) Value() (driver.Value, error)

type Interface

type Interface interface {
	GetID() string
	SetID(id string)
	GetVID() uint64
	SetVID(uint64)
	SetBlockRange(br *BlockRange)
	GetBlockRange() *BlockRange
	SetUpdatedBlockNum(blockNum uint64)

	Exists() bool
	SetExists(exists bool)
	SetMutated(step int)
}

type LocalStringArray

type LocalStringArray pq.StringArray

func ArrayAdd

func ArrayAdd(a, b LocalStringArray) LocalStringArray

func (*LocalStringArray) MarshalCSV

func (b *LocalStringArray) MarshalCSV() ([]byte, error)

func (*LocalStringArray) Scan

func (a *LocalStringArray) Scan(src interface{}) error

Scan implements the sql.Scanner interface.

func (LocalStringArray) Value

func (a LocalStringArray) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type Map

type Map map[string]Interface

type Mergeable

type Mergeable interface {
	Merge(step int, previous Interface)
}

An entity that is mergeable is able to take an Entity from a previous _parallel step_, and merge it with the one from the current step. It needs to understand the state of the data in each field, at which step each field is "ready" (or valid), and know how to merge them.

The Entity that is kept is the _receiver_ of the method, the previous is not kept around. You are guaranteed that the type of `previous` will be the same as the _receiver_.

For example, a field like `TransactionCount` that is computed on step 2, will want to be sum'ed up on step 3. You do not want to merge anything on step 1 because the data for TransactionCount is not "ready" on that step.

Another example would be a field that computes an average over time. Merging an average would mean adding the two and dividing by two, but for the step at which we know the data was properly computed: if the update to the value comes from step 3, you will want to only apply the merge at step 4.

NOTE: You should use `previous.MutatedOnStep` to validate the entity was effectively changed at the step you expect it to have changed. In some situations, this might not be the case.

type NamedEntity

type NamedEntity interface {
	TableName() string
}

type POI

type POI struct {
	Base
	Digest Bytes `db:"digest" csv:"digest"`
	// contains filtered or unexported fields
}

func NewPOI

func NewPOI(causalityRegion string) *POI

func (*POI) AddEnt

func (p *POI) AddEnt(entityType string, ent interface{}) error

func (*POI) AggregateDigest

func (p *POI) AggregateDigest(previousDigest []byte)

func (*POI) Apply

func (p *POI) Apply()

func (*POI) Clear

func (p *POI) Clear()

func (*POI) IsFinal

func (p *POI) IsFinal(_ uint64, _ time.Time) bool

func (*POI) RemoveEnt

func (p *POI) RemoveEnt(entityType, entityId string) error

func (*POI) TableName

func (p *POI) TableName() string

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

func NewRegistry

func NewRegistry(entities ...Interface) *Registry

func (*Registry) Data

func (r *Registry) Data() map[string]reflect.Type

func (*Registry) Entities

func (r *Registry) Entities() []Interface

func (*Registry) GetInterface

func (r *Registry) GetInterface(tableName string) (Interface, bool)

func (*Registry) GetType

func (r *Registry) GetType(tableName string) (reflect.Type, bool)

func (*Registry) Len

func (r *Registry) Len() int

func (*Registry) Register

func (r *Registry) Register(entities ...Interface)

type Sanitizable

type Sanitizable interface {
	Sanitize()
}

type Transaction

type Transaction struct {
	Hash     eth.Hash
	Index    uint32
	From     eth.Address
	To       eth.Address
	Value    *big.Int
	GasUsed  uint64
	GasPrice *big.Int
	Input    []byte
}

Jump to

Keyboard shortcuts

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