cpc

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2018 License: GPL-3.0 Imports: 65 Imported by: 0

Documentation

Overview

Package cpc implements the cpchain protocol.

Index

Constants

View Source
const (
	// Protocol messages belonging to eth/62
	StatusMsg          = 0x00
	NewBlockHashesMsg  = 0x01
	TxMsg              = 0x02
	GetBlockHeadersMsg = 0x03
	BlockHeadersMsg    = 0x04
	GetBlockBodiesMsg  = 0x05
	BlockBodiesMsg     = 0x06
	NewBlockMsg        = 0x07

	// Protocol messages belonging to eth/63
	GetNodeDataMsg = 0x0d
	NodeDataMsg    = 0x0e
	GetReceiptsMsg = 0x0f
	ReceiptsMsg    = 0x10
)

eth protocol message codes

View Source
const (
	ErrMsgTooLarge = iota
	ErrDecode
	ErrInvalidMsgCode
	ErrProtocolVersionMismatch
	ErrNetworkIdMismatch
	ErrGenesisBlockMismatch
	ErrNoStatusMsg
	ErrExtraStatusMsg
	ErrSuspendedPeer
)
View Source
const ProtocolMaxMsgSize = 10 * 1024 * 1024 // Maximum cap on the size of a protocol message

Variables

View Source
var DefaultConfig = Config{
	SyncMode:      downloader.FullSync,
	NetworkId:     1,
	LightPeers:    100,
	DatabaseCache: 768,
	TrieCache:     256,
	TrieTimeout:   60 * time.Minute,
	GasPrice:      big.NewInt(18 * configs.Shannon),

	TxPool: core.DefaultTxPoolConfig,
	GPO: gasprice.Config{
		Blocks:     20,
		Percentile: 60,
	},
	Admission: admission.DefaultConfig,
	PrivateTx: private.DefaultConfig(),
}

DefaultConfig contains default settings for use on the cpchain main net.

View Source
var ProtocolLengths = []uint64{80}

ProtocolLengths are the number of implemented message corresponding to different protocol versions.

View Source
var ProtocolName = "cpc"

ProtocolName is the official short name of the protocol used during capability negotiation.

View Source
var ProtocolVersions = []uint{cconfigs.Cpc1}

ProtocolVersions are the versions of the cpchain protocol (first is primary).

Functions

func CreateDB

func CreateDB(ctx *node.ServiceContext, config *Config, name string) (database.Database, error)

CreateDB creates the chain database.

func NewBloomIndexer

func NewBloomIndexer(db database.Database, size uint64) *core.ChainIndexer

NewBloomIndexer returns a chain indexer that generates bloom bits data for the canonical chain for fast logs filtering.

Types

type APIBackend

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

APIBackend implements cpcapi.Backend for full nodes

func (*APIBackend) AccountManager

func (b *APIBackend) AccountManager() *accounts.Manager

func (*APIBackend) BlockByNumber

func (b *APIBackend) BlockByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Block, error)

func (*APIBackend) BloomStatus

func (b *APIBackend) BloomStatus() (uint64, uint64)

func (*APIBackend) CalcRptInfo

func (b *APIBackend) CalcRptInfo(address common.Address, blockNum uint64) int64

func (*APIBackend) ChainConfig

func (b *APIBackend) ChainConfig() *configs.ChainConfig

ChainConfig returns the active chain configuration.

func (*APIBackend) ChainDb

func (b *APIBackend) ChainDb() database.Database

func (*APIBackend) CommitteMember

func (b *APIBackend) CommitteMember() []common.Address

CommitteMember return current committe

func (*APIBackend) CurrentBlock

func (b *APIBackend) CurrentBlock() *types.Block

func (*APIBackend) CurrentTerm

func (b *APIBackend) CurrentTerm() uint64

CurrentTerm return current term

func (*APIBackend) CurrentView

func (b *APIBackend) CurrentView() uint64

CurrentView return current view

func (*APIBackend) Downloader

func (b *APIBackend) Downloader() *downloader.Downloader

func (*APIBackend) EventMux

