types

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2019 License: LGPL-3.0 Imports: 22 Imported by: 0

Documentation

Overview

Package types contains data types related to Fractal consensus.

Package types contains data types related to Fractal consensus.

Index

Constants

View Source
const (
	// BloomByteLength represents the number of bytes used in a log bloom.
	BloomByteLength = 4096

	// BloomBitLength represents the number of bits used in a log bloom.
	BloomBitLength = 8 * BloomByteLength
)
View Source
const (
	// ReceiptStatusFailed is the status code of a transaction if execution failed.
	ReceiptStatusFailed = uint64(0)

	// ReceiptStatusSuccessful is the status code of a transaction if execution succeeded.
	ReceiptStatusSuccessful = uint64(1)
)
View Source
const NotInPackage uint32 = math.MaxUint32

If a transaction not in txPackage, the TxPackageIndex is NotInPackage.

Variables

View Source
var (
	// ErrGasLimitReached is returned by the gas pool if the amount of gas required
	// by a transaction is higher than what's left in the block.
	ErrGasLimitReached = errors.New("gas limit reached")
)
View Source
var (
	ErrInvalidChainId = errors.New("invalid chain id for signer")
)
View Source
var (
	ErrInvalidPkgSig = errors.New("invalid transaction package v, r, s values")
)
View Source
var (
	ErrInvalidSig = errors.New("invalid transaction v, r, s values")
)
View Source
var ErrMapNotFoundInCache = errors.New("map not found in cache")

Functions

func BloomLookup

func BloomLookup(bin *Bloom, topic bytesBacked) bool

func CalcGasLimit

func CalcGasLimit(parent *Block) uint64

CalcGasLimit computes the gas limit of the next block after parent. This is miner strategy, not consensus protocol.

func DeriveSha

func DeriveSha(list DerivableList) common.Hash

func LogsBloom

func LogsBloom(logs []*Log) *big.Int

func Sender

func Sender(signer Signer, tx *Transaction) (common.Address, error)

Sender returns the address derived from the signature (V, R, S) using secp256k1 elliptic curve and an error if it failed deriving or upon an incorrect signature.

Sender may cache the address, allowing it to be used regardless of signing method. The cache is invalidated if the cached signer does not match the signer used in the current call.

Types

type Block

type Block struct {
	// contents
	Header BlockHeader
	Body   BlockBody

	// whether the block state has been checked
	StateChecked BlockStateCheckedEnum

	//
	ReceivedAt   time.Time
	ReceivedFrom interface{}
	ReceivedPath BlockReceivePathEnum
	// contains filtered or unexported fields
}

Block represents a block in the Fractal blockchain.

func NewBlock

func NewBlock(parentHash common.Hash, round uint64,
	sig []byte, coinbase common.Address, difficulty *big.Int, height uint64) *Block

func NewBlockWithHeader

func NewBlockWithHeader(header *BlockHeader) *Block

func (*Block) Bloom

func (b *Block) Bloom() *Bloom

func (*Block) CacheBloom

func (b *Block) CacheBloom(bloom *Bloom)

func (*Block) CompareByHeightAndRoundAndSimpleHash

func (b *Block) CompareByHeightAndRoundAndSimpleHash(b2 *Block) int

return 1 if b is better then b2

func (*Block) CompareByRoundAndSimpleHash

func (b *Block) CompareByRoundAndSimpleHash(b2 *Block) int

return 1 if b2 is behind b

func (*Block) DecodeRLP

func (b *Block) DecodeRLP(s *rlp.Stream) error

DecodeRLP decodes the fractal block

func (*Block) EncodeRLP

func (b *Block) EncodeRLP(w io.Writer) error

EncodeRLP serializes block into the RLP format.

func (*Block) FullHash

func (b *Block) FullHash() common.Hash

Hash returns the keccak256 hash of full block. The hash is computed on the first call and cached thereafter.

func (*Block) MarshalJSON

func (b *Block) MarshalJSON() ([]byte, error)

Serialize block to json format

