mc

package
v0.0.0-...-1df7544 Latest Latest
Warning

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

Go to latest
Published: May 12, 2021 License: GPL-3.0 Imports: 58 Imported by: 5

Documentation

Overview

Package mc implements the MoacNode protocol.

Package mc implements the MoacNode protocol.

Index

Constants

View Source
const (
	SubnetBegin  = 0
	SubnetEnd    = 1
	SubnetRemove = 2
)
View Source
const (
	// Protocol messages belonging to mc/62
	StatusMsg          = 0x00
	NewBlockHashesMsg  = 0x01
	TxMsg              = 0x02
	GetBlockHeadersMsg = 0x03
	BlockHeadersMsg    = 0x04
	GetBlockBodiesMsg  = 0x05
	BlockBodiesMsg     = 0x06
	NewBlockMsg        = 0x07

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

	//sharding message
	ShardingCreateMsg = 0x21
	ShardingFlushMsg  = 0x22

	//scs message
	ScsMsg = 0x31
	ScsRes = 0x32
	ScsReg = 0x33
)

mc 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
View Source
const SubnetsConfigPrefix = "subnetsConfig"

Variables

View Source
var DefaultConfig = Config{
	SyncMode:             downloader.FastSync,
	EthashCacheDir:       "ethash",
	EthashCachesInMem:    2,
	EthashCachesOnDisk:   3,
	EthashDatasetsInMem:  1,
	EthashDatasetsOnDisk: 2,
	NetworkId:            params.MainNetworkId,
	LightPeers:           20,
	DatabaseCache:        128,
	GasPrice:             big.NewInt(18 * params.Xiao),

	TxPool: core.DefaultTxPoolConfig,
	GPO: gasprice.Config{
		Blocks:     10,
		Percentile: 50,
	},
}

DefaultConfig contains default settings for use on the MoacNode main net. network ID

View Source
var ProtocolLengths = []uint64{52, 8}

Number of implemented message corresponding to different protocol versions.

View Source
var ProtocolName = "mc"

Official short name of the protocol used during capability negotiation.

View Source
var ProtocolVersions = []uint{mc63, mc62}

Supported versions of the mc protocol (first is primary).

Functions

func CreateConsensusEngine

func CreateConsensusEngine(ctx *node.ServiceContext, config *Config, chainConfig *params.ChainConfig, db mcdb.Database) consensus.Engine

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

func CreateDB

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

CreateDB creates the chain database.

func CreateSyncDB

func CreateSyncDB(ctx *node.ServiceContext, config *Config, name string) (mcdb.Database, error)

CreateSyncDB creates the sync database.

func ErrResp

func ErrResp(code errCode, format string, v ...interface{}) error

func GetScsPushMsgHash

func GetScsPushMsgHash(msg *pb.ScsPushMsg) common.Hash

func NewBloomIndexer

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

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

func NewSubnetsConfigDB

func NewSubnetsConfigDB(db mcdb.Database) mcdb.Database

Types

type BlockBodiesData

type BlockBodiesData []*BlockBody

BlockBodiesData is the network packet for block content distribution.

type BlockBody

type BlockBody struct {
	Transactions []*types.Transaction // Transactions contained within a block
	Uncles       []*types.Header      // Uncles contained within a block
}

BlockBody represents the data content of a single block.

type BlockTraceResult

type BlockTraceResult struct {
	Validated  bool                 `json:"validated"`
	StructLogs []mcapi.StructLogRes `json:"structLogs"`
	Error      string               `json:"error"`
}

BlockTraceResult is the returned value when replaying a block to check for consensus results and full VM trace logs for all included transactions.

type BloomIndexer

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

BloomIndexer implements a core.ChainIndexer, building up a rotated bloom bits index for the MoacService 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)

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

type Config

type Config struct {
	// The genesis block, which is inserted if the database is empty.
	// If nil, the MoacNode 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

	// 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

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

	// Ethash options
	EthashCacheDir       string
	EthashCachesInMem    int
	EthashCachesOnDisk   int
	EthashDatasetDir     string
	EthashDatasetsInMem  int
	EthashDatasetsOnDisk int

	// Transaction pool options
	TxPool core.TxPoolConfig

	// GasRemaining Price Oracle options ?
	GPO gasprice.Config

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

	// Miscellaneous options
	DocRoot   string `toml:"-"`
	PowFake   bool   `toml:"-"`
	PowTest   bool   `toml:"-"`
	PowShared bool   `toml:"-"`
}