func (b *APIBackend) EventMux() *event.TypeMux

func (*APIBackend) GetBlock

func (b *APIBackend) GetBlock(ctx context.Context, hash common.Hash) (*types.Block, error)

func (*APIBackend) GetEVM

func (b *APIBackend) GetEVM(ctx context.Context, msg core.Message, state *state.StateDB, header *types.Header, vmCfg vm.Config) (*vm.EVM, func() error, error)

func (*APIBackend) GetLogs

func (b *APIBackend) GetLogs(ctx context.Context, hash common.Hash) ([][]*types.Log, error)

func (*APIBackend) GetPoolNonce

func (b *APIBackend) GetPoolNonce(ctx context.Context, addr common.Address) (uint64, error)

func (*APIBackend) GetPoolTransaction

func (b *APIBackend) GetPoolTransaction(hash common.Hash) *types.Transaction

func (*APIBackend) GetPoolTransactions

func (b *APIBackend) GetPoolTransactions() (types.Transactions, error)

func (*APIBackend) GetPrivateReceipt

func (b *APIBackend) GetPrivateReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)

func (*APIBackend) GetReceipts

func (b *APIBackend) GetReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error)

func (*APIBackend) GetTd

func (b *APIBackend) GetTd(blockHash common.Hash) *big.Int

func (*APIBackend) HeaderByNumber

func (b *APIBackend) HeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Header, error)

func (*APIBackend) ProtocolVersion

func (b *APIBackend) ProtocolVersion() int

func (*APIBackend) RNode

func (b *APIBackend) RNode() ([]common.Address, uint64)

RNode returns current RNode information

func (*APIBackend) RemoteDB

func (b *APIBackend) RemoteDB() database.RemoteDatabase

RemoteDB returns remote database instance.

func (*APIBackend) SendTx

func (b *APIBackend) SendTx(ctx context.Context, signedTx *types.Transaction) error

func (*APIBackend) ServiceFilter

func (b *APIBackend) ServiceFilter(ctx context.Context, session *bloombits.MatcherSession)

func (*APIBackend) SetHead

func (b *APIBackend) SetHead(number uint64)

func (*APIBackend) StateAndHeaderByNumber

func (b *APIBackend) StateAndHeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber, isPrivate bool) (*state.StateDB, *types.Header, error)

func (*APIBackend) Stats

func (b *APIBackend) Stats() (pending int, queued int)

func (*APIBackend) SubscribeChainEvent

func (b *APIBackend) SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription

func (*APIBackend) SubscribeChainHeadEvent

func (b *APIBackend) SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription

func (*APIBackend) SubscribeChainSideEvent

func (b *APIBackend) SubscribeChainSideEvent(ch chan<- core.ChainSideEvent) event.Subscription

func (*APIBackend) SubscribeLogsEvent

func (b *APIBackend) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscription

func (*APIBackend) SubscribeNewTxsEvent

func (b *APIBackend) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) event.Subscription

func (*APIBackend) SubscribeRemovedLogsEvent

func (b *APIBackend) SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent) event.Subscription

func (*APIBackend) SuggestPrice

func (b *APIBackend) SuggestPrice(ctx context.Context) (*big.Int, error)

func (*APIBackend) TermLen

func (b *APIBackend) TermLen() uint64

TermLen return current TermLen

func (*APIBackend) TxPoolContent

func (b *APIBackend) TxPoolContent() (map[common.Address]types.Transactions, map[common.Address]types.Transactions)

func (*APIBackend) ViewLen

func (b *APIBackend) ViewLen() uint64

ViewLen return current ViewLen

type BadBlockArgs

type BadBlockArgs struct {
	Hash  common.Hash            `json:"hash"`
	Block map[string]interface{} `json:"block"`
	RLP   string                 `json:"rlp"`
}

BadBlockArgs represents the entries in the list returned when bad blocks are queried.

type BloomIndexer

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

BloomIndexer implements a core.ChainIndexer, building up a rotated bloom bits index for the cpchain header bloom filters, permitting blazing fast filtering.