func (*Block) SignHashByte

func (b *Block) SignHashByte() []byte

func (*Block) SimpleHash

func (b *Block) SimpleHash() common.Hash

Hash returns the keccak256 hash of block's consensus part. The hash is computed on the first call and cached thereafter.

type BlockBody

type BlockBody struct {
	Transactions    []*Transaction `json:"transactions"     gencodec:"required"`
	TxPackageHashes []common.Hash  `json:"txpackages"     gencodec:"required"`
}

BlockHeader represents the body of a block in the Fractal blockchain

type BlockExecutedEvent

type BlockExecutedEvent struct{ Block *Block }

type BlockHeader

type BlockHeader struct {
	ParentHash     common.Hash    `json:"parentHash"       gencodec:"required"`
	Round          uint64         `json:"round"            gencodec:"required"`
	Sig            []byte         `json:"sig"              gencodec:"required"`
	Coinbase       common.Address `json:"miner"            gencodec:"required"`
	Difficulty     *big.Int       `json:"difficulty"       gencodec:"required"`
	Height         uint64         `json:"height"           gencodec:"required"`
	Amount         uint64         `json:"amount"           gencodec:"required"`
	GasLimit       uint64         `json:"gasLimit"         gencodec:"required"`
	GasUsed        uint64         `json:"gasUsed"          gencodec:"required"`
	StateHash      common.Hash    `json:"stateHash"        gencodec:"required"`
	TxHash         common.Hash    `json:"txHash"           gencodec:"required"`
	ReceiptHash    common.Hash    `json:"receiptsRoot"     gencodec:"required"`
	ParentFullHash common.Hash    `json:"parentFullHash"   gencodec:"required"`
	Confirms       []common.Hash  `json:"confirms"         gencodec:"required"`
	FullSig        []byte         `json:"fullSig"          gencodec:"required"`
	MinedTime      uint64         `json:"minedTime"        gencodec:"required"`
	HopCount       uint64         `json:"hopCount"         gencodec:"required"`
}

BlockHeader represents the header of a block in the Fractal blockchain

func (*BlockHeader) FullHash

func (bh *BlockHeader) FullHash() common.Hash

Hash returns the keccak256 hash of full block. The hash is computed on the first call and cached thereafter.

func (*BlockHeader) SimpleHash

func (bh *BlockHeader) SimpleHash() common.Hash

type BlockReceivePathEnum

type BlockReceivePathEnum byte
const (
	BlockNull BlockReceivePathEnum = iota
	BlockFastSync
	BlockMined
)

type BlockRoundHash

type BlockRoundHash struct {
	Round      uint64
	SimpleHash common.Hash
	FullHash   common.Hash
}

type for block complex index

type BlockRoundHashes

type BlockRoundHashes []*BlockRoundHash

type for block index list

func (*BlockRoundHashes) SortByRoundHash

func (list *BlockRoundHashes) SortByRoundHash()

sort blocks by round

type BlockStateCheckedEnum

type BlockStateCheckedEnum byte
const (
	NoBlockState BlockStateCheckedEnum = iota
	HasBlockStateButNotChecked
	BlockStateChecked
)

type Blocks

type Blocks []*Block

type for block array

func (*Blocks) Copy

func (blocks *Blocks) Copy() Blocks

func (*Blocks) Has

func (blocks *Blocks) Has(hash common.Hash) bool

func (*Blocks) Remove

func (blocks *Blocks) Remove(hash common.Hash)

remove block from array

func (*Blocks) SortByRoundHash

func (blocks *Blocks) SortByRoundHash()

sort blocks by round

type Bloom

type Bloom [BloomByteLength]byte

Bloom represents a 32768 bit bloom filter.

func BytesToBloom

func BytesToBloom(b []byte) *Bloom

BytesToBloom converts a byte slice to a bloom filter. It panics if b is not of suitable size.

func CreateBloom

func CreateBloom(receipts Receipts) *Bloom

func (*Bloom) Add

