storable

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HexStrToBigInt

func HexStrToBigInt(hexString string) (*big.Int, error)

HexStrToBigInt transforms a hex sting like "0xff" to a big.Int. Arbitrary length values are possible.

func HexStrToBigIntStr

func HexStrToBigIntStr(hexString string) (string, error)

HexStrToBigIntStr transforms a hex sting like "0xff" to a big int string like "15". Arbitrary length values are possible.

func Trim0x

func Trim0x(str string) string

Trim0x removes the "0x" prefix of hexes if it exists

Types

type AccountTx

type AccountTx struct {
	Address         string
	Counterparty    string
	TxHash          string
	Out             bool
	IncludedInBlock int64
	TxIndex         int64
}

AccountTx is a type of entity that represents a transaction between two accounts For each transaction, 2 AccountTx entities will be created, one for each direction of the transaction This helps with querying an account's transactions history in a specific order (e.g. chronological) and paginated

type AccountTxsGroup

type AccountTxsGroup struct {
	RawBlock types.Block
	// contains filtered or unexported fields
}

func NewStorableAccountTxs

func NewStorableAccountTxs(block types.Block) *AccountTxsGroup

func (*AccountTxsGroup) ToDB

func (atg *AccountTxsGroup) ToDB(tx *sql.Tx) error

type Block

type Block struct {
	RawBlock             types.Block
	Number               int64
	BlockHash            string
	ParentBlockHash      string
	BlockCreationTime    DatetimeToJSONUnix
	BlockGasLimit        string
	BlockGasUsed         string
	BlockDifficulty      string
	TotalBlockDifficulty string
	BlockExtraData       ByteArray
	BlockMixHash         ByteArray
	BlockNonce           ByteArray
	BlockSize            int64
	BlockLogsBloom       ByteArray
	IncludesUncle        JSONStringArray
	HasBeneficiary       ByteArray
	HasReceiptsTrie      ByteArray
	HasTxTrie            ByteArray
	Sha3Uncles           ByteArray
	NumberOfUncles       int32
	NumberOfTxs          int32
}

func NewStorableBlock

func NewStorableBlock(block types.Block) *Block

func (*Block) ToDB

func (sb *Block) ToDB(tx *sql.Tx) error

type ByteArray

type ByteArray string

ByteArray is a custom type that maps to a the database `bytea` fields

func (*ByteArray) Scan

func (val *ByteArray) Scan(value interface{}) error

func (ByteArray) String

func (val ByteArray) String() string

func (ByteArray) Value

func (val ByteArray) Value() (driver.Value, error)

type DatetimeToJSONUnix

type DatetimeToJSONUnix time.Time

DatetimeToJSONUnix binds a time.Time to a `timestamp` database field when marshaled to JSON, outputs a unix timestamp

func (DatetimeToJSONUnix) MarshalJSON

func (t DatetimeToJSONUnix) MarshalJSON() ([]byte, error)

func (*DatetimeToJSONUnix) Scan

func (t *DatetimeToJSONUnix) Scan(value interface{}) error

func (DatetimeToJSONUnix) String

func (t DatetimeToJSONUnix) String() string

func (*DatetimeToJSONUnix) UnmarshalJSON

func (t *DatetimeToJSONUnix) UnmarshalJSON(data []byte) error

func (DatetimeToJSONUnix) Value

func (t DatetimeToJSONUnix) Value() (driver.Value, error)

type JSONObject

type JSONObject map[string]interface{}

JSONObject binds a map[string]interface{} to a `jsonb` database field

func (*JSONObject) Scan

func (obj *JSONObject) Scan(value interface{}) error

func (JSONObject) Value

func (obj JSONObject) Value() (driver.Value, error)

type JSONStringArray

type JSONStringArray []string

JSONStringArray binds a slice of strings to a `jsonb` database field

func (*JSONStringArray) Scan

func (j *JSONStringArray) Scan(value interface{}) error

func (JSONStringArray) Value

func (j JSONStringArray) Value() (driver.Value, error)

type LogEntriesGroup

type LogEntriesGroup struct {
	RawBlock    types.Block
	RawReceipts []types.Receipt
	// contains filtered or unexported fields
}

func NewStorableLogEntries

func NewStorableLogEntries(block types.Block, receipts []types.Receipt) *LogEntriesGroup

func (*LogEntriesGroup) ToDB

func (leg *LogEntriesGroup) ToDB(tx *sql.Tx) error

type LogEntry

type LogEntry struct {
	TxHash          string
	LogIndex        int32
	LogData         ByteArray
	LoggedBy        string
	Topic0          string
	Topic1          string
	Topic2          string
	Topic3          string
	IncludedInBlock int64
}

type Tx

type Tx struct {
	TxHash              string
	IncludedInBlock     int64
	TxIndex             int32
	From                ByteArray
	To                  ByteArray
	Value               string
	TxNonce             int64
	MsgGasLimit         string
	TxGasUsed           string
	TxGasPrice          string
	CumulativeGasUsed   string
	MsgPayload          ByteArray
	MsgStatus           string
	Creates             ByteArray
	TxLogsBloom         ByteArray
	BlockCreationTime   DatetimeToJSONUnix
	LogEntriesTriggered int32
}

type TxsGroup

type TxsGroup struct {
	RawBlock    types.Block
	RawReceipts []types.Receipt
	// contains filtered or unexported fields
}

func NewStorableTxs

func NewStorableTxs(block types.Block, receipts []types.Receipt) *TxsGroup

func (*TxsGroup) ToDB

func (t *TxsGroup) ToDB(dbTx *sql.Tx) error

type Uncle

type Uncle struct {
	BlockHash         string
	IncludedInBlock   int64
	Number            int64
	BlockCreationTime DatetimeToJSONUnix
	UncleIndex        int32
	BlockGasLimit     string
	BlockGasUsed      string
	HasBeneficiary    ByteArray
	BlockDifficulty   string
	BlockExtraData    ByteArray
	BlockMixHash      ByteArray
	BlockNonce        ByteArray
	Sha3Uncles        ByteArray
}

type UnclesGroup

type UnclesGroup struct {
	RawBlock  types.Block
	RawUncles []types.Block
	// contains filtered or unexported fields
}

func NewStorableUncles

func NewStorableUncles(block types.Block, uncles []types.Block) *UnclesGroup

func (*UnclesGroup) ToDB

func (ug *UnclesGroup) ToDB(tx *sql.Tx) error

Jump to

Keyboard shortcuts

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