common

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: GPL-3.0 Imports: 21 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Big0   = big.NewInt(0)
	Big1   = big.NewInt(1)
	Big2   = big.NewInt(2)
	Big3   = big.NewInt(3)
	Big32  = big.NewInt(32)
	Big256 = big.NewInt(256)
	Big257 = big.NewInt(257)
)

Functions

This section is empty.

Types

type ChainHighestBlock

type ChainHighestBlock struct {
	Block    block.Block
	Inserted bool
}

type ChainStateReader

type ChainStateReader interface {
	BalanceAt(ctx context.Context, account types.Address, blockNumber uint256.Int) (uint256.Int, error)
	StorageAt(ctx context.Context, account types.Address, key types.Hash, blockNumber uint256.Int) ([]byte, error)
	CodeAt(ctx context.Context, account types.Address, blockNumber uint256.Int) ([]byte, error)
	NonceAt(ctx context.Context, account types.Address, blockNumber uint256.Int) (uint64, error)
}

type ConnHandler

type ConnHandler func([]byte, peer.ID) error

type DownloaderFinishEvent

type DownloaderFinishEvent struct{}

DownloaderFinishEvent finish download

type DownloaderStartEvent

type DownloaderStartEvent struct{}

DownloaderStartEvent start download

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 IBlockChain

type IBlockChain interface {
	IHeaderChain
	Config() *params.ChainConfig
	CurrentBlock() block.IBlock
	Blocks() []block.IBlock
	Start() error
	GenesisBlock() block.IBlock
	NewBlockHandler(payload []byte, peer peer.ID) error
	InsertChain(blocks []block.IBlock) (int, error)
	InsertBlock(blocks []block.IBlock, isSync bool) (int, error)
	SetEngine(engine consensus.Engine)
	GetBlocksFromHash(hash types.Hash, n int) (blocks []block.IBlock)
	SealedBlock(b block.IBlock) error
	Engine() consensus.Engine
	GetReceipts(blockHash types.Hash) (block.Receipts, error)
	GetLogs(blockHash types.Hash) ([][]*block.Log, error)
	SetHead(head uint64) error
	AddFutureBlock(block block.IBlock) error

	GetHeader(types.Hash, *uint256.Int) block.IHeader
	// alias for GetBlocksFromHash?
	GetBlock(hash types.Hash, number uint64) block.IBlock
	StateAt(tx kv.Tx, blockNr uint64) *state.IntraBlockState

	GetTd(hash types.Hash, number *uint256.Int) *uint256.Int
	HasBlock(hash types.Hash, number uint64) bool

	DB() kv.RwDB
	Quit() <-chan struct{}

	Close() error

	WriteBlockWithState(block block.IBlock, receipts []*block.Receipt, ibs *state.IntraBlockState, nopay map[types.Address]*uint256.Int) error

	GetDepositInfo(address types.Address) (*uint256.Int, *uint256.Int)
	GetAccountRewardUnpaid(account types.Address) (*uint256.Int, error)
}

type IDownloader

type IDownloader interface {
	SyncHeader() error
	SyncBody() error
	SyncTx() error
	Start() error
	Close() error
	IsDownloading() bool
	ConnHandler([]byte, peer.ID) error
}

type IHeaderChain

type IHeaderChain interface {
	GetHeaderByNumber(number *uint256.Int) block.IHeader
	GetHeaderByHash(h types.Hash) (block.IHeader, error)
	InsertHeader(headers []block.IHeader) (int, error)
	GetBlockByHash(h types.Hash) (block.IBlock, error)
	GetBlockByNumber(number *uint256.Int) (block.IBlock, error)
}

type IMiner

type IMiner interface {
	Start()
	PendingBlockAndReceipts() (block.IBlock, block.Receipts)
}

type INetwork