func (*BloomIndexer) Commit

func (b *BloomIndexer) Commit() error

Commit implements core.ChainIndexerBackend, finalizing the bloom section and writing it out into the database.

func (*BloomIndexer) Process

func (b *BloomIndexer) Process(header *types.Header)

Process implements core.ChainIndexerBackend, adding a new header's bloom into the index.

func (*BloomIndexer) Reset

func (b *BloomIndexer) Reset(section uint64, lastSectionHead common.Hash) error

Reset implements core.ChainIndexerBackend, starting a new bloombits index section.

type ChainManager

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

ChainManager is the collection of Ethereum full node-related APIs exposed over the private admin endpoint.

func NewAdminManager

func NewAdminManager(c *CpchainService) *ChainManager

NewAdminManager creates a new API definition for the full node private admin methods of the Ethereum service.

func (*ChainManager) ExportChain

func (api *ChainManager) ExportChain(ctx context.Context, file *admin.File) (*common.IsOk, error)

ExportChain exports the current blockchain into a local file.

func (*ChainManager) ImportChain

func (api *ChainManager) ImportChain(ctx context.Context, file *admin.File) (*common.IsOk, error)

ImportChain imports a blockchain from a local file.

func (*ChainManager) IsPublic

func (c *ChainManager) IsPublic() bool

IsPublic if public default

func (*ChainManager) Namespace

func (c *ChainManager) Namespace() string

Namespace namespace

func (*ChainManager) RegisterJsonRpc

func (c *ChainManager) RegisterJsonRpc(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption)

RegisterJsonRpc register GAPI to restfull json

func (*ChainManager) RegisterServer

func (c *ChainManager) RegisterServer(s *grpc.Server)

RegisterServer register GAPI to grpc

type Coinbase

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

Coinbase provides an API to access Ethereum full node-related information.

func NewCoinbase

func NewCoinbase(c *CpchainService) *Coinbase

NewCoinbase creates a new Ethereum protocol API for full nodes.

func (*Coinbase) Coinbase

func (c *Coinbase) Coinbase(ctx context.Context, req *empty.Empty) (*common.Address, error)

Coinbase is the address that mining rewards will be send to

func (*Coinbase) IsPublic

func (c *Coinbase) IsPublic() bool

IsPublic if public default

func (*Coinbase) Namespace

func (c *Coinbase) Namespace() string

Namespace namespace naem

func (*Coinbase) RegisterJsonRpc

func (c *Coinbase) RegisterJsonRpc(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption)

RegisterJsonRpc register api to restfull json

func (*Coinbase) RegisterServer

func (c *Coinbase) RegisterServer(s *grpc.Server)

RegisterServer register api to grpc

type Config

type Config struct {
	// The genesis block, which is inserted if the database is empty.
	// If nil, the cpchain main net block is used.
	Genesis *core.Genesis `toml:",omitempty"`

	// Protocol options
	NetworkId uint64 // Network ID to use for selecting peers to connect to
	SyncMode  downloader.SyncMode
	NoPruning bool // TODO: remove it {AC}

	// Light client options
	LightServ  int `toml:",omitempty"` // Maximum percentage of time allowed for serving LES requests
	LightPeers int `toml:",omitempty"` // Maximum number of LES client peers

	// Database options
	SkipBcVersionCheck bool `toml:"-"`
	DatabaseHandles    int  `toml:"-"`
	DatabaseCache      int
	TrieCache          int
	TrieTimeout        time.Duration

	// Mining-related options
	Cpcbase      common.Address `toml:",omitempty"`
	MinerThreads int            `toml:",omitempty"`
	ExtraData    []byte         `toml:",omitempty"`
	GasPrice     *big.Int

	// Admission options
	Admission admission.Config

	// Transaction pool options
	TxPool core.TxPoolConfig

	// Gas Price Oracle options
	GPO gasprice.Config

	// Enables tracking of SHA3 preimages in the VM
	EnablePreimageRecording bool

	// Miscellaneous options
	DocRoot string `toml:"-"`

	// Private Tx related configuration
	PrivateTx private.Config
}