func (Config) MarshalTOML

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

func (*Config) UnmarshalTOML

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

type ContractBackend

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

ContractBackend implements bind.ContractBackend with direct calls to MoacNode internals to support operating on contracts within subprotocols like mc and swarm.

Internally this backend uses the already exposed API endpoints of the MoacNode object. These should be rewritten to internal Go method calls when the Go API is refactored to support a clean library use.

func NewContractBackend

func NewContractBackend(apiBackend mcapi.Backend) *ContractBackend

NewContractBackend creates a new native contract backend using an existing Etheruem object.

func (*ContractBackend) CallContract

func (b *ContractBackend) CallContract(ctx context.Context, msg moaccore.CallMsg, blockNum *big.Int) ([]byte, error)

ContractCall implements bind.ContractCaller executing an MoacNode contract call with the specified data as the input. The pending flag requests execution against the pending block, not the stable head of the chain.

func (*ContractBackend) CodeAt

func (b *ContractBackend) CodeAt(ctx context.Context, contract common.Address, blockNum *big.Int) ([]byte, error)

CodeAt retrieves any code associated with the contract from the local API.

func (*ContractBackend) EstimateGas

func (b *ContractBackend) EstimateGas(ctx context.Context, msg moaccore.CallMsg) (*big.Int, error)

EstimateGasLimit implements bind.ContractTransactor triing to estimate the gas needed to execute a specific transaction based on the current pending state of the backend blockchain. There is no guarantee that this is the true gas limit requirement as other transactions may be added or removed by miners, but it should provide a basis for setting a reasonable default.

func (*ContractBackend) PendingCallContract

func (b *ContractBackend) PendingCallContract(ctx context.Context, msg moaccore.CallMsg) ([]byte, error)

ContractCall implements bind.ContractCaller executing an MoacNode contract call with the specified data as the input. The pending flag requests execution against the pending block, not the stable head of the chain.

func (*ContractBackend) PendingCodeAt

func (b *ContractBackend) PendingCodeAt(ctx context.Context, contract common.Address) ([]byte, error)

CodeAt retrieves any code associated with the contract from the local API.

func (*ContractBackend) PendingNonceAt

func (b *ContractBackend) PendingNonceAt(ctx context.Context, account common.Address) (nonce uint64, err error)

PendingAccountNonce implements bind.ContractTransactor retrieving the current pending nonce associated with an account.

func (*ContractBackend) SendTransaction

func (b *ContractBackend) SendTransaction(ctx context.Context, tx *types.Transaction) error

SendTransaction implements bind.ContractTransactor injects the transaction into the pending pool for execution.

func (*ContractBackend) SuggestGasPrice

func (b *ContractBackend) SuggestGasPrice(ctx context.Context) (*big.Int, error)

SuggestGasPrice implements bind.ContractTransactor retrieving the currently suggested gas price to allow a timely execution of a transaction.

type GetBlockHeadersData

type GetBlockHeadersData struct {
	Origin  HashOrNumber // Block from which to retrieve headers
	Amount  uint64       // Maximum number of headers to retrieve
	Skip    uint64       // Blocks to skip between consecutive headers
	Reverse bool         // Query direction (false = rising towards latest, true = falling towards genesis)
}

GetBlockHeadersData represents a block header query.

type HashOrNumber

type HashOrNumber struct {
	Hash   common.Hash // Block hash from which to retrieve headers (excludes Number)
	Number uint64      // Block hash from which to retrieve headers (excludes Hash)
}

HashOrNumber is a combined field for specifying an origin block.

func (*HashOrNumber) DecodeRLP

func (hn *HashOrNumber) DecodeRLP(s *rlp.Stream) error

DecodeRLP is a specialized decoder for HashOrNumber to decode the contents into either a block hash or a block number.

func (*HashOrNumber) EncodeRLP

func (hn *HashOrNumber) EncodeRLP(w io.Writer) error

EncodeRLP is a specialized encoder for HashOrNumber to encode only one of the two contained union fields.

type LesServer

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

type MoacApiBackend

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

MoacApiBackend implements mcapi.Backend for full nodes

func (*MoacApiBackend) AccountManager

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

func (*MoacApiBackend) BlockByNumber

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

