common

package
v0.0.0-...-7833c67 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: GPL-3.0 Imports: 21 Imported by: 0

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

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

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.
csidh
Package csidh implements commutative supersingular isogeny-based Diffie-Hellman key exchange algorithm (CSIDH) resulting from the group action.
Package csidh implements commutative supersingular isogeny-based Diffie-Hellman key exchange algorithm (CSIDH) resulting from the group action.
dilithium
dilithium implements the CRYSTALS-Dilithium signature schemes as submitted to round3 of the NIST PQC competition and described in
dilithium implements the CRYSTALS-Dilithium signature schemes as submitted to round3 of the NIST PQC competition and described in
dilithium/mode2
mode2 implements the CRYSTALS-Dilithium signature scheme Dilithium2 as submitted to round3 of the NIST PQC competition and described in
mode2 implements the CRYSTALS-Dilithium signature scheme Dilithium2 as submitted to round3 of the NIST PQC competition and described in
dilithium/mode2aes
mode2aes implements the CRYSTALS-Dilithium signature scheme Dilithium2-AES as submitted to round3 of the NIST PQC competition and described in
mode2aes implements the CRYSTALS-Dilithium signature scheme Dilithium2-AES as submitted to round3 of the NIST PQC competition and described in
dilithium/mode3
mode3 implements the CRYSTALS-Dilithium signature scheme Dilithium3 as submitted to round3 of the NIST PQC competition and described in
mode3 implements the CRYSTALS-Dilithium signature scheme Dilithium3 as submitted to round3 of the NIST PQC competition and described in
dilithium/mode3aes
mode3aes implements the CRYSTALS-Dilithium signature scheme Dilithium3-AES as submitted to round3 of the NIST PQC competition and described in
mode3aes implements the CRYSTALS-Dilithium signature scheme Dilithium3-AES as submitted to round3 of the NIST PQC competition and described in
dilithium/mode5
mode5 implements the CRYSTALS-Dilithium signature scheme Dilithium5 as submitted to round3 of the NIST PQC competition and described in
mode5 implements the CRYSTALS-Dilithium signature scheme Dilithium5 as submitted to round3 of the NIST PQC competition and described in
dilithium/mode5aes
mode5aes implements the CRYSTALS-Dilithium signature scheme Dilithium5-AES as submitted to round3 of the NIST PQC competition and described in
mode5aes implements the CRYSTALS-Dilithium signature scheme Dilithium5-AES as submitted to round3 of the NIST PQC competition and described in
keccakf1600
Package keccakf1600 provides a two and four-way Keccak-f[1600] permutation in parallel.
Package keccakf1600 provides a two and four-way Keccak-f[1600] permutation in parallel.
kem
Package kem provides a unified interface for KEM schemes.
Package kem provides a unified interface for KEM schemes.
kem/frodo
Package frodo provides the key encapsulation mechanism FrodoKEM.
Package frodo provides the key encapsulation mechanism FrodoKEM.
kem/frodo/frodo640shake
Package frodo640shake implements the variant FrodoKEM-640 with SHAKE.
Package frodo640shake implements the variant FrodoKEM-640 with SHAKE.
kem/kyber
Package kyber implements the CRYSTALS-Kyber.CCAKEM IND-CCA2 secure key encapsulation mechanism (KEM) as submitted to round 3 of the NIST PQC competition and described in
Package kyber implements the CRYSTALS-Kyber.CCAKEM IND-CCA2 secure key encapsulation mechanism (KEM) as submitted to round 3 of the NIST PQC competition and described in
kem/kyber/kyber1024
Package kyber1024 implements the IND-CCA2 secure key encapsulation mechanism Kyber1024.CCAKEM as submitted to round 3 of the NIST PQC competition and described in
Package kyber1024 implements the IND-CCA2 secure key encapsulation mechanism Kyber1024.CCAKEM as submitted to round 3 of the NIST PQC competition and described in
kem/kyber/kyber512
Package kyber512 implements the IND-CCA2 secure key encapsulation mechanism Kyber512.CCAKEM as submitted to round 3 of the NIST PQC competition and described in
Package kyber512 implements the IND-CCA2 secure key encapsulation mechanism Kyber512.CCAKEM as submitted to round 3 of the NIST PQC competition and described in
kem/kyber/kyber768
Package kyber768 implements the IND-CCA2 secure key encapsulation mechanism Kyber768.CCAKEM as submitted to round 3 of the NIST PQC competition and described in
Package kyber768 implements the IND-CCA2 secure key encapsulation mechanism Kyber768.CCAKEM as submitted to round 3 of the NIST PQC competition and described in
kyber/kyber512
kyber512 implements the IND-CPA-secure Public Key Encryption scheme Kyber512.CPAPKE as submitted to round 3 of the NIST PQC competition and described in
kyber512 implements the IND-CPA-secure Public Key Encryption scheme Kyber512.CPAPKE as submitted to round 3 of the NIST PQC competition and described in
pke
Package pke provides a variety of public key encryption mechanisms.
Package pke provides a variety of public key encryption mechanisms.
pke/kyber
Package kyber implements the CRYSTALS-Kyber.CPAPKE public key encryption as submitted to round 3 of the NIST PQC competition and described in
Package kyber implements the CRYSTALS-Kyber.CPAPKE public key encryption as submitted to round 3 of the NIST PQC competition and described in
pke/kyber/kyber1024
kyber1024 implements the IND-CPA-secure Public Key Encryption scheme Kyber1024.CPAPKE as submitted to round 3 of the NIST PQC competition and described in
kyber1024 implements the IND-CPA-secure Public Key Encryption scheme Kyber1024.CPAPKE as submitted to round 3 of the NIST PQC competition and described in
pke/kyber/kyber512
kyber512 implements the IND-CPA-secure Public Key Encryption scheme Kyber512.CPAPKE as submitted to round 3 of the NIST PQC competition and described in
kyber512 implements the IND-CPA-secure Public Key Encryption scheme Kyber512.CPAPKE as submitted to round 3 of the NIST PQC competition and described in
pke/kyber/kyber768
kyber768 implements the IND-CPA-secure Public Key Encryption scheme Kyber768.CPAPKE as submitted to round 3 of the NIST PQC competition and described in
kyber768 implements the IND-CPA-secure Public Key Encryption scheme Kyber768.CPAPKE as submitted to round 3 of the NIST PQC competition and described in
rand
Package rand defines methods of obtaining random number generators.
Package rand defines methods of obtaining random number generators.
sha3
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202.
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202.
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