func (Config) MarshalTOML

func (c Config) MarshalTOML() (interface{}, error)

MarshalTOML marshals as TOML.

func (*Config) UnmarshalTOML

func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error

UnmarshalTOML unmarshals from TOML.

type CpchainService

type CpchainService struct {

	// chain service backend
	APIBackend          *APIBackend
	AdmissionApiBackend admission.ApiBackend
	// contains filtered or unexported fields
}

CpchainService implements the CpchainService full node service.

func New

func New(ctx *node.ServiceContext, config *Config) (*CpchainService, error)

New creates a new CpchainService object (including the initialisation of the common CpchainService object)

func (*CpchainService) APIs

func (s *CpchainService) APIs() []rpc.API

APIs return the collection of RPC services the cpc package offers. NOTE, some of these services probably need to be moved to somewhere else.

func (*CpchainService) AccountManager

func (s *CpchainService) AccountManager() *accounts.Manager

func (*CpchainService) AddLesServer

func (s *CpchainService) AddLesServer(ls LesServer)

func (*CpchainService) BlockChain

func (s *CpchainService) BlockChain() *core.BlockChain

func (*CpchainService) ChainDb

func (s *CpchainService) ChainDb() database.Database

func (*CpchainService) Coinbase

func (s *CpchainService) Coinbase() (coinbase common.Address, err error)

func (*CpchainService) CpcVersion

func (s *CpchainService) CpcVersion() int

func (*CpchainService) CreateConsensusEngine

func (s *CpchainService) CreateConsensusEngine(ctx *node.ServiceContext, chainConfig *configs.ChainConfig, db database.Database) consensus.Engine

CreateConsensusEngine creates the required type of consensus engine instance for an Cpchain service

func (*CpchainService) Downloader

func (s *CpchainService) Downloader() *downloader.Downloader

func (*CpchainService) Engine

func (s *CpchainService) Engine() consensus.Engine

func (*CpchainService) EventMux

func (s *CpchainService) EventMux() *event.TypeMux

func (*CpchainService) GAPIs

func (s *CpchainService) GAPIs() []grpc.GApi

GAPIs return the collection of GRPC services the cpc package offers. NOTE, some of these services probably need to be moved to somewhere else.

func (*CpchainService) IsListening

func (s *CpchainService) IsListening() bool

func (*CpchainService) IsMining

func (s *CpchainService) IsMining() bool

func (*CpchainService) Miner

func (s *CpchainService) Miner() *miner.Miner

func (*CpchainService) NetVersion

func (s *CpchainService) NetVersion() uint64

func (*CpchainService) Protocols

func (s *CpchainService) Protocols() []p2p.Protocol

Protocols implements node.Service, returning all the currently configured network protocols to start.

func (*CpchainService) RemoteDB

func (s *CpchainService) RemoteDB() database.RemoteDatabase

func (*CpchainService) ResetWithGenesisBlock

func (s *CpchainService) ResetWithGenesisBlock(gb *types.Block)

func (*CpchainService) SetAsMiner

func (s *CpchainService) SetAsMiner(isMiner bool)

SetAsMiner sets dpor engine as miner

func (*CpchainService) SetClientForDpor

func (s *CpchainService) SetClientForDpor(client backend.ClientBackend)

func (*CpchainService) SetCoinbase

func (s *CpchainService) SetCoinbase(coinbase common.Address)

SetCoinbase sets the mining reward address.

func (*CpchainService) Start

func (s *CpchainService) Start(srvr *p2p.Server) error

start implements node.service, starting all internal goroutines needed by the cpchain protocol implementation.

func (*CpchainService) StartMining

func (s *CpchainService) StartMining(local bool, client backend.ClientBackend) error

func (*CpchainService) Stop

func (s *CpchainService) Stop() error

Stop implements node.Service, terminating all internal goroutines used by the cpchain protocol.

func (*CpchainService) StopMining

func (s *CpchainService) StopMining()

func (*CpchainService) TxPool

func (s *CpchainService) TxPool() *core.TxPool

type DebugDumper

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