func (*MoacApiBackend) BloomStatus

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

func (*MoacApiBackend) ChainConfig

func (b *MoacApiBackend) ChainConfig() *params.ChainConfig

func (*MoacApiBackend) ChainDb

func (b *MoacApiBackend) ChainDb() mcdb.Database

func (*MoacApiBackend) CurrentBlock

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

func (*MoacApiBackend) Downloader

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

func (*MoacApiBackend) EventMux

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

func (*MoacApiBackend) GetBlock

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

func (*MoacApiBackend) GetEVM

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

func (*MoacApiBackend) GetPoolNonce

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

func (*MoacApiBackend) GetPoolTransaction

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

func (*MoacApiBackend) GetPoolTransactions

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

func (*MoacApiBackend) GetReceipts

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

func (*MoacApiBackend) GetTd

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

func (*MoacApiBackend) HeaderByHash

func (b *MoacApiBackend) HeaderByHash(ctx context.Context, blockHash common.Hash) (*types.Header, error)

func (*MoacApiBackend) HeaderByNumber

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

func (*MoacApiBackend) ProtocolVersion

func (b *MoacApiBackend) ProtocolVersion() int

func (*MoacApiBackend) SendTx

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

func (*MoacApiBackend) ServiceFilter

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

func (*MoacApiBackend) SetHead

func (b *MoacApiBackend) SetHead(number uint64)

func (*MoacApiBackend) StateAndHeaderByNumber

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

func (*MoacApiBackend) Stats

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

func (*MoacApiBackend) SubscribeChainEvent

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

func (*MoacApiBackend) SubscribeChainHeadEvent

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

func (*MoacApiBackend) SubscribeChainSideEvent

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

func (*MoacApiBackend) SubscribeLogsEvent

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

func (*MoacApiBackend) SubscribeRemovedLogsEvent

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

func (*MoacApiBackend) SubscribeTxPreEvent

func (b *MoacApiBackend) SubscribeTxPreEvent(ch chan<- core.TxPreEvent) event.Subscription

func (*MoacApiBackend) SuggestPrice

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

func (*MoacApiBackend) TxPoolContent

type MoacNodeInfo

type MoacNodeInfo struct {
	Network    uint64      `json:"network"`    // MoacNode network ID (1=Frontier, 2=Morden, Ropsten=3)
	Difficulty *big.Int    `json:"difficulty"` // Total difficulty of the host's blockchain
	Genesis    common.Hash `json:"genesis"`    // SHA3 hash of the host's genesis block
	Head       common.Hash `json:"head"`       // SHA3 hash of the host's best owned block
}

about the host Peer.

type MoacService

type MoacService struct {
	ProtocolManager *ProtocolManager

	ApiBackend *MoacApiBackend
	// contains filtered or unexported fields
}

MoacService implements the MoacService full node service. 2018/07/06 Added scs interface to scsHandler

var Instance *MoacService

Add a instance of MoacService handling SCS

func GetInstance

func GetInstance() *MoacService

func New

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

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

func (*MoacService) APIs

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

APIs returns the collection of RPC services the moaccore package offers. NOTE, some of these services probably need to be moved to somewhere else. 2018/07/06 added the scsHandler as scs provider

func (*MoacService) AccountManager

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

func (*MoacService) AddLesServer

func (s *MoacService) AddLesServer(ls LesServer)

func (*MoacService) BlockChain

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

func (*MoacService) ChainDb

func (s *MoacService) ChainDb() mcdb.Database

func (*MoacService) Downloader

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

func (*MoacService) Engine

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

func (*MoacService) EventMux

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

func (*MoacService) IsListening

func (s *MoacService) IsListening() bool

func (*MoacService) IsMining

func (s *MoacService) IsMining() bool

func (*MoacService) IsSubnetP2PEnabled

func (s *MoacService) IsSubnetP2PEnabled(contractAddress common.Address, where string) bool

func (*MoacService) McVersion

func (s *MoacService) McVersion() int

func (*MoacService) Miner

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

func (*MoacService) Moacbase

func (s *MoacService) Moacbase() (eb common.Address, err error)

* Return the base58 encoded address instead of the HEX address.

func (*MoacService) NetVersion

func (s *MoacService) NetVersion() uint64

func (*MoacService) Protocols

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

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

func (*MoacService) ResetWithGenesisBlock

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