func (b *Bloom) Add(d *big.Int)

Add adds d to the filter. Future calls of Test(d) will return true.

func (*Bloom) Big

func (b *Bloom) Big() *big.Int

Big converts b to a big integer.

func (*Bloom) Bytes

func (b *Bloom) Bytes() []byte

func (*Bloom) Count

func (b *Bloom) Count() int

number of binary "1"

func (Bloom) MarshalText

func (b Bloom) MarshalText() ([]byte, error)

MarshalText encodes b as a hex string with 0x prefix.

func (*Bloom) SetBytes

func (b *Bloom) SetBytes(d []byte)

SetBytes sets the content of b to the given bytes. It panics if d is not of suitable size.

func (*Bloom) UnmarshalText

func (b *Bloom) UnmarshalText(input []byte) error

UnmarshalText b as a hex string with 0x prefix.

type ChainUpdateEvent

type ChainUpdateEvent struct{ Block *Block }

type DerivableList

type DerivableList interface {
	Len() int
	GetRlp(i int) []byte
}

type EIP155Signer

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

EIP155Transaction implements Signer using the EIP155 rules.

func NewEIP155Signer

func NewEIP155Signer(chainId uint64) EIP155Signer

func (EIP155Signer) Equal

func (s EIP155Signer) Equal(s2 Signer) bool

func (EIP155Signer) Hash

func (s EIP155Signer) Hash(tx *Transaction) common.Hash

Hash returns the hash to be signed by the sender. It does not uniquely identify the transaction.

func (EIP155Signer) Sender

func (s EIP155Signer) Sender(tx *Transaction) (common.Address, error)

func (EIP155Signer) SignatureValues

func (s EIP155Signer) SignatureValues(tx *Transaction, sig []byte) (R, S, V *big.Int, err error)

WithSignature returns a new transaction with the given signature. This signature needs to be in the [R || S || V] format where V is 0 or 1.

type FakeSigner

type FakeSigner struct{}

FakeSigner for test

func NewFakeSigner

func NewFakeSigner() FakeSigner

func (FakeSigner) Equal

func (s FakeSigner) Equal(s2 Signer) bool

func (FakeSigner) Hash

func (s FakeSigner) Hash(tx *Transaction) common.Hash

Hash returns the hash to be signed by the sender. It does not uniquely identify the transaction.

func (FakeSigner) Sender

func (s FakeSigner) Sender(tx *Transaction) (common.Address, error)

func (FakeSigner) SignatureValues

func (s FakeSigner) SignatureValues(tx *Transaction, sig []byte) (R, S, V *big.Int, err error)

WithSignature returns a new transaction with the given signature. This signature needs to be in the [R || S || V] format where V is 0 or 1.

type FrontierSigner

type FrontierSigner struct{}

func (FrontierSigner) Equal

func (s FrontierSigner) Equal(s2 Signer) bool

func (FrontierSigner) Hash

func (fs FrontierSigner) Hash(tx *Transaction) common.Hash

Hash returns the hash to be signed by the sender. It does not uniquely identify the transaction.

func (FrontierSigner) Sender

func (fs FrontierSigner) Sender(tx *Transaction) (common.Address, error)

func (FrontierSigner) SignatureValues

func (fs FrontierSigner) SignatureValues(tx *Transaction, sig []byte) (r, s, v *big.Int, err error)

SignatureValues returns signature values. This signature needs to be in the [R || S || V] format where V is 0 or 1.

type GasPool

type GasPool uint64

GasPool tracks the amount of gas available during execution of the transactions in a block. The zero value is a pool with zero gas available.

func (*GasPool) AddGas

func (gp *GasPool) AddGas(amount uint64) *GasPool

AddGas makes gas available for execution.

func (*GasPool) Gas

func (gp *GasPool) Gas() uint64

Gas returns the amount of gas remaining in the pool.

func (*GasPool) String

func (gp *GasPool) String() string

func (*GasPool) SubGas

func (gp *GasPool) SubGas(amount uint64) error