DebugDumper is the collection of Ethereum full node APIs exposed over the public debugging endpoint.

func NewDebugDumper

func NewDebugDumper(c *CpchainService) *DebugDumper

NewDebugDumper creates a new API definition for the full node- related public debug methods of the Ethereum service.

func (*DebugDumper) DumpBlock

func (api *DebugDumper) DumpBlock(ctx context.Context, blockNumber *pb.BlockNumber) (*pb.Dump, error)

DumpBlock retrieves the entire state of the database at a given block.

func (*DebugDumper) IsPublic

func (d *DebugDumper) IsPublic() bool

IsPublic if public default

func (*DebugDumper) Namespace

func (d *DebugDumper) Namespace() string

Namespace namespace

func (*DebugDumper) RegisterJsonRpc

func (d *DebugDumper) RegisterJsonRpc(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption)

RegisterJsonRpc register api to restfull json

func (*DebugDumper) RegisterServer

func (d *DebugDumper) RegisterServer(s *grpc.Server)

RegisterServer register api to grpc

type DebugManager

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

DebugManager is the collection of Ethereum full node APIs exposed over the private debugging endpoint.

func NewDebugManager

func NewDebugManager(c *CpchainService) *DebugManager

NewDebugManager creates a new API definition for the full node-related private debug methods of the Ethereum service.

func (*DebugManager) GetBadBlocks

func (d *DebugManager) GetBadBlocks(ctx context.Context, req *empty.Empty) (*pb.BadBlockArgs, error)

GetBadBlocks returns a list of the last 'bad blocks' that the client has seen on the network and returns them as a JSON list of block-hashes

func (*DebugManager) GetModifiedAccountsByHash

func (d *DebugManager) GetModifiedAccountsByHash(ctx context.Context, req *debug.DebugManagerRequest) (*pb.Addresses, error)

GetModifiedAccountsByHash returns all accounts that have changed between the two blocks specified. A change is defined as a difference in nonce, balance, code hash, or storage hash.

With one parameter, returns the list of accounts modified in the specified block.

func (*DebugManager) GetModifiedAccountsByNumber

func (d *DebugManager) GetModifiedAccountsByNumber(ctx context.Context, req *debug.DebugManagerRequest) (*pb.Addresses, error)

GetModifiedAccountsByNumber returns all accounts that have changed between the two blocks specified. A change is defined as a difference in nonce, balance, code hash, or storage hash.

With one parameter, returns the list of accounts modified in the specified block.

func (*DebugManager) IsPublic

func (d *DebugManager) IsPublic() bool

IsPublic if public default

func (*DebugManager) Namespace

func (d *DebugManager) Namespace() string

Namespace namespace

func (*DebugManager) Preimage

func (d *DebugManager) Preimage(ctx context.Context, hash *pb.Hash) (*debug.PreimageValue, error)

Preimage is a debug API function that returns the preimage for a sha3 hash, if known.

func (*DebugManager) RegisterJsonRpc

func (d *DebugManager) RegisterJsonRpc(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption)

RegisterJsonRpc register api to restfull json

func (*DebugManager) RegisterServer

func (d *DebugManager) RegisterServer(s *grpc.Server)

RegisterServer register api to grpc

func (*DebugManager) StorageRangeAt

StorageRangeAt returns the storage at the given block height and transaction index.

type LesServer

type LesServer interface {
	Start(srvr *p2p.Server)
	Stop()
	Protocols() []p2p.Protocol
	SetBloomBitsIndexer(bbIndexer *core.ChainIndexer)
}

type MinerManager

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

MinerManager provides private RPC methods to control the miner. These methods can be abused by external users and must be considered insecure for use by untrusted users.

func NewMinerManager

func NewMinerManager(c *CpchainService) *MinerManager

NewMinerManager create a new RPC service which controls the miner of this node.

func (*MinerManager) IsPublic

func (m *MinerManager) IsPublic() bool

IsPublic if public default

func (*MinerManager) Namespace

func (m *MinerManager) Namespace() string

Namespace namespace