func (*MoacService) SetMoacbase

func (self *MoacService) SetMoacbase(moacbase common.Address)

set in js console via admin interface or wrapper from cli flags

func (*MoacService) Start

func (s *MoacService) Start(server *p2p.Server) error

Start implements node.Service, starting all internal goroutines needed by the MoacService protocol implementation.

func (*MoacService) StartMining

func (s *MoacService) StartMining(local bool) error

func (*MoacService) Stop

func (s *MoacService) Stop() error

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

func (*MoacService) StopMining

func (s *MoacService) StopMining()

func (*MoacService) TxPool

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

type NewBlockHashesData

type NewBlockHashesData []struct {
	Hash   common.Hash // Hash of one particular block being announced
	Number uint64      // Number of one particular block being announced
}

NewBlockHashesData is the network packet for the block announcements.

type P2PManager

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

func (*P2PManager) String

func (p *P2PManager) String() string

display mainnet and subnets information in the p2pmanager

type Peer

type Peer struct {
	*p2p.Peer
	// contains filtered or unexported fields
}

func (*Peer) AsyncSendNewBlock

func (p *Peer) AsyncSendNewBlock(block *types.Block, td *big.Int)

AsyncSendNewBlock queues an entire block for propagation to a remote peer. If the peer's broadcast queue is full, the event is silently dropped.

func (*Peer) AsyncSendNewBlockHash

func (p *Peer) AsyncSendNewBlockHash(block *types.Block)

AsyncSendNewBlockHash queues the availability of a block for propagation to a remote peer. If the peer's broadcast queue is full, the event is silently dropped.

func (*Peer) AsyncSendScsMsg

func (p *Peer) AsyncSendScsMsg(msg *pb.ScsPushMsg)

AsyncSendScsMsg queues an scs push msg for propagation to a remote peer. If the peer's broadcast queue is full, the event is silently dropped.

func (*Peer) AsyncSendScsRes

func (p *Peer) AsyncSendScsRes(msg *pb.ScsPushMsg)

AsyncSendScsRes queues an scs push msg for propagation to a remote peer. If the peer's broadcast queue is full, the event is silently dropped.

func (*Peer) AsyncSendTransactions

func (p *Peer) AsyncSendTransactions(txs types.Transactions)

AsyncSendTransactions queues list of transactions propagation to a remote peer. If the peer's broadcast queue is full, the event is silently dropped.

func (*Peer) Handshake

func (p *Peer) Handshake(network uint64, td *big.Int, head common.Hash, genesis common.Hash) error

Handshake executes the mc protocol handshake, negotiating version number, network IDs, difficulties, head and genesis blocks.

func (*Peer) Head

func (p *Peer) Head() (hash common.Hash, td *big.Int)

Head retrieves a copy of the current head hash and total difficulty of the Peer.

func (*Peer) Id

func (p *Peer) Id() string

func (*Peer) Info

func (p *Peer) Info() *PeerInfo

Info gathers and returns a collection of metadata known about a Peer.

func (*Peer) IsMainnet

func (p *Peer) IsMainnet() bool

func (*Peer) MarkBlock

func (p *Peer) MarkBlock(hash common.Hash)

MarkBlock marks a block as known for the Peer, ensuring that the block will never be propagated to this particular Peer.

func (*Peer) MarkMsg

func (p *Peer) MarkMsg(id common.Hash)

func (*Peer) MarkTransaction

func (p *Peer) MarkTransaction(hash common.Hash)

MarkTransaction marks a transaction as known for the Peer, ensuring that it will never be propagated to this particular Peer.

func (*Peer) RequestBodies

func (p *Peer) RequestBodies(hashes []common.Hash) error

RequestBodies fetches a batch of blocks' bodies corresponding to the hashes specified.

func (*Peer) RequestHeadersByHash

func (p *Peer) RequestHeadersByHash(origin common.Hash, amount int, skip int, reverse bool) error

RequestHeadersByHash fetches a batch of blocks' headers corresponding to the specified header query, based on the hash of an origin block.

func (*Peer) RequestHeadersByNumber

func (p *Peer) RequestHeadersByNumber(origin uint64, amount int, skip int, reverse bool) error

RequestHeadersByNumber fetches a batch of blocks' headers corresponding to the specified header query, based on the number of an origin block.