SubGas deducts the given amount from the pool if enough gas is available and returns an error otherwise.

type Log

type Log struct {
	// Consensus fields:
	// address of the contract that generated the event
	Address common.Address `json:"address" gencodec:"required"`
	// list of topics provided by the contract.
	Topics []common.Hash `json:"topics" gencodec:"required"`
	// supplied by the contract, usually ABI-encoded
	Data []byte `json:"data" gencodec:"required"`

	// Derived fields. These fields are filled in by the node
	// but not secured by consensus.
	// block in which the transaction was included
	BlockNumber uint64 `json:"blockNumber" gencodec:"required"`
	// hash of the transaction
	TxHash common.Hash `json:"transactionHash" gencodec:"required"`
	// index of the package in the block
	PkgIndex uint32 `json:"packageIndex" gencodec:"required"`
	// index of the transaction in the block/package
	TxIndex uint32 `json:"transactionIndex" gencodec:"required"`
	// index of the log in the receipt
	Index uint32 `json:"logIndex" gencodec:"required"`
}

Log represents a contract log event. These events are generated by the WASM function and stored/indexed by the node.

func (*Log) DecodeRLP

func (l *Log) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder.

func (*Log) EncodeRLP

func (l *Log) EncodeRLP(w io.Writer) error

EncodeRLP implements rlp.Encoder.

func (Log) MarshalJSON

func (l Log) MarshalJSON() ([]byte, error)

MarshalJSON marshals as JSON.

func (*Log) UnmarshalJSON

func (l *Log) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

type LogForStorage

type LogForStorage Log

LogForStorage is a wrapper around a Log that flattens and parses the entire content of a log including non-consensus fields.

func (*LogForStorage) DecodeRLP

func (l *LogForStorage) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder.

func (*LogForStorage) EncodeRLP

func (l *LogForStorage) EncodeRLP(w io.Writer) error

EncodeRLP implements rlp.Encoder.

type Message

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

Message is a fully derived transaction and implements types.Message

func NewMessage

func NewMessage(from common.Address, to *common.Address, nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, checkNonce bool) Message

func (Message) CheckNonce

func (m Message) CheckNonce() bool

func (Message) Data

func (m Message) Data() []byte

func (Message) From

func (m Message) From() common.Address

func (Message) Gas

func (m Message) Gas() uint64

func (Message) GasPrice

func (m Message) GasPrice() *big.Int

func (Message) Nonce

func (m Message) Nonce() uint64

func (Message) To

func (m Message) To() *common.Address

func (Message) Value

func (m Message) Value() *big.Int

type NewMinedBlockEvent

type NewMinedBlockEvent struct{ Block *Block }

type NewTxsEvent

type NewTxsEvent struct{ Txs []*Transaction }

NewTxsEvent is posted when a batch of transactions enter the transaction pool.

type PackerECPubKey

type PackerECPubKey [65]byte

type PackerInfo

type PackerInfo struct {
	PackerPubKey PackerECPubKey
	Coinbase     common.Address
	RpcAddress   string // include ip address and port,
}

type PackerInfoMap

type PackerInfoMap struct {
	IndexPackerMap map[uint32]*PackerInfo
	PubKeyIndexMap map[PackerECPubKey]uint32
}

func NewPackerInfoMap

func NewPackerInfoMap() *PackerInfoMap

type PackerInfoMapCache

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

func NewPackerInfoMapCache

func NewPackerInfoMapCache(cacheSize uint8) (*PackerInfoMapCache, error)

func (*PackerInfoMapCache) Get

func (ps *PackerInfoMapCache) Get(blockHash common.Hash) (*PackerInfoMap, error)

func (*PackerInfoMapCache) Put

func (ps *PackerInfoMapCache) Put(blockHash common.Hash, packerInfoMap *PackerInfoMap)

type PkgReceivePath

type PkgReceivePath byte
const (
	PkgReceivePathBegin PkgReceivePath = iota
	PkgReceivePathBroadcast
	PkgReceivePathSync
	PkgReceivePathFuture
	PkgReceivePathEnd
)

