common

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2018 License: LGPL-3.0 Imports: 12 Imported by: 7

Documentation

Index

Constants

View Source
const (
	ErrCodeDuplicateKey = 1062
)

Variables

View Source
var (
	// ErrWrongSigner returns if it's a wrong signer
	ErrWrongSigner = errors.New("wrong signer")
	// ErrInconsistentRoot returns if the block and dump states have different root
	ErrInconsistentRoot = errors.New("inconsistent root")
	// ErrInconsistentStates returns if the number of blocks, dumps or recipents are different
	ErrInconsistentStates = errors.New("inconsistent states")
	// ErrInvalidTD is returned when a block has invalid TD
	ErrInvalidTD = errors.New("invalid TD")
	// ErrInvalidReceiptLog returns if it's a invalid receipt log
	ErrInvalidReceiptLog = errors.New("invalid receipt log")
)

Functions

func AddressHex

func AddressHex(address common.Address) string

AddressHex returns an address hex and lower-case string without '0x'

func BytesTo0xHex

func BytesTo0xHex(data []byte) string

BytesTo0xHex returns a hex representation (with '0x') of a byte array

func BytesToHex

func BytesToHex(data []byte) string

BytesToHex returns a hex representation (lower-case string without '0x') of a byte array

func DuplicateError

func DuplicateError(err error) bool

DuplicateError checks whether it's a duplicate key error

func EthTransferEvent

func EthTransferEvent(b *types.Block, log *types.TransferLog) *model.ETHTransfer

EthTransferEvent converts eth transfer log to eth tranfer event

func HashHex

func HashHex(hash common.Hash) string

HashHex returns a hash hex and lower-case string without '0x'

func Header(b *types.Block) *model.Header

Header converts ethereum block to db block

func Hex

func Hex(str string) string

Hex returns a hash string and lower-case string without '0x'

func HexToBytes

func HexToBytes(hex string) []byte

HexToBytes returns byte array of a hex string (with or without '0x')

func IsLatestBlock

func IsLatestBlock(blockNumber int64) bool

IsLatestBlock returns true if blockNumber < 0 and false otherwise.

func NotFoundError

func NotFoundError(err error) bool

NotFoundError checks whether it's a not found error

func ParseTd

func ParseTd(ltd *model.TotalDifficulty) (*big.Int, error)

func Receipt

func Receipt(b *types.Block, receipt *types.Receipt) (*model.Receipt, error)

Receipt converts ethereum transaction receipt to db transaction receipt

func StringToHex

func StringToHex(data string) string

StringToHex returns a hex representation (lower-case string without '0x') of a string

func TotalDifficulty

func TotalDifficulty(b *types.Block, td *big.Int) *model.TotalDifficulty

TotalDifficulty creates a db struct for an ethereum block

func Transaction

func Transaction(b *types.Block, tx *types.Transaction) (*model.Transaction, error)

Transaction converts ethereum transaction to db transaction

Types

This section is empty.

Jump to

Keyboard shortcuts

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