func (*MinerManager) RegisterJsonRpc

func (m *MinerManager) RegisterJsonRpc(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption)

RegisterJsonRpc register api to restfull json

func (*MinerManager) RegisterServer

func (m *MinerManager) RegisterServer(s *grpc.Server)

RegisterServer register api to grpc

func (*MinerManager) SetCoinbase

func (api *MinerManager) SetCoinbase(ctx context.Context, newAddress *pb.Address) (*pb.IsOk, error)

SetCoinbase sets the coinbase of the miner

func (*MinerManager) SetExtra

func (api *MinerManager) SetExtra(ctx context.Context, extra *miner.Extra) (*pb.IsOk, error)

SetExtra sets the extra data string that is included when this miner mines a block.

func (*MinerManager) SetGasPrice

func (api *MinerManager) SetGasPrice(ctx context.Context, gasPrice *pb.GasPrice) (*pb.IsOk, error)

SetGasPrice sets the minimum accepted gas price for the miner.

func (*MinerManager) Start

func (api *MinerManager) Start(ctx context.Context, threads *miner.Threads) (*empty.Empty, error)

Start the miner with the given number of threads. If threads is nil the number of workers started is equal to the number of logical CPUs that are usable by this process. If mining is already running, this method adjust the number of threads allowed to use.

func (*MinerManager) Stop

func (api *MinerManager) Stop(ctx context.Context, req *empty.Empty) (*pb.IsOk, error)

Stop the miner

type NodeInfo

type NodeInfo struct {
	Network uint64               `json:"network"` // cpchain network ID (1=Frontier, 2=Morden, Ropsten=3, Rinkeby=4)
	Height  *big.Int             `json:"height"`  // height of the host's blockchain
	Genesis common.Hash          `json:"genesis"` // SHA3 hash of the host's genesis block
	Config  *configs.ChainConfig `json:"config"`  // Chain configuration for the fork rules
	Head    common.Hash          `json:"head"`    // SHA3 hash of the host's best owned block
}

NodeInfo represents a short summary of the Cpchain sub-protocol metadata known about the host peer.

type PeerInfo

type PeerInfo struct {
	Version int      `json:"version"` // cpchain protocol version negotiated
	Height  *big.Int `json:"height"`  // height of the peer's blockchain
	Head    string   `json:"head"`    // SHA3 hash of the peer's best owned block
}

PeerInfo represents a short summary of the cpchain sub-protocol metadata known about a connected peer.

type PrivateAdminAPI

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

PrivateAdminAPI is the collection of cpchain full node-related APIs exposed over the private admin endpoint.

func NewPrivateAdminAPI

func NewPrivateAdminAPI(eth *CpchainService) *PrivateAdminAPI

NewPrivateAdminAPI creates a new API definition for the full node private admin methods of the cpchain service.

func (*PrivateAdminAPI) ExportChain

func (api *PrivateAdminAPI) ExportChain(file string) (bool, error)

ExportChain exports the current blockchain into a local file.

func (*PrivateAdminAPI) ImportChain

func (api *PrivateAdminAPI) ImportChain(file string) (bool, error)

ImportChain imports a blockchain from a local file.

type PrivateDebugAPI

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

PrivateDebugAPI is the collection of cpchain full node APIs exposed over the private debugging endpoint.

func NewPrivateDebugAPI

func NewPrivateDebugAPI(config *configs.ChainConfig, service *CpchainService) *PrivateDebugAPI

NewPrivateDebugAPI creates a new API definition for the full node-related private debug methods of the cpchain service.

func (*PrivateDebugAPI) GetBadBlocks

func (api *PrivateDebugAPI) GetBadBlocks(ctx context.Context) ([]*BadBlockArgs, error)

GetBadBlocks returns a list of the last 'bad blocks' that the client has seen on the network and returns them as a JSON list of block-hashes

func (*PrivateDebugAPI) GetModifiedAccountsByHash

func (api *PrivateDebugAPI) GetModifiedAccountsByHash(startHash common.Hash, endHash *common.Hash) ([]common.Address, error)

