common

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2019 License: LGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrCodeDuplicateKey = 1062
)

Variables

View Source
var (
	// ErrWrongSigner is returned if it's a wrong signer
	ErrWrongSigner = errors.New("wrong signer")
	// ErrInconsistentStates is returned if the number of blocks, dumps or receipts are different
	ErrInconsistentStates = errors.New("inconsistent states")
	// ErrInvalidTD is returned when a block has invalid TD
	ErrInvalidTD = errors.New("invalid TD")
	// ErrInvalidReceiptLog is returned if it's a invalid receipt log
	ErrInvalidReceiptLog = errors.New("invalid receipt log")
	// ErrHasPrevBalance is returned if an account has a previous balance when it's a new subscription
	ErrHasPrevBalance = errors.New("missing previous balance")
	// ErrMissingPrevBalance is returned if an account is missing previous balance when it's an old subscription
	ErrMissingPrevBalance = errors.New("missing previous balance")
	// ErrMissingSubscriptions is returned if an address doesn't belong to any subscription
	ErrMissingSubscriptions = errors.New("missing subscriptions")
)
View Source
var ErrUnknownChain = errors.New("unknown chain")

Functions

func AccumulateRewards added in v0.2.3

func AccumulateRewards(chainConfig *params.ChainConfig, header *types.Header, uncles []*types.Header) (minerBaseReward, uncleInclusionReward *big.Int, uncleCoinbase []common.Address, uncleReward []*big.Int, uncleHash []common.Hash)

AccumulateRewards credits the coinbase of the given block with the mining reward. The total reward consists of the static block reward and rewards for included uncles. The coinbase of each uncle block is also rewarded.

**COPIED FROM**: github.com/ethereum/go-ethereum/consensus/ethash/consensus.go#accumulateRewards()

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.Transfer

EthTransferEvent converts eth transfer log to eth tranfer event

func GetChain added in v0.3.1

func GetChain(chain Chain) (*params.ChainConfig, error)

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(chain *params.ChainConfig, b *types.Block, tx *types.Transaction) (*model.Transaction, error)

Transaction converts ethereum transaction to db transaction

Types

type Chain added in v0.3.1

type Chain int

Chain represents the chain type

const (
	// MainChain represents the main chain config
	MainChain Chain = iota
	// TestChain represents the test chain config
	TestChain
	// RopstenChain represents the ropsten chain config
	RopstenChain
)

Jump to

Keyboard shortcuts

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