func (*Peer) RequestNodeData

func (p *Peer) RequestNodeData(hashes []common.Hash) error

RequestNodeData fetches a batch of arbitrary data from a node's known state data, corresponding to the specified hashes.

func (*Peer) RequestOneHeader

func (p *Peer) RequestOneHeader(hash common.Hash) error

RequestOneHeader is a wrapper around the header query functions to fetch a single header. It is used solely by the fetcher.

func (*Peer) RequestReceipts

func (p *Peer) RequestReceipts(hashes []common.Hash) error

RequestReceipts fetches a batch of transaction receipts from a remote node.

func (*Peer) SendBlockBodies

func (p *Peer) SendBlockBodies(bodies []*BlockBody) error

SendBlockBodies sends a batch of block contents to the remote Peer.

func (*Peer) SendBlockBodiesRLP

func (p *Peer) SendBlockBodiesRLP(bodies []rlp.RawValue) error

SendBlockBodiesRLP sends a batch of block contents to the remote Peer from an already RLP encoded format.

func (*Peer) SendBlockHeaders

func (p *Peer) SendBlockHeaders(headers []*types.Header) error

SendBlockHeaders sends a batch of block headers to the remote Peer.

func (*Peer) SendNewBlock

func (p *Peer) SendNewBlock(block *types.Block, td *big.Int) error

SendNewBlock propagates an entire block to a remote Peer.

func (*Peer) SendNewBlockHashes

func (p *Peer) SendNewBlockHashes(hashes []common.Hash, numbers []uint64) error

SendNewBlockHashes announces the availability of a number of blocks through a hash notification.

func (*Peer) SendNodeData

func (p *Peer) SendNodeData(data [][]byte) error

SendNodeDataRLP sends a batch of arbitrary internal data, corresponding to the hashes requested.

func (*Peer) SendReceiptsRLP

func (p *Peer) SendReceiptsRLP(receipts []rlp.RawValue) error

SendReceiptsRLP sends a batch of transaction receipts, corresponding to the ones requested from an already RLP encoded format.

func (*Peer) SendScsMsg

func (p *Peer) SendScsMsg(msg *pb.ScsPushMsg) error

func (*Peer) SendScsRes

func (p *Peer) SendScsRes(msg *pb.ScsPushMsg) error

func (*Peer) SendShardingMsg

func (p *Peer) SendShardingMsg()

send sharding message

func (*Peer) SendTransactions

func (p *Peer) SendTransactions(txs types.Transactions) error

SendTransactions sends transactions to the Peer and includes the hashes in its transaction hash set for future reference.

func (*Peer) SetHead

func (p *Peer) SetHead(hash common.Hash, td *big.Int)

SetHead updates the head hash and total difficulty of the Peer.

func (*Peer) SetNodeType

func (p *Peer) SetNodeType(id discover.NodeID, nodeType int)

func (*Peer) String

func (p *Peer) String() string

String implements fmt.Stringer.

type PeerInfo