func (PkgReceivePath) String

func (p PkgReceivePath) String() string

type PkgSigner

type PkgSigner interface {
	// Sign the txPackage with the given key, and return a new signed package.
	Sign(pkg *TxPackage, key crypto.PrivateKey) (*TxPackage, error)

	// VerifySignature verify the given package's signature
	RecoverPubKey(pkg *TxPackage) ([]byte, error)

	// Hash return the package hash that should be signed.
	Hash(pkg *TxPackage) common.Hash

	// SigToRSV transfer the signature into [r||s||v] format.
	SigToRSV(sig []byte) (r, s, v *big.Int, err error)

	// Equals return if the given signer == this one.
	Equals(signer PkgSigner) bool
}

func MakePkgSigner

func MakePkgSigner(fakeMode bool) PkgSigner

func NewDefaultSigner

func NewDefaultSigner() PkgSigner

type Receipt

type Receipt struct {
	// Consensus fields
	PostState         []byte `json:"root"`
	Status            uint64 `json:"status"`
	CumulativeGasUsed uint64 `json:"cumulativeGasUsed" gencodec:"required"`
	Bloom             *Bloom `json:"logsBloom"         gencodec:"required"`
	Logs              []*Log `json:"logs"              gencodec:"required"`

	// Implementation fields (don't reorder!)
	TxHash          common.Hash    `json:"transactionHash" gencodec:"required"`
	ContractAddress common.Address `json:"contractAddress"`
	GasUsed         uint64         `json:"gasUsed" gencodec:"required"`
}

Receipt represents the results of a transaction.

func NewReceipt

func NewReceipt(root []byte, failed bool, cumulativeGasUsed uint64) *Receipt

NewReceipt creates a barebone transaction receipt, copying the init fields.

func (*Receipt) DecodeRLP

func (r *Receipt) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder, and loads the consensus fields of a receipt from an RLP stream.

func (*Receipt) EncodeRLP

func (r *Receipt) EncodeRLP(w io.Writer) error

EncodeRLP implements rlp.Encoder, and flattens the consensus fields of a receipt into an RLP stream. If no post state is present, byzantium fork is assumed.

func (Receipt) MarshalJSON

func (r Receipt) MarshalJSON() ([]byte, error)

MarshalJSON marshals as JSON.

func (*Receipt) UnmarshalJSON

func (r *Receipt) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

type ReceiptForStorage

type ReceiptForStorage Receipt

ReceiptForStorage is a wrapper around a Receipt that flattens and parses the entire content of a receipt, as opposed to only the consensus fields originally.

func (*ReceiptForStorage) DecodeRLP

func (r *ReceiptForStorage) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder, and loads both consensus and implementation fields of a receipt from an RLP stream.

func (*ReceiptForStorage) EncodeRLP

func (r *ReceiptForStorage) EncodeRLP(w io.Writer) error

EncodeRLP implements rlp.Encoder, and flattens all content fields of a receipt into an RLP stream.

type Receipts

type Receipts []*Receipt

Receipts is a wrapper around a Receipt array to implement DerivableList.

func (Receipts) GetRlp

func (r Receipts) GetRlp(i int) []byte

GetRlp returns the RLP encoding of one receipt from the list.

func (Receipts) Len

func (r Receipts) Len() int

Len returns the number of receipts in this list.

type Signer

type Signer interface {
	// Sender returns the sender address of the transaction.
	Sender(tx *Transaction) (common.Address, error)
	// SignatureValues returns the raw R, S, V values corresponding to the
	// given signature.
	SignatureValues(tx *Transaction, sig []byte) (r, s, v *big.Int, err error)
	// Hash returns the hash to be signed.
	Hash(tx *Transaction) common.Hash
	// Equal returns true if the given signer is the same as the receiver.
	Equal(Signer) bool
}

Signer encapsulates transaction signature handling. Note that this interface is not a stable API and may change at any time to accommodate new protocol rules.