GetModifiedAccountsByHash returns all accounts that have changed between the two blocks specified. A change is defined as a difference in nonce, balance, code hash, or storage hash.

With one parameter, returns the list of accounts modified in the specified block.

func (*PrivateDebugAPI) GetModifiedAccountsByNumber

func (api *PrivateDebugAPI) GetModifiedAccountsByNumber(startNum uint64, endNum *uint64) ([]common.Address, error)

GetModifiedAccountsByNumber returns all accounts that have changed between the two blocks specified. A change is defined as a difference in nonce, balance, code hash, or storage hash.

With one parameter, returns the list of accounts modified in the specified block.

func (*PrivateDebugAPI) Preimage

func (api *PrivateDebugAPI) Preimage(ctx context.Context, hash common.Hash) (hexutil.Bytes, error)

Preimage is a debug API function that returns the preimage for a sha3 hash, if known.

func (*PrivateDebugAPI) StorageRangeAt

func (api *PrivateDebugAPI) StorageRangeAt(ctx context.Context, blockHash common.Hash, txIndex int, contractAddress common.Address, keyStart hexutil.Bytes, maxResult int) (StorageRangeResult, error)

StorageRangeAt returns the storage at the given block height and transaction index.

func (*PrivateDebugAPI) TraceBlock

func (api *PrivateDebugAPI) TraceBlock(ctx context.Context, blob []byte, config *TraceConfig) ([]*txTraceResult, error)

TraceBlock returns the structured logs created during the execution of EVM and returns them as a JSON object.

func (*PrivateDebugAPI) TraceBlockByHash

func (api *PrivateDebugAPI) TraceBlockByHash(ctx context.Context, hash common.Hash, config *TraceConfig) ([]*txTraceResult, error)

TraceBlockByHash returns the structured logs created during the execution of EVM and returns them as a JSON object.

func (*PrivateDebugAPI) TraceBlockByNumber

func (api *PrivateDebugAPI) TraceBlockByNumber(ctx context.Context, number rpc.BlockNumber, config *TraceConfig) ([]*txTraceResult, error)

TraceBlockByNumber returns the structured logs created during the execution of EVM and returns them as a JSON object.

func (*PrivateDebugAPI) TraceBlockFromFile

func (api *PrivateDebugAPI) TraceBlockFromFile(ctx context.Context, file string, config *TraceConfig) ([]*txTraceResult, error)

TraceBlockFromFile returns the structured logs created during the execution of EVM and returns them as a JSON object.

func (*PrivateDebugAPI) TraceChain

func (api *PrivateDebugAPI) TraceChain(ctx context.Context, start, end rpc.BlockNumber, config *TraceConfig) (*rpc.Subscription, error)

TraceChain returns the structured logs created during the execution of EVM between two blocks (excluding start) and returns them as a JSON object.

func (*PrivateDebugAPI) TraceTransaction

func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig) (interface{}, error)

TraceTransaction returns the structured logs created during the execution of EVM and returns them as a JSON object.

type PrivateMinerAPI

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

PrivateMinerAPI provides private RPC methods to control the miner. These methods can be abused by external users and must be considered insecure for use by untrusted users.

func NewPrivateMinerAPI

func NewPrivateMinerAPI(e *CpchainService) *PrivateMinerAPI

NewPrivateMinerAPI create a new RPC service which controls the miner of this node.

func (*PrivateMinerAPI) SetCoinbase

func (api *PrivateMinerAPI) SetCoinbase(coinbase common.Address) bool

func (*PrivateMinerAPI) SetExtra

func (api *PrivateMinerAPI) SetExtra(extra string) (bool, error)

SetExtra sets the extra data string that is included when this miner mines a block.

func (*PrivateMinerAPI) SetGasPrice

func (api *PrivateMinerAPI) SetGasPrice(gasPrice hexutil.Big) bool

SetGasPrice sets the minimum accepted gas price for the miner.

func (*PrivateMinerAPI) Start

func (api *PrivateMinerAPI) Start(threads *int) error