type INetwork interface {
	WriterMessage(messageType message.MessageType, payload []byte, peer peer.ID) error
	//BroadcastMessage(messageType message.MessageType, payload []byte) (int, error)
	SetHandler(message.MessageType, ConnHandler) error
	ClosePeer(id peer.ID) error
	Start() error
	Host() host.Host
	PeerCount() int
	Bootstrapped() bool
}

type IPeer

type IPeer interface {
	ID() peer.ID
	Write(msg message.IMessage) error
	WriteMsg(messageType message.MessageType, payload []byte) error
	SetHandler(message.MessageType, ConnHandler) error
	ClearHandler(message.MessageType) error
	Close() error
}

type IPubSub

type IPubSub interface {
	JoinTopic(topic string) (*pubsub.Topic, error)
	Publish(topic string, msg proto.Message) error
	GetTopics() []string
	Start() error
}

type IStateDB

type IStateDB interface {
	CreateAccount(types.Address)

	SubBalance(addr types.Address, amount uint256.Int)
	AddBalance(addr types.Address, amount uint256.Int)
	GetBalance(addr types.Address) uint256.Int

	GetNonce(addr types.Address) uint64
	SetNonce(addr types.Address, nonce uint64)

	GetCodeHash(addr types.Address) types.Hash
	GetCode(addr types.Address) []byte
	SetCode(addr types.Address, code []byte)
	GetCodeSize(addr types.Address) int

	AddRefund(uint64)
	SubRefund(uint64)
	GetRefund() uint64

	GetCommittedState(types.Address, types.Hash) types.Hash
	GetState(types.Address, types.Hash) types.Hash
	SetState(types.Address, types.Hash, types.Hash)

	Suicide(types.Address) bool
	HasSuicided(types.Address) bool

	Exist(types.Address) bool
	Empty(types.Address) bool

	PrepareAccessList(sender types.Address, dest *types.Address, precompiles []types.Address, list transaction.AccessList)
	AddressInAccessList(addr types.Address) bool
	SlotInAccessList(addr types.Address, slot types.Hash) (addressOk bool, slotOk bool)
	AddAddressToAccessList(addr types.Address)
	AddSlotToAccessList(addr types.Address, slot types.Hash)

	RevertToSnapshot(int)
	Snapshot() int

	AddLog(*block.Log)
	GetLogs(hash types.Hash, blockHash types.Hash) []*block.Log

	TxIndex() int
	Prepare(thash types.Hash, ti int)

	Error() error
}

type ITxsPool added in v0.1.2

type ITxsPool interface {
	Service
	Has(hash types.Hash) bool
	Pending(enforceTips bool) map[types.Address][]*transaction.Transaction
	GetTransaction() ([]*transaction.Transaction, error)
	GetTx(hash types.Hash) *transaction.Transaction
	AddRemotes(txs []*transaction.Transaction) []error
	AddLocal(tx *transaction.Transaction) error
	Stats() (int, int, int, int)
	Nonce(addr types.Address) uint64
	Content() (map[types.Address][]*transaction.Transaction, map[types.Address][]*transaction.Transaction)
}

type MinedEntireEvent

type MinedEntireEvent struct {
	Entire state.EntireCode
}

type NewLocalTxsEvent

type NewLocalTxsEvent struct{ Txs []*transaction.Transaction }

NewLocalTxsEvent local txs

type NewLogsEvent

type NewLogsEvent struct{ Logs []*block.Log }

NewLogsEvent new logs

type NewPendingLogsEvent

type NewPendingLogsEvent struct{ Logs []*block.Log }

NewPendingLogsEvent is posted when a reorg happens // todo miner v2

type NewTxsEvent

type NewTxsEvent struct{ Txs []*transaction.Transaction }

NewTxsEvent txs

type Peer

type Peer struct {
	IPeer
	CurrentHeight *uint256.Int
	AddTimer      time.Time
}

type PeerDropEvent

type PeerDropEvent struct{ Peer peer.ID }

PeerDropEvent Peer drop

type PeerJoinEvent