type PeerInfo struct {
	Version    int      `json:"version"`    // MoacNode protocol version negotiated
	Difficulty *big.Int `json:"difficulty"` // Total difficulty 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 MoacNode sub-protocol metadata known about a connected Peer.

type PeerSet

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

PeerSet represents the collection of active peers currently participating in the MoacNode sub-protocol.

func (*PeerSet) BestPeer

func (ps *PeerSet) BestPeer() *Peer

BestPeer retrieves the known Peer with the currently highest total difficulty.

func (*PeerSet) Close

func (ps *PeerSet) Close()

Close disconnects all peers. No new peers can be registered after Close has returned.

func (*PeerSet) Len

func (ps *PeerSet) Len() int

Len returns if the current number of peers in the set.

func (*PeerSet) Peer

func (ps *PeerSet) Peer(id string) *Peer

Peer retrieves the registered Peer with the given id.

func (*PeerSet) PeersWithoutBlock

func (ps *PeerSet) PeersWithoutBlock(hash common.Hash) []*Peer

PeersWithoutBlock retrieves a list of peers that do not have a given block in their set of known hashes.

func (*PeerSet) PeersWithoutSCSMsg

func (ps *PeerSet) PeersWithoutSCSMsg(msg *pb.ScsPushMsg) []*Peer

func (*PeerSet) PeersWithoutTx

func (ps *PeerSet) PeersWithoutTx(hash common.Hash) []*Peer

PeersWithoutTx retrieves a list of peers that do not have a given transaction in their set of known hashes.

func (*PeerSet) Register

func (ps *PeerSet) Register(p *Peer) error

Register injects a new Peer into the working set, or returns an error if the Peer is already known.

func (*PeerSet) Unregister

func (ps *PeerSet) Unregister(id string) error

Unregister removes a remote Peer from the active set, disabling any further actions to/from that particular entity.

type PrivateAdminAPI

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

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

func NewPrivateAdminAPI

func NewPrivateAdminAPI(mc *MoacService) *PrivateAdminAPI

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

func (*PrivateAdminAPI) AddSubnetP2P

func (api *PrivateAdminAPI) AddSubnetP2P(subnetid string, blockNumber uint64) error

AddSubnetP2P requests connecting this node to subnet's dedicated p2p network as a result, this node will join multiple p2p networks including the mainnet one

func (*PrivateAdminAPI) ExportChain

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

ExportChain exports the current blockchain into a local file.

func (*PrivateAdminAPI) GetSubnetP2PList

func (api *PrivateAdminAPI) GetSubnetP2PList() ([]map[string]interface{}, error)

GetSubnetP2PList display the information about the P2P networks

func (*PrivateAdminAPI) ImportChain

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

ImportChain imports a blockchain from a local file.

func (*PrivateAdminAPI) RemoveSubnetP2P

func (api *PrivateAdminAPI) RemoveSubnetP2P(subnetid string, blockNumber uint64) error

RemoveSubnetP2P requests disconnecting this node to subnet's dedicated p2p network

type PrivateDebugAPI

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

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

func NewPrivateDebugAPI

func NewPrivateDebugAPI(config *params.ChainConfig, mc *MoacService) *PrivateDebugAPI

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

func (*PrivateDebugAPI) ActualGas

func (api *PrivateDebugAPI) ActualGas(ctx context.Context, encodedTx hexutil.Bytes) (*big.Int, error)

ActualGas returns an actual of the amount of gas needed to execute the given transaction.

func (*PrivateDebugAPI) GetBadBlocks

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

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

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(blockRlp []byte, config *vm.LogConfig) BlockTraceResult

TraceBlock processes the given block'api RLP but does not import the block in to the chain.

func (*PrivateDebugAPI) TraceBlockByHash

func (api *PrivateDebugAPI) TraceBlockByHash(hash common.Hash, config *vm.LogConfig) BlockTraceResult

TraceBlockByHash processes the block by hash.

func (*PrivateDebugAPI) TraceBlockByNumber

func (api *PrivateDebugAPI) TraceBlockByNumber(blockNr rpc.BlockNumber, config *vm.LogConfig) BlockTraceResult

TraceBlockByNumber processes the block by canonical block number.

func (*PrivateDebugAPI) TraceBlockFromFile

func (api *PrivateDebugAPI) TraceBlockFromFile(file string, config *vm.LogConfig) BlockTraceResult

TraceBlockFromFile loads the block'api RLP from the given file name and attempts to process it but does not import the block in to the chain.

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 *MoacService) *PrivateMinerAPI

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

func (*PrivateMinerAPI) GetGasPrice

func (api *PrivateMinerAPI) GetGasPrice() uint64

func (*PrivateMinerAPI) GetHashrate

func (api *PrivateMinerAPI) GetHashrate() uint64

GetHashrate returns the current hashrate of the miner.

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) SetMoacbase

func (api *PrivateMinerAPI) SetMoacbase(moacbase common.Address) bool

SetMoacbase sets the moacbase of 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 {
	NetworkRelay *nr.NetworkRelay

	SubProtocols []p2p.Protocol
	// contains filtered or unexported fields
}

func NewProtocolManager

func NewProtocolManager(
	config *params.ChainConfig,
	mode downloader.SyncMode,
	networkId uint64,
	mux *event.TypeMux,
	txpool txPool,
	engine consensus.Engine,
	blockchain *core.BlockChain,
	chaindb mcdb.Database,
	scsHandler *vnode.VnodeServer,
) (*ProtocolManager, error)

NewProtocolManager returns a new moaccore sub protocol manager. The MoacNode sub protocol manages peers capable with the moaccore 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) BroadcastPushMsgToPeerSet