Start the miner with the given number of threads. If threads is nil the number of workers started is equal to the number of logical CPUs that are usable by this process. If mining is already running, this method adjust the number of threads allowed to use.

func (*PrivateMinerAPI) Stop

func (api *PrivateMinerAPI) Stop() bool

Stop the miner

type ProtocolManager

type ProtocolManager struct {
	SubProtocols []p2p.Protocol
	// contains filtered or unexported fields
}

func NewProtocolManager

func NewProtocolManager(config *configs.ChainConfig, mode downloader.SyncMode, networkID uint64, mux *event.TypeMux, txpool txPool, engine consensus.Engine, blockchain *core.BlockChain, chaindb database.Database, coinbase common.Address) (*ProtocolManager, error)

NewProtocolManager returns a new sub protocol manager. The cpchain sub protocol manages peers capable with the cpchain network.

func (*ProtocolManager) BroadcastBlock

func (pm *ProtocolManager) BroadcastBlock(block *types.Block, propagate bool)

BroadcastBlock will either propagate a block to a subset of it's peers, or will only announce it's availability (depending what's requested).

func (*ProtocolManager) BroadcastTxs

func (pm *ProtocolManager) BroadcastTxs(txs types.Transactions)

BroadcastTxs will propagate a batch of transactions to all peers which are not known to already have the given transaction.

func (*ProtocolManager) NodeInfo

func (pm *ProtocolManager) NodeInfo() *NodeInfo

NodeInfo retrieves some protocol metadata about the running host node.

func (*ProtocolManager) Start

func (pm *ProtocolManager) Start(maxPeers int)

Start starts all the blockchain synchronization mechanisms

func (*ProtocolManager) Stop

func (pm *ProtocolManager) Stop()

Stop stops all

type PublicCpchainAPI

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

PublicCpchainAPI provides an API to access cpchain full node-related information.

func NewPublicCpchainAPI

func NewPublicCpchainAPI(e *CpchainService) *PublicCpchainAPI

NewPublicCpchainAPI creates a new cpchain protocol API for full nodes.

func (*PublicCpchainAPI) Coinbase

func (api *PublicCpchainAPI) Coinbase() (common.Address, error)

Coinbase is the address that mining rewards will be send to (alias for Coinbase)

func (*PublicCpchainAPI) Cpcbase

func (api *PublicCpchainAPI) Cpcbase() (common.Address, error)

Coinbase is the address that mining rewards will be send to

type PublicDebugAPI

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

PublicDebugAPI is the collection of cpchain full node APIs exposed over the public debugging endpoint.

func NewPublicDebugAPI

func NewPublicDebugAPI(eth *CpchainService) *PublicDebugAPI

NewPublicDebugAPI creates a new API definition for the full node- related public debug methods of the cpchain service.

func (*PublicDebugAPI) DumpBlock

func (api *PublicDebugAPI) DumpBlock(blockNr rpc.BlockNumber) (state.Dump, error)

DumpBlock retrieves the entire state of the database at a given block.

type StorageRangeResult

type StorageRangeResult struct {
	Storage storageMap   `json:"storage"`
	NextKey *common.Hash `json:"nextKey"` // nil if Storage includes the last key in the trie.
}

StorageRangeResult is the result of a debug_storageRangeAt API call.

type TraceConfig

type TraceConfig struct {
	*vm.LogConfig
	Tracer  *string
	Timeout *string
	Reexec  *uint64
}

TraceConfig holds extra parameters to trace functions.

Directories

Path Synopsis
Package downloader contains the manual full chain synchronisation.
Package downloader contains the manual full chain synchronisation.
Package fetcher contains the block announcement based synchronisation.
Package fetcher contains the block announcement based synchronisation.
Package filters implements an ethereum filtering system for block, transactions and log events.
Package filters implements an ethereum filtering system for block, transactions and log events.
Package tracers is a collection of JavaScript transaction tracers.
Package tracers is a collection of JavaScript transaction tracers.
internal/tracers
Package tracers contains the actual JavaScript tracer assets.
Package tracers contains the actual JavaScript tracer assets.

Jump to

Keyboard shortcuts

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