func MakeSigner

func MakeSigner(signerType string, chainID uint64) Signer

MakeSigner returns a Signer based on the given chain config and block number.

type Transaction

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

func NewContractCreation

func NewContractCreation(nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, broadcast bool) *Transaction

func NewTransaction

func NewTransaction(nonce uint64, to common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, broadcast bool) *Transaction

func SignTx

func SignTx(tx *Transaction, s Signer, prv crypto.PrivateKey) (*Transaction, error)

SignTx signs the transaction using the given signer and private key

func (*Transaction) AsMessage

func (tx *Transaction) AsMessage(s Signer) (Message, error)

AsMessage returns the transaction as a types.Message.

AsMessage requires a signer to derive the sender.

func (*Transaction) Broadcast

func (tx *Transaction) Broadcast() bool

func (*Transaction) ChainId

func (tx *Transaction) ChainId() *big.Int

ChainId returns which chain id this transaction was signed for (if at all)

func (*Transaction) CheckNonce

func (tx *Transaction) CheckNonce() bool

func (*Transaction) Cost

func (tx *Transaction) Cost() *big.Int

Cost returns amount + gasprice * gaslimit.

func (*Transaction) Data

func (tx *Transaction) Data() []byte

func (*Transaction) DecodeRLP

func (tx *Transaction) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder

func (*Transaction) EncodeRLP

func (tx *Transaction) EncodeRLP(w io.Writer) error

EncodeRLP implements rlp.Encoder

func (*Transaction) Gas

func (tx *Transaction) Gas() uint64

func (*Transaction) GasPrice

func (tx *Transaction) GasPrice() *big.Int

func (*Transaction) Hash

func (tx *Transaction) Hash() common.Hash

Hash hashes the RLP encoding of tx. It uniquely identifies the transaction.

func (*Transaction) MarshalJSON

func (tx *Transaction) MarshalJSON() ([]byte, error)

MarshalJSON encodes the web3 RPC transaction format.

func (*Transaction) MatchPacker

func (tx *Transaction) MatchPacker(packerGroupSize uint64, packerIndex uint32, signer Signer) bool

func (*Transaction) Nonce

func (tx *Transaction) Nonce() uint64

func (*Transaction) PackingHash

func (tx *Transaction) PackingHash(signer Signer) common.Hash

func (*Transaction) PackingHashUint64

func (tx *Transaction) PackingHashUint64(signer Signer) uint64

func (*Transaction) RawSignatureValues

func (tx *Transaction) RawSignatureValues() (*big.Int, *big.Int, *big.Int)

func (*Transaction) SetFrom

func (tx *Transaction) SetFrom(signer Signer, addr common.Address)

func (*Transaction) Size

func (tx *Transaction) Size() common.StorageSize

Size returns the true RLP encoded storage size of the transaction, either by encoding and returning it, or returning a previsouly cached value.

func (*Transaction) To

func (tx *Transaction) To() *common.Address

To returns the recipient address of the transaction. It returns nil if the transaction is a contract creation.

func (*Transaction) UnmarshalJSON

func (tx *Transaction) UnmarshalJSON(input []byte) error

UnmarshalJSON decodes the web3 RPC transaction format.

func (*Transaction) Value

func (tx *Transaction) Value() *big.Int

func (*Transaction) WithSignature

func (tx *Transaction) WithSignature(signer Signer, sig []byte) (*Transaction, error)

WithSignature returns a new transaction with the given signature. This signature is generated by Sign method in the crypto.PrivateKey interface.

type Transactions

type Transactions []*Transaction

Transactions is a Transaction slice type for basic sorting.

func TxDifference

func TxDifference(a, b Transactions) Transactions

TxDifference returns a new set which is the difference between a and b.

func (Transactions) GetRlp

func (s Transactions) GetRlp(i int) []byte

GetRlp implements Rlpable and returns the i'th element of s in rlp.

func (Transactions) Len

func (s Transactions) Len() int

Len returns the length of s.

func (Transactions) Swap

