core

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: May 26, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const PoolSize = 8

Variables

This section is empty.

Functions

func NewBlock

func NewBlock(reward *big.Int, coinbase common.Address, chainDB, mptDB *pebble.DB, txs []*Transaction)

func NewBlock2 added in v1.5.0

func NewBlock2(reward, nonce, diff, prevNum *big.Int, prevHash []byte, coinbase common.Address, chainDB, mptDB *pebble.DB, txs []*Transaction)

func NewGenesisBlock

func NewGenesisBlock(chainDB *pebble.DB)

func PreOrderTraversal added in v1.4.0

func PreOrderTraversal(root *MerkleNode)

func PrintNode added in v1.4.0

func PrintNode(node *MerkleNode)

func PushTxToPool added in v1.4.0

func PushTxToPool(loc []byte, tx *Transaction, txDB *pebble.DB)

func TxIsFull added in v1.4.0

func TxIsFull(txDB *pebble.DB) (bool, []byte)

Types

type Block

type Block struct {
	Header *BlockHeader
	Body   *BlockBody
}

func DeserializeBlock

func DeserializeBlock(b []byte) *Block

func (*Block) Hash added in v1.4.0

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

func (*Block) Serialize

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

type BlockBody

type BlockBody struct {
	Txs []*Transaction
}

type BlockHeader

type BlockHeader struct {
	BlockHash      common.Hash
	PrevBlockHash  common.Hash
	StateTreeRoot  common.Hash
	MerkleTreeRoot common.Hash
	Coinbase       common.Address
	Difficulty     *big.Int
	Number         *big.Int
	Nonce          *big.Int
	Reward         *big.Int
	GasLimit       uint64
	GasUsed        uint64
	Time           uint64
}

type MerkleNode

type MerkleNode struct {
	Left  *MerkleNode
	Right *MerkleNode
	Hash  []byte
}

func NewMerkleNode

func NewMerkleNode(left, right *MerkleNode, tx *Transaction) *MerkleNode

type MerkleTree

type MerkleTree struct {
	RootNode *MerkleNode
}

func NewMerkleTree

func NewMerkleTree(txs []*Transaction) *MerkleTree

type State added in v1.4.0

type State struct {
	Nonce    uint64      // The number of transactions completed by the wallet
	Balance  *big.Int    // Current Account Balance
	Storage  common.Hash // Contract Code Storage Hash
	CodeHash []byte      // Contract Code Hash
}

func DeserializeState added in v1.4.0

func DeserializeState(b []byte) *State

func NewState added in v1.4.0

func NewState() *State

func (*State) Serialize added in v1.4.0

func (s *State) Serialize() []byte

type Transaction

type Transaction struct {
	TxHash    common.Hash
	From      common.Address
	To        common.Address
	Value     *big.Int
	Time      uint64
	PubKey    []byte
	Signature []byte
	State     int
}

func DeserializeTx added in v1.4.0

func DeserializeTx(b []byte) *Transaction

func NewTransaction

func NewTransaction(amount *big.Int, time uint64, from, to common.Address, pubKey []byte) *Transaction

func (*Transaction) Hash added in v1.4.0

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

func (*Transaction) Serialize

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

Jump to

Keyboard shortcuts

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