core

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateGenesisBlock

func CreateGenesisBlock(balanceAlloc map[string]*big.Int, db *dbstore.DB) *types.Block

Mine the genesis block and do initial balance allocation.

func StartBlockchain

func StartBlockchain(config *config.Config)

Types

type Blockchain

type Blockchain struct {
	LastBlock    *types.Block
	Consensus    consensus.Consensus
	Mutex        *sync.RWMutex
	LastHash     *util.Hash
	BlockchainDb *dbstore.BlockchainDB
	StateDB      *dbstore.StateDB
	Txpool       *txpool.TxPool
	RPCServer    *rpc.RPCServer
	TxProcessor  *executer.TxProcessor
	Signer       *util.Address
	P2PServer    *p2p.P2PServer

	TxpoolCh     chan *types.Transaction
	BlockCh      chan *types.Block
	TxpoolChSize int
	BlockChSize  int

	MineInterrupt     chan bool
	MineInterruptSize int
}

func NewBlockchain

func NewBlockchain(c *config.Config) *Blockchain

NewBlockchain creates a new blockchain with the given config.

func (*Blockchain) AddBlock

func (bc *Blockchain) AddBlock(data []byte, txs []*types.Transaction, mineInterrupt chan bool, signerPrivateKey *ecdsa.PrivateKey) error

AddBlock mines and adds a new block to the blockchain.

func (*Blockchain) AddExternalBlock

func (bc *Blockchain) AddExternalBlock(block *types.Block) error

AddBlock mines and adds a new block to the blockchain.

func (*Blockchain) Current

func (bc *Blockchain) Current() *types.Block

Current returns the current block in the blockchain.

func (*Blockchain) GetBlockByHash

func (bc *Blockchain) GetBlockByHash(h *util.Hash) (*types.Block, error)

GetBlockByHash returns the block with the given block hash.

func (*Blockchain) GetBlockByNumber

func (bc *Blockchain) GetBlockByNumber(b *big.Int) (*types.Block, error)

GetBlockByNumber returns the block with the given block number.

func (*Blockchain) ImportBlockLoop

func (bc *Blockchain) ImportBlockLoop()

func (*Blockchain) RemoveLastBlock

func (bc *Blockchain) RemoveLastBlock()

Jump to

Keyboard shortcuts

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