func (s Transactions) Swap(i, j int)

Swap swaps the i'th and the j'th element in s.

type TxByNonce

type TxByNonce Transactions

TxByNonce implements the sort interface to allow sorting a list of transactions by their nonces. This is usually only useful for sorting transactions from a single account, otherwise a nonce comparison doesn't make much sense.

func (TxByNonce) Len

func (s TxByNonce) Len() int

func (TxByNonce) Less

func (s TxByNonce) Less(i, j int) bool

func (TxByNonce) Swap

func (s TxByNonce) Swap(i, j int)

type TxByPrice

type TxByPrice Transactions

TxByPrice implements both the sort and the heap interface, making it useful for all at once sorting as well as individually adding and removing elements.

func (TxByPrice) Len

func (s TxByPrice) Len() int

func (TxByPrice) Less

func (s TxByPrice) Less(i, j int) bool

func (*TxByPrice) Pop

func (s *TxByPrice) Pop() interface{}

func (*TxByPrice) Push

func (s *TxByPrice) Push(x interface{})

func (TxByPrice) Swap

func (s TxByPrice) Swap(i, j int)

type TxPackage

type TxPackage struct {
	ReceivedAt   time.Time
	ReceivedFrom interface{}
	ReceivedPath PkgReceivePath
	// contains filtered or unexported fields
}

func NewTxPackage

func NewTxPackage(packer common.Address, nonce uint64, txs []*Transaction, blockFullHash common.Hash, genTime uint64) *TxPackage

func (*TxPackage) AddTransactions

func (pkg *TxPackage) AddTransactions(txs []*Transaction) []*Transaction

func (*TxPackage) BlockFullHash

func (pkg *TxPackage) BlockFullHash() common.Hash

func (*TxPackage) DecodeRLP

func (pkg *TxPackage) DecodeRLP(s *rlp.Stream) error

func (*TxPackage) EncodeRLP

func (pkg *TxPackage) EncodeRLP(w io.Writer) error

func (*TxPackage) Fork

func (pkg *TxPackage) Fork() *TxPackage

func (*TxPackage) GasPrice

func (pkg *TxPackage) GasPrice() *big.Int

func (*TxPackage) GenTime

func (pkg *TxPackage) GenTime() uint64

func (*TxPackage) Hash

func (pkg *TxPackage) Hash() common.Hash

Hash encode the pkgData with rlp and calc the hash value. This is the unique id of a txPackage.

func (*TxPackage) HopCount

func (pkg *TxPackage) HopCount() uint64

func (*TxPackage) IncreaseHopCount

func (pkg *TxPackage) IncreaseHopCount()

func (*TxPackage) MarshalJSON

func (pkg *TxPackage) MarshalJSON() ([]byte, error)

func (*TxPackage) Nonce

func (pkg *TxPackage) Nonce() uint64

func (*TxPackage) Packer

func (pkg *TxPackage) Packer() common.Address

func (*TxPackage) SetSignature

func (pkg *TxPackage) SetSignature(R, S, V *big.Int)

func (*TxPackage) Signature

func (pkg *TxPackage) Signature() (r *big.Int, s *big.Int, v *big.Int)

func (*TxPackage) Transactions

func (pkg *TxPackage) Transactions() []*Transaction

func (*TxPackage) UnmarshalJSON

func (pkg *TxPackage) UnmarshalJSON(input []byte) error

type TxPackages

type TxPackages []*TxPackage

type for txpkg array

func (*TxPackages) Copy

func (pkgs *TxPackages) Copy() TxPackages

func (*TxPackages) Has

func (pkgs *TxPackages) Has(hash common.Hash) bool

func (*TxPackages) Remove

func (pkgs *TxPackages) Remove(hash common.Hash)

remove txpkg from array

type TxWithIndex

type TxWithIndex struct {
	Tx             *Transaction
	TxPackageIndex uint32 // index in txPackage
	TxIndex        uint32 // index in block
}

Jump to

Keyboard shortcuts

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