func (pm *ProtocolManager) BroadcastPushMsgToPeerSet(msg *pb.ScsPushMsg, peerSet *PeerSet)

func (*ProtocolManager) BroadcastPushResToPeerSet

func (pm *ProtocolManager) BroadcastPushResToPeerSet(msg *pb.ScsPushMsg, peerSet *PeerSet)

func (*ProtocolManager) BroadcastTx

func (pm *ProtocolManager) BroadcastTx(tx *types.Transaction)

BroadcastTx will propagate a transaction to all peers which are not known to already have the given transaction.

func (*ProtocolManager) GetSubnetPeerSet

func (pm *ProtocolManager) GetSubnetPeerSet(subnetid string) *PeerSet

func (*ProtocolManager) NodeInfo

func (pm *ProtocolManager) NodeInfo() *MoacNodeInfo

NodeInfo retrieves some protocol metadata about the running host node.

func (*ProtocolManager) RemoveSubnetServer

func (pm *ProtocolManager) RemoveSubnetServer(subnetid string, n *node.Node)

func (*ProtocolManager) Start

func (pm *ProtocolManager) Start(maxPeers int)

func (*ProtocolManager) Stop

func (pm *ProtocolManager) Stop()

type PublicDebugAPI

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

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

func NewPublicDebugAPI

func NewPublicDebugAPI(mc *MoacService) *PublicDebugAPI

NewPublicDebugAPI creates a new API definition for the full node- related public debug methods of the MoacService 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 PublicMinerAPI

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

PublicMinerAPI provides an API to control the miner. It offers only methods that operate on data that pose no security risk when it is publicly accessible.

func NewPublicMinerAPI

func NewPublicMinerAPI(e *MoacService) *PublicMinerAPI

NewPublicMinerAPI create a new PublicMinerAPI instance.

func (*PublicMinerAPI) GetWork

func (api *PublicMinerAPI) GetWork() ([3]string, error)

GetWork returns a work package for external miner. The work package consists of 3 strings result[0], 32 bytes hex encoded current block header pow-hash result[1], 32 bytes hex encoded seed hash used for DAG result[2], 32 bytes hex encoded boundary condition ("target"), 2^256/difficulty

func (*PublicMinerAPI) Mining

func (api *PublicMinerAPI) Mining() bool

Mining returns an indication if this node is currently mining.

func (*PublicMinerAPI) SubmitHashrate

func (api *PublicMinerAPI) SubmitHashrate(hashrate hexutil.Uint64, id common.Hash) bool

SubmitHashrate can be used for remote miners to submit their hash rate. This enables the node to report the combined hash rate of all miners which submit work through this node. It accepts the miner hash rate and an identifier which must be unique between nodes.

func (*PublicMinerAPI) SubmitWork

func (api *PublicMinerAPI) SubmitWork(nonce types.BlockNonce, solution, digest common.Hash) bool

SubmitWork can be used by external miner to submit their POW solution. It returns an indication if the work was accepted. Note, this is not an indication if the provided work was valid!

type PublicMoacAPI

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

PublicMoacAPI provides an API to access MoacService full node-related information.

func NewPublicMoacAPI

func NewPublicMoacAPI(e *MoacService) *PublicMoacAPI

NewPublicMoacAPI creates a new MoacService protocol API for full nodes.

func (*PublicMoacAPI) Coinbase

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

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

func (*PublicMoacAPI) Hashrate

func (api *PublicMoacAPI) Hashrate() hexutil.Uint64

Hashrate returns the POW hashrate

func (*PublicMoacAPI) Moacbase

func (api *PublicMoacAPI) Moacbase() (common.Address, error)

Moacbase is the address that mining rewards will be send to

type StatusData

type StatusData struct {
	ProtocolVersion uint32
	NetworkId       uint64
	TD              *big.Int
	CurrentBlock    common.Hash
	GenesisBlock    common.Hash
}

StatusData is the network packet for the status message.

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 SubnetConfig

type SubnetConfig struct {
	Subnetid   string
	BlockStart uint64
	BlockEnd   uint64
}

type SubnetNotify

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

type TraceArgs

type TraceArgs struct {
	*vm.LogConfig
	Tracer  *string
	Timeout *string
}

TraceArgs holds extra parameters to trace functions

type TraceConfig

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

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 moaccore filtering system for block, transactions and log events.
Package filters implements an moaccore 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