type PeerJoinEvent struct{ Peer peer.ID }

PeerJoinEvent Peer join

type PeerMap

type PeerMap map[peer.ID]Peer

func (PeerMap) ToSlice

func (pm PeerMap) ToSlice() PeerSet

type PeerSet

type PeerSet []Peer

func (PeerSet) Len

func (ps PeerSet) Len() int

func (PeerSet) Less

func (ps PeerSet) Less(i, j int) bool

func (PeerSet) Swap

func (ps PeerSet) Swap(i, j int)

type PrettyAge

type PrettyAge time.Time

PrettyAge is a pretty printed version of a time.Duration value that rounds the values up to a single most significant unit, days/weeks/years included.

func (PrettyAge) String

func (t PrettyAge) String() string

String implements the Stringer interface, allowing pretty printing of duration values rounded to the most significant time unit.

type PrettyDuration

type PrettyDuration time.Duration

PrettyDuration is a pretty printed version of a time.Duration value that cuts the unnecessary precision off from the formatted textual representation.

func (PrettyDuration) String

func (d PrettyDuration) String() string

String implements the Stringer interface, allowing pretty printing of duration values rounded to three decimals.

type ProtocolHandshakeFn

type ProtocolHandshakeFn func(peer IPeer, genesisHash types.Hash, currentHeight *uint256.Int) (Peer, bool)

type ProtocolHandshakeInfo

type ProtocolHandshakeInfo func() (types.Hash, *uint256.Int, error)

type RemovedLogsEvent

type RemovedLogsEvent struct{ Logs []*block.Log }

RemovedLogsEvent is posted when a reorg happens // todo blockchain v2

type Service added in v0.1.2

type Service interface {
	// Start spawns any goroutines required by the service.
	//Start()
	// Stop terminates all goroutines belonging to the service,
	// blocking until they are all terminated.
	Stop() error
}

Service is a struct that can be registered into a ServiceRegistry for easy dependency management.

Directories

Path Synopsis
blake2b
Package blake2b implements the BLAKE2b hash algorithm defined by RFC 7693 and the extendable output function (XOF) BLAKE2Xb.
Package blake2b implements the BLAKE2b hash algorithm defined by RFC 7693 and the extendable output function (XOF) BLAKE2Xb.
bls
Package bls implements a go-wrapper around a library implementing the the BLS12-381 curve and signature scheme.
Package bls implements a go-wrapper around a library implementing the the BLS12-381 curve and signature scheme.
bls/blst
Package blst implements a go-wrapper around a library implementing the the BLS12-381 curve and signature scheme.
Package blst implements a go-wrapper around a library implementing the the BLS12-381 curve and signature scheme.
bls/common
Package common provides the BLS interfaces that are implemented by the various BLS wrappers.
Package common provides the BLS interfaces that are implemented by the various BLS wrappers.
bn256
Package bn256 implements the Optimal Ate pairing over a 256-bit Barreto-Naehrig curve.
Package bn256 implements the Optimal Ate pairing over a 256-bit Barreto-Naehrig curve.
bn256/cloudflare
Package bn256 implements a particular bilinear group at the 128-bit security level.
Package bn256 implements a particular bilinear group at the 128-bit security level.
bn256/google
Package bn256 implements a particular bilinear group.
Package bn256 implements a particular bilinear group.
rand
Package rand defines methods of obtaining random number generators.
Package rand defines methods of obtaining random number generators.
Package hexutil implements hex encoding with 0x prefix.
Package hexutil implements hex encoding with 0x prefix.
Package math provides integer math utilities.
Package math provides integer math utilities.
Package mclock is a wrapper for a monotonic clock source
Package mclock is a wrapper for a monotonic clock source
Package prque implements a priority queue data structure supporting arbitrary value types and int64 priorities.
Package prque implements a priority queue data structure supporting arbitrary value types and int64 priorities.
ssz

Jump to

Keyboard shortcuts

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