Documentation ¶
Overview ¶
Package ngin implements the Ngin protocol.
Index ¶
- Constants
- Variables
- func ProtocolMessageStringer(m uint) string
- type CallArgs
- type Config
- type ContractBackend
- func (b *ContractBackend) ContractCall(contract common.Address, data []byte, pending bool) ([]byte, error)
- func (b *ContractBackend) EstimateGasLimit(sender common.Address, contract *common.Address, value *big.Int, data []byte) (*big.Int, error)
- func (b *ContractBackend) HasCode(contract common.Address, pending bool) (bool, error)
- func (b *ContractBackend) PendingAccountNonce(account common.Address) (uint64, error)
- func (b *ContractBackend) SendTransaction(tx *types.Transaction) error
- func (b *ContractBackend) SuggestGasPrice() (*big.Int, error)
- type EthNodeInfo
- type ExecutionResult
- type GasPriceOracle
- type NewBlocksArgs
- type Ngin
- func (s *Ngin) APIs() []rpc.API
- func (s *Ngin) AccountManager() *accounts.Manager
- func (s *Ngin) BlockChain() *core.BlockChain
- func (s *Ngin) ChainConfig() *core.ChainConfig
- func (s *Ngin) ChainDb() ngindb.Database
- func (s *Ngin) Coinbase() (eb common.Address, err error)
- func (s *Ngin) DappDb() ngindb.Database
- func (s *Ngin) Downloader() *downloader.Downloader
- func (s *Ngin) EthVersion() int
- func (s *Ngin) EventMux() *event.TypeMux
- func (self *Ngin) HTTPClient() *httpclient.HTTPClient
- func (s *Ngin) IsListening() bool
- func (s *Ngin) IsMining() bool
- func (s *Ngin) Miner() *miner.Miner
- func (s *Ngin) NetVersion() int
- func (s *Ngin) Protocols() []p2p.Protocol
- func (s *Ngin) ResetWithGenesisBlock(gb *types.Block)
- func (self *Ngin) SetCoinbase(coinbase common.Address)
- func (self *Ngin) SetSolc(solcPath string) (*compiler.Solidity, error)
- func (self *Ngin) Solc() (*compiler.Solidity, error)
- func (s *Ngin) Start(srvr *p2p.Server) error
- func (s *Ngin) StartMining(threads int, gpus string) error
- func (s *Ngin) Stop() error
- func (s *Ngin) StopMining()
- func (s *Ngin) TxPool() *core.TxPool
- func (s *Ngin) WaitForShutdown()
- type PMHandlerAddEvent
- type PMHandlerRemoveEvent
- type PeerInfo
- type PrivateAccountAPI
- func (s *PrivateAccountAPI) EcRecover(data, sig hexutil.Bytes) (common.Address, error)
- func (s *PrivateAccountAPI) ImportRawKey(privkey string, password string) (common.Address, error)
- func (s *PrivateAccountAPI) ListAccounts() []common.Address
- func (s *PrivateAccountAPI) LockAccount(addr common.Address) bool
- func (s *PrivateAccountAPI) NewAccount(password string) (common.Address, error)
- func (s *PrivateAccountAPI) SendTransaction(args SendTxArgs, passwd string) (common.Hash, error)
- func (s *PrivateAccountAPI) Sign(data hexutil.Bytes, addr common.Address, passwd string) (hexutil.Bytes, error)
- func (s *PrivateAccountAPI) SignAndSendTransaction(args SendTxArgs, passwd string) (common.Hash, error)
- func (s *PrivateAccountAPI) UnlockAccount(addr common.Address, password string, duration *rpc.HexNumber) (bool, error)
- type PrivateAdminAPI
- type PrivateMinerAPI
- type ProtocolManager
- type PublicAccountAPI
- type PublicBlockChainAPI
- func (s *PublicBlockChainAPI) BlockNumber() *big.Int
- func (s *PublicBlockChainAPI) Call(args CallArgs, blockNr rpc.BlockNumber) (string, error)
- func (s *PublicBlockChainAPI) EstimateGas(args CallArgs) (*rpc.HexNumber, error)
- func (s *PublicBlockChainAPI) GetBalance(address common.Address, blockNr rpc.BlockNumber) (*big.Int, error)
- func (s *PublicBlockChainAPI) GetBlockByHash(blockHash common.Hash, fullTx bool) (map[string]interface{}, error)
- func (s *PublicBlockChainAPI) GetBlockByNumber(blockNr rpc.BlockNumber, fullTx bool) (map[string]interface{}, error)
- func (s *PublicBlockChainAPI) GetCode(address common.Address, blockNr rpc.BlockNumber) (string, error)
- func (s *PublicBlockChainAPI) GetStorageAt(address common.Address, key string, blockNr rpc.BlockNumber) (string, error)
- func (s *PublicBlockChainAPI) GetUncleByBlockHashAndIndex(blockHash common.Hash, index rpc.HexNumber) (map[string]interface{}, error)
- func (s *PublicBlockChainAPI) GetUncleByBlockNumberAndIndex(blockNr rpc.BlockNumber, index rpc.HexNumber) (map[string]interface{}, error)
- func (s *PublicBlockChainAPI) GetUncleCountByBlockHash(blockHash common.Hash) *rpc.HexNumber
- func (s *PublicBlockChainAPI) GetUncleCountByBlockNumber(blockNr rpc.BlockNumber) *rpc.HexNumber
- func (s *PublicBlockChainAPI) NewBlocks(ctx context.Context, args NewBlocksArgs) (rpc.Subscription, error)
- func (s *PublicBlockChainAPI) Sign(addr common.Address, data hexutil.Bytes) (hexutil.Bytes, error)
- func (s *PublicBlockChainAPI) TraceCall(args CallArgs, blockNr rpc.BlockNumber) (*ExecutionResult, error)
- type PublicDebugAPI
- func (api *PublicDebugAPI) AccountExist(address common.Address, number uint64) (bool, error)
- func (api *PublicDebugAPI) DumpBlock(number uint64) (state.Dump, error)
- func (api *PublicDebugAPI) GetBlockRlp(number uint64) (string, error)
- func (api *PublicDebugAPI) Metrics(raw bool) (map[string]interface{}, error)
- func (api *PublicDebugAPI) PrintBlock(number uint64) (string, error)
- func (api *PublicDebugAPI) SetHead(number uint64) (bool, error)
- func (s *PublicDebugAPI) TraceTransaction(txHash common.Hash) (*ExecutionResult, error)
- func (api *PublicDebugAPI) Verbosity(n uint64) (int, error)
- func (api *PublicDebugAPI) Vmodule(s string) (string, error)
- type PublicMinerAPI
- type PublicNetAPI
- type PublicNginAPI
- func (s *PublicNginAPI) ChainId() *big.Int
- func (s *PublicNginAPI) Coinbase() (common.Address, error)
- func (s *PublicNginAPI) CompileSolidity(source string) (map[string]*compiler.Contract, error)
- func (s *PublicNginAPI) GasPrice() *big.Int
- func (s *PublicNginAPI) GetCompilers() ([]string, error)
- func (s *PublicNginAPI) Hashrate() *rpc.HexNumber
- func (s *PublicNginAPI) ProtocolVersion() *rpc.HexNumber
- func (s *PublicNginAPI) Syncing() (interface{}, error)
- type PublicNgindAPI
- func (api *PublicNgindAPI) BuildATXI(start, stop, step rpc.BlockNumber) (bool, error)
- func (api *PublicNgindAPI) GetATXIBuildStatus() (*core.AtxiProgressT, error)
- func (api *PublicNgindAPI) GetAddressTransactions(address common.Address, blockStartN uint64, blockEndN rpc.BlockNumber, ...) (list []string, err error)
- func (api *PublicNgindAPI) GetTransactionsByAddress(address common.Address, blockStartN uint64, blockEndN rpc.BlockNumber, ...) (list []string, err error)
- type PublicTransactionPoolAPI
- func (s *PublicTransactionPoolAPI) GetBlockTransactionCountByHash(blockHash common.Hash) *rpc.HexNumber
- func (s *PublicTransactionPoolAPI) GetBlockTransactionCountByNumber(blockNr rpc.BlockNumber) *rpc.HexNumber
- func (s *PublicTransactionPoolAPI) GetTransactionByBlockHashAndIndex(blockHash common.Hash, index rpc.HexNumber) (*RPCTransaction, error)
- func (s *PublicTransactionPoolAPI) GetTransactionByBlockNumberAndIndex(blockNr rpc.BlockNumber, index rpc.HexNumber) (*RPCTransaction, error)
- func (s *PublicTransactionPoolAPI) GetTransactionByHash(txHash common.Hash) (*RPCTransaction, error)
- func (s *PublicTransactionPoolAPI) GetTransactionCount(address common.Address, blockNr rpc.BlockNumber) (*rpc.HexNumber, error)
- func (s *PublicTransactionPoolAPI) GetTransactionReceipt(txHash common.Hash) (map[string]interface{}, error)
- func (s *PublicTransactionPoolAPI) NewPendingTransactions(ctx context.Context) (rpc.Subscription, error)
- func (s *PublicTransactionPoolAPI) PendingTransactions() []*RPCTransaction
- func (s *PublicTransactionPoolAPI) Resend(tx Tx, gasPrice, gasLimit *rpc.HexNumber) (common.Hash, error)
- func (s *PublicTransactionPoolAPI) SendRawTransaction(encodedTx string) (string, error)
- func (s *PublicTransactionPoolAPI) SendTransaction(args SendTxArgs) (common.Hash, error)
- func (s *PublicTransactionPoolAPI) SignTransaction(args SignTransactionArgs) (*SignTransactionResult, error)
- type PublicTxPoolAPI
- type RPCTransaction
- type SendTxArgs
- type SignTransactionArgs
- type SignTransactionResult
- type Tx
Constants ¶
const ( NetworkId = 52520 ProtocolMaxMsgSize = 10 * 1024 * 1024 // Maximum cap on the size of a protocol message )
const ( // Protocol messages belonging to ngin/62 StatusMsg = 0x00 NewBlockHashesMsg = 0x01 TxMsg = 0x02 GetBlockHeadersMsg = 0x03 BlockHeadersMsg = 0x04 GetBlockBodiesMsg = 0x05 BlockBodiesMsg = 0x06 NewBlockMsg = 0x07 // Protocol messages belonging to ngin/63 GetNodeDataMsg = 0x0d NodeDataMsg = 0x0e GetReceiptsMsg = 0x0f ReceiptsMsg = 0x10 )
ngin protocol message codes
const ( ErrMsgTooLarge = iota ErrDecode ErrInvalidMsgCode ErrProtocolVersionMismatch ErrNetworkIdMismatch ErrGenesisBlockMismatch ErrNoStatusMsg ErrExtraStatusMsg ErrSuspendedPeer )
Variables ¶
var EnableBadBlockReporting = false
var ProtocolLengths = []uint64{17, 8}
Number of implemented message corresponding to different protocol versions.
var ProtocolName = "ngin"
Official short name of the protocol used during capability negotiation.
Supported versions of the ngin protocol (first is primary).
Functions ¶
func ProtocolMessageStringer ¶
Types ¶
type CallArgs ¶
type CallArgs struct { From common.Address `json:"from"` To *common.Address `json:"to"` Gas *rpc.HexNumber `json:"gas"` GasPrice *rpc.HexNumber `json:"gasPrice"` Value rpc.HexNumber `json:"value"` Data string `json:"data"` }
CallArgs represents the arguments for a call.
type Config ¶
type Config struct { ChainConfig *core.ChainConfig // chain configuration NetworkId int // Network ID to use for selecting peers to connect to Genesis *core.GenesisDump FastSync bool // Enables the state download based fast synchronisation algorithm MaxPeers int BlockChainVersion int SkipBcVersionCheck bool // e.g. blockchain export DatabaseCache int DatabaseHandles int NatSpec bool DocRoot string PowTest bool AccountManager *accounts.Manager Coinbase common.Address GasPrice *big.Int MinerThreads int SolcPath string UseAddrTxIndex bool GpoMinGasPrice *big.Int GpoMaxGasPrice *big.Int GpoFullBlockRatio int GpobaseStepDown int GpobaseStepUp int GpobaseCorrectionFactor int TestGenesisBlock *types.Block // Genesis block to seed the chain database with (testing only!) TestGenesisState ngindb.Database // Genesis state to seed the database with (testing only!) }
type ContractBackend ¶
type ContractBackend struct {
// contains filtered or unexported fields
}
ContractBackend implements bind.ContractBackend with direct calls to Ngin internals to support operating on contracts within subprotocols like ngin and swarm.
Internally this backend uses the already exposed API endpoints of the Ngin 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(ngin *Ngin) *ContractBackend
NewContractBackend creates a new native contract backend using an existing Etheruem object.
func (*ContractBackend) ContractCall ¶
func (b *ContractBackend) ContractCall(contract common.Address, data []byte, pending bool) ([]byte, error)
ContractCall implements bind.ContractCaller executing an Ngin 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) EstimateGasLimit ¶
func (b *ContractBackend) EstimateGasLimit(sender common.Address, contract *common.Address, value *big.Int, data []byte) (*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) HasCode ¶
HasCode implements bind.ContractVerifier.HasCode by retrieving any code associated with the contract from the local API, and checking its size.
func (*ContractBackend) PendingAccountNonce ¶
func (b *ContractBackend) PendingAccountNonce(account common.Address) (uint64, error)
PendingAccountNonce implements bind.ContractTransactor retrieving the current pending nonce associated with an account.
func (*ContractBackend) SendTransaction ¶
func (b *ContractBackend) SendTransaction(tx *types.Transaction) error
SendTransaction implements bind.ContractTransactor injects the transaction into the pending pool for execution.
func (*ContractBackend) SuggestGasPrice ¶
func (b *ContractBackend) SuggestGasPrice() (*big.Int, error)
SuggestGasPrice implements bind.ContractTransactor retrieving the currently suggested gas price to allow a timely execution of a transaction.
type EthNodeInfo ¶
type EthNodeInfo struct { Network int `json:"network"` // Ngin network ID (1=Mainnet, 2=Testnet) 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 }
EthNodeInfo represents a short summary of the Ngin sub-protocol metadata known about the host peer.
type ExecutionResult ¶
ExecutionResult groups all structured logs emitted by the EVM while replaying a transaction in debug mode as well as the amount of gas used and the return value
type GasPriceOracle ¶
type GasPriceOracle struct {
// contains filtered or unexported fields
}
GasPriceOracle recommends gas prices based on the content of recent blocks.
func NewGasPriceOracle ¶
func NewGasPriceOracle(ngin *Ngin) *GasPriceOracle
NewGasPriceOracle returns a new oracle.
func (*GasPriceOracle) SuggestPrice ¶
func (self *GasPriceOracle) SuggestPrice() *big.Int
SuggestPrice returns the recommended gas price.
type NewBlocksArgs ¶
type NewBlocksArgs struct { IncludeTransactions bool `json:"includeTransactions"` TransactionDetails bool `json:"transactionDetails"` }
NewBlocksArgs allows the user to specify if the returned block should include transactions and in which format.
type Ngin ¶
type Ngin struct { SolcPath string GpoMinGasPrice *big.Int GpoMaxGasPrice *big.Int GpoFullBlockRatio int GpobaseStepDown int GpobaseStepUp int GpobaseCorrectionFactor int Mining bool MinerThreads int NatSpec bool PowTest bool // contains filtered or unexported fields }
func (*Ngin) APIs ¶
APIs returns the collection of RPC services the ethereum package offers. NOTE, some of these services probably need to be moved to somewhere else.
func (*Ngin) AccountManager ¶
func (*Ngin) BlockChain ¶
func (s *Ngin) BlockChain() *core.BlockChain
func (*Ngin) ChainConfig ¶
func (s *Ngin) ChainConfig() *core.ChainConfig
func (*Ngin) Downloader ¶
func (s *Ngin) Downloader() *downloader.Downloader
func (*Ngin) EthVersion ¶
func (*Ngin) HTTPClient ¶
func (self *Ngin) HTTPClient() *httpclient.HTTPClient
HTTPClient returns the light http client used for fetching offchain docs (natspec, source for verification)
func (*Ngin) IsListening ¶
func (*Ngin) NetVersion ¶
func (*Ngin) Protocols ¶
Protocols implements node.Service, returning all the currently configured network protocols to start.
func (*Ngin) ResetWithGenesisBlock ¶
func (*Ngin) SetCoinbase ¶
set in js console via admin interface or wrapper from cli flags
func (*Ngin) Start ¶
Start implements node.Service, starting all internal goroutines needed by the Ngin protocol implementation.
func (*Ngin) Stop ¶
Stop implements node.Service, terminating all internal goroutines used by the Ngin protocol.
func (*Ngin) StopMining ¶
func (s *Ngin) StopMining()
func (*Ngin) WaitForShutdown ¶
func (s *Ngin) WaitForShutdown()
This function will wait for a shutdown and resumes main thread execution
type PMHandlerAddEvent ¶
type PMHandlerAddEvent struct { PMPeersLen int PMBestPeer *peer Peer *peer }
type PMHandlerRemoveEvent ¶
type PMHandlerRemoveEvent struct { PMPeersLen int PMBestPeer *peer Peer *peer }
type PeerInfo ¶
type PeerInfo struct { Version int `json:"version"` // Ngin 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 Ngin sub-protocol metadata known about a connected peer.
type PrivateAccountAPI ¶
type PrivateAccountAPI struct {
// contains filtered or unexported fields
}
PrivateAccountAPI provides an API to access accounts managed by this node. It offers methods to create, (un)lock en list accounts. Some methods accept passwords and are therefore considered private by default.
func NewPrivateAccountAPI ¶
func NewPrivateAccountAPI(e *Ngin) *PrivateAccountAPI
NewPrivateAccountAPI create a new PrivateAccountAPI.
func (*PrivateAccountAPI) EcRecover ¶
EcRecover returns the address for the account that was used to create the signature. Note, this function is compatible with ngin_sign and personal_sign. As such it recovers the address of: hash = keccak256("\x19Ethereum Signed Message:\n"${message length}${message}) addr = ecrecover(hash, signature)
Note, the signature must conform to the secp256k1 curve R, S and V values, where the V value must be be 27 or 28 for legacy reasons.
https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_ecRecover
func (*PrivateAccountAPI) ImportRawKey ¶
ImportRawKey stores the given hex encoded ECDSA key into the key directory, encrypting it with the passphrase.
func (*PrivateAccountAPI) ListAccounts ¶
func (s *PrivateAccountAPI) ListAccounts() []common.Address
ListAccounts will return a list of addresses for accounts this node manages.
func (*PrivateAccountAPI) LockAccount ¶
func (s *PrivateAccountAPI) LockAccount(addr common.Address) bool
LockAccount will lock the account associated with the given address when it's unlocked.
func (*PrivateAccountAPI) NewAccount ¶
func (s *PrivateAccountAPI) NewAccount(password string) (common.Address, error)
NewAccount will create a new account and returns the address for the new account.
func (*PrivateAccountAPI) SendTransaction ¶
func (s *PrivateAccountAPI) SendTransaction(args SendTxArgs, passwd string) (common.Hash, error)
SendTransaction will create a transaction from the given arguments and tries to sign it with the key associated with args.To. If the given passwd isn't able to decrypt the key it fails.
func (*PrivateAccountAPI) Sign ¶
func (s *PrivateAccountAPI) Sign(data hexutil.Bytes, addr common.Address, passwd string) (hexutil.Bytes, error)
Sign calculates an Ngin ECDSA signature for: keccack256("\x19Ethereum Signed Message:\n" + len(message) + message))
Note, the produced signature conforms to the secp256k1 curve R, S and V values, where the V value will be 27 or 28 for legacy reasons.
The key used to calculate the signature is decrypted with the given password.
https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_sign
func (*PrivateAccountAPI) SignAndSendTransaction ¶
func (s *PrivateAccountAPI) SignAndSendTransaction(args SendTxArgs, passwd string) (common.Hash, error)
SignAndSendTransaction was renamed to SendTransaction. This method is deprecated and will be removed in the future. It primary goal is to give clients time to update.
func (*PrivateAccountAPI) UnlockAccount ¶
func (s *PrivateAccountAPI) UnlockAccount(addr common.Address, password string, duration *rpc.HexNumber) (bool, error)
UnlockAccount will unlock the account associated with the given address with the given password for duration seconds. If duration is nil it will use a default of 300 seconds. It returns an indication if the account was unlocked.
type PrivateAdminAPI ¶
type PrivateAdminAPI struct {
// contains filtered or unexported fields
}
PrivateAdminAPI is the collection of Etheruem APIs exposed over the private admin endpoint.
func NewPrivateAdminAPI ¶
func NewPrivateAdminAPI(ngin *Ngin) *PrivateAdminAPI
NewPrivateAdminAPI creates a new API definition for the private admin methods of the Ngin 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 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 *Ngin) *PrivateMinerAPI
NewPrivateMinerAPI create a new RPC service which controls the miner of this node.
func (*PrivateMinerAPI) SetCoinbase ¶
func (s *PrivateMinerAPI) SetCoinbase(coinbase common.Address) bool
SetCoinbase sets the coinbase of the miner
func (*PrivateMinerAPI) SetGasPrice ¶
func (s *PrivateMinerAPI) SetGasPrice(gasPrice rpc.HexNumber) bool
SetGasPrice sets the minimum accepted gas price for the miner.
type ProtocolManager ¶
type ProtocolManager struct { SubProtocols []p2p.Protocol // contains filtered or unexported fields }
func NewProtocolManager ¶
func NewProtocolManager(config *core.ChainConfig, mode downloader.SyncMode, networkId uint64, mux *event.TypeMux, txpool txPool, pow pow.PoW, blockchain *core.BlockChain, chaindb ngindb.Database) (*ProtocolManager, error)
NewProtocolManager returns a new ethereum sub protocol manager. The Ngin sub protocol manages peers capable with the ethereum 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) BroadcastTx ¶
func (pm *ProtocolManager) BroadcastTx(hash common.Hash, tx *types.Transaction)
BroadcastTx will propagate a transaction to all peers which are not known to already have the given transaction.
func (*ProtocolManager) NodeInfo ¶
func (self *ProtocolManager) NodeInfo() *EthNodeInfo
NodeInfo retrieves some protocol metadata about the running host node.
func (*ProtocolManager) Start ¶
func (pm *ProtocolManager) Start(maxPeers int)
func (*ProtocolManager) Stop ¶
func (pm *ProtocolManager) Stop()
type PublicAccountAPI ¶
type PublicAccountAPI struct {
// contains filtered or unexported fields
}
PublicAccountAPI provides an API to access accounts managed by this node. It offers only methods that can retrieve accounts.
func NewPublicAccountAPI ¶
func NewPublicAccountAPI(am *accounts.Manager) *PublicAccountAPI
NewPublicAccountAPI creates a new PublicAccountAPI.
func (*PublicAccountAPI) Accounts ¶
func (s *PublicAccountAPI) Accounts() []accounts.Account
Accounts returns the collection of accounts this node manages
type PublicBlockChainAPI ¶
type PublicBlockChainAPI struct {
// contains filtered or unexported fields
}
PublicBlockChainAPI provides an API to access the Ngin blockchain. It offers only methods that operate on public data that is freely available to anyone.
func NewPublicBlockChainAPI ¶
func NewPublicBlockChainAPI(config *core.ChainConfig, bc *core.BlockChain, m *miner.Miner, chainDb ngindb.Database, gpo *GasPriceOracle, eventMux *event.TypeMux, am *accounts.Manager) *PublicBlockChainAPI
NewPublicBlockChainAPI creates a new Etheruem blockchain API.
func (*PublicBlockChainAPI) BlockNumber ¶
func (s *PublicBlockChainAPI) BlockNumber() *big.Int
BlockNumber returns the block number of the chain head.
func (*PublicBlockChainAPI) Call ¶
func (s *PublicBlockChainAPI) Call(args CallArgs, blockNr rpc.BlockNumber) (string, error)
Call executes the given transaction on the state for the given block number. It doesn't make and changes in the state/blockchain and is useful to execute and retrieve values.
func (*PublicBlockChainAPI) EstimateGas ¶
func (s *PublicBlockChainAPI) EstimateGas(args CallArgs) (*rpc.HexNumber, error)
EstimateGas returns an estimate of the amount of gas needed to execute the given transaction.
func (*PublicBlockChainAPI) GetBalance ¶
func (s *PublicBlockChainAPI) GetBalance(address common.Address, blockNr rpc.BlockNumber) (*big.Int, error)
GetBalance returns the amount of wei for the given address in the state of the given block number. The rpc.LatestBlockNumber and rpc.PendingBlockNumber meta block numbers are also allowed.
func (*PublicBlockChainAPI) GetBlockByHash ¶
func (s *PublicBlockChainAPI) GetBlockByHash(blockHash common.Hash, fullTx bool) (map[string]interface{}, error)
GetBlockByHash returns the requested block. When fullTx is true all transactions in the block are returned in full detail, otherwise only the transaction hash is returned.
func (*PublicBlockChainAPI) GetBlockByNumber ¶
func (s *PublicBlockChainAPI) GetBlockByNumber(blockNr rpc.BlockNumber, fullTx bool) (map[string]interface{}, error)
GetBlockByNumber returns the requested block. When blockNr is -1 the chain head is returned. When fullTx is true all transactions in the block are returned in full detail, otherwise only the transaction hash is returned.
func (*PublicBlockChainAPI) GetCode ¶
func (s *PublicBlockChainAPI) GetCode(address common.Address, blockNr rpc.BlockNumber) (string, error)
GetCode returns the code stored at the given address in the state for the given block number.
func (*PublicBlockChainAPI) GetStorageAt ¶
func (s *PublicBlockChainAPI) GetStorageAt(address common.Address, key string, blockNr rpc.BlockNumber) (string, error)
GetStorageAt returns the storage from the state at the given address, key and block number. The rpc.LatestBlockNumber and rpc.PendingBlockNumber meta block numbers are also allowed.
func (*PublicBlockChainAPI) GetUncleByBlockHashAndIndex ¶
func (s *PublicBlockChainAPI) GetUncleByBlockHashAndIndex(blockHash common.Hash, index rpc.HexNumber) (map[string]interface{}, error)
GetUncleByBlockHashAndIndex returns the uncle block for the given block hash and index. When fullTx is true all transactions in the block are returned in full detail, otherwise only the transaction hash is returned.
func (*PublicBlockChainAPI) GetUncleByBlockNumberAndIndex ¶
func (s *PublicBlockChainAPI) GetUncleByBlockNumberAndIndex(blockNr rpc.BlockNumber, index rpc.HexNumber) (map[string]interface{}, error)
GetUncleByBlockNumberAndIndex returns the uncle block for the given block hash and index. When fullTx is true all transactions in the block are returned in full detail, otherwise only the transaction hash is returned.
func (*PublicBlockChainAPI) GetUncleCountByBlockHash ¶
func (s *PublicBlockChainAPI) GetUncleCountByBlockHash(blockHash common.Hash) *rpc.HexNumber
GetUncleCountByBlockHash returns number of uncles in the block for the given block hash
func (*PublicBlockChainAPI) GetUncleCountByBlockNumber ¶
func (s *PublicBlockChainAPI) GetUncleCountByBlockNumber(blockNr rpc.BlockNumber) *rpc.HexNumber
GetUncleCountByBlockNumber returns number of uncles in the block for the given block number
func (*PublicBlockChainAPI) NewBlocks ¶
func (s *PublicBlockChainAPI) NewBlocks(ctx context.Context, args NewBlocksArgs) (rpc.Subscription, error)
NewBlocks triggers a new block event each time a block is appended to the chain. It accepts an argument which allows the caller to specify whether the output should contain transactions and in what format.
func (*PublicBlockChainAPI) Sign ¶
Sign signs the given hash using the key that matches the address. The key must be unlocked in order to sign the hash.
func (*PublicBlockChainAPI) TraceCall ¶
func (s *PublicBlockChainAPI) TraceCall(args CallArgs, blockNr rpc.BlockNumber) (*ExecutionResult, error)
TraceCall executes a call and returns the amount of gas and optionally returned values.
type PublicDebugAPI ¶
type PublicDebugAPI struct {
// contains filtered or unexported fields
}
PublicDebugAPI is the collection of Etheruem APIs exposed over the public debugging endpoint.
func NewPublicDebugAPI ¶
func NewPublicDebugAPI(ngin *Ngin) *PublicDebugAPI
NewPublicDebugAPI creates a new API definition for the public debug methods of the Ethereum service.
func (*PublicDebugAPI) AccountExist ¶
AccountExist checks whether an address is considered exists at a given block.
func (*PublicDebugAPI) DumpBlock ¶
func (api *PublicDebugAPI) DumpBlock(number uint64) (state.Dump, error)
DumpBlock retrieves the entire state of the database at a given block. TODO: update to be able to dump for specific addresses?
func (*PublicDebugAPI) GetBlockRlp ¶
func (api *PublicDebugAPI) GetBlockRlp(number uint64) (string, error)
GetBlockRlp retrieves the RLP encoded for of a single block.
func (*PublicDebugAPI) Metrics ¶
func (api *PublicDebugAPI) Metrics(raw bool) (map[string]interface{}, error)
Metrics return all available registered metrics for the client. See https://github.com/ethereumproject/go-ethereum/wiki/Metrics-and-Monitoring for prophetic documentation.
func (*PublicDebugAPI) PrintBlock ¶
func (api *PublicDebugAPI) PrintBlock(number uint64) (string, error)
PrintBlock retrieves a block and returns its pretty printed form.
func (*PublicDebugAPI) TraceTransaction ¶
func (s *PublicDebugAPI) TraceTransaction(txHash common.Hash) (*ExecutionResult, error)
TraceTransaction returns the amount of gas and execution result of the given transaction.
func (*PublicDebugAPI) Verbosity ¶
func (api *PublicDebugAPI) Verbosity(n uint64) (int, error)
Verbosity implements api method debug_verbosity, enabling setting global logging verbosity on the fly. Note that it will NOT allow setting verbosity '0', which is effectively 'off'. In place of ability to receive 0 as a functional parameter, debug.verbosity() -> debug.verbosity(0) -> glog.GetVerbosity(). creates a shorthand/convenience method as a "getter" function returning the current value of the verbosity setting.
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 *Ngin) *PublicMinerAPI
NewPublicMinerAPI create a new PublicMinerAPI instance.
func (*PublicMinerAPI) GetWork ¶
func (s *PublicMinerAPI) GetWork() (work [3]string, err 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 (s *PublicMinerAPI) Mining() bool
Mining returns an indication if this node is currently mining.
func (*PublicMinerAPI) SubmitHashrate ¶
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 ¶
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 PublicNetAPI ¶
type PublicNetAPI struct {
// contains filtered or unexported fields
}
PublicNetAPI offers network related RPC methods
func NewPublicNetAPI ¶
func NewPublicNetAPI(net *p2p.Server, networkVersion int) *PublicNetAPI
NewPublicNetAPI creates a new net API instance.
func (*PublicNetAPI) Listening ¶
func (s *PublicNetAPI) Listening() bool
Listening returns an indication if the node is listening for network connections.
func (*PublicNetAPI) PeerCount ¶
func (s *PublicNetAPI) PeerCount() *rpc.HexNumber
PeerCount returns the number of connected peers
func (*PublicNetAPI) Version ¶
func (s *PublicNetAPI) Version() string
Version returns the current ethereum protocol version.
type PublicNginAPI ¶
type PublicNginAPI struct {
// contains filtered or unexported fields
}
PublicNginAPI provides an API to access Ngin related information. It offers only methods that operate on public data that is freely available to anyone.
func NewPublicNginAPI ¶
func NewPublicNginAPI(ngin *Ngin) *PublicNginAPI
NewPublicNginAPI creates a new Ngin protocol API.
func (*PublicNginAPI) ChainId ¶ added in v0.1.3
func (s *PublicNginAPI) ChainId() *big.Int
ChainId returns the chain-configured value for EIP-155 chain id, used in signing protected txs. If EIP-155 is not configured it will return 0. Number will be returned as a string in hexadecimal format. 61 - Mainnet $((0x3d)) 62 - Testnet $((0x3e))
func (*PublicNginAPI) Coinbase ¶ added in v0.1.3
func (s *PublicNginAPI) Coinbase() (common.Address, error)
Coinbase is the address that mining rewards will be send to
func (*PublicNginAPI) CompileSolidity ¶ added in v0.1.3
CompileSolidity compiles the given solidity source
func (*PublicNginAPI) GasPrice ¶ added in v0.1.3
func (s *PublicNginAPI) GasPrice() *big.Int
GasPrice returns a suggestion for a gas price.
func (*PublicNginAPI) GetCompilers ¶ added in v0.1.3
func (s *PublicNginAPI) GetCompilers() ([]string, error)
GetCompilers returns the collection of available smart contract compilers
func (*PublicNginAPI) Hashrate ¶ added in v0.1.3
func (s *PublicNginAPI) Hashrate() *rpc.HexNumber
Hashrate returns the POW hashrate
func (*PublicNginAPI) ProtocolVersion ¶ added in v0.1.3
func (s *PublicNginAPI) ProtocolVersion() *rpc.HexNumber
ProtocolVersion returns the current Ngin protocol version this node supports
func (*PublicNginAPI) Syncing ¶ added in v0.1.3
func (s *PublicNginAPI) Syncing() (interface{}, error)
Syncing returns false in case the node is currently not syncing with the network. It can be up to date or has not yet received the latest block headers from its pears. In case it is synchronizing: - startingBlock: block number this node started to synchronise from - currentBlock: block number this node is currently importing - highestBlock: block number of the highest block header this node has received from peers - pulledStates: number of state entries processed until now - knownStates: number of known state entries that still need to be pulled
type PublicNgindAPI ¶ added in v0.1.4
type PublicNgindAPI struct {
// contains filtered or unexported fields
}
PublicDebugAPI is the collection of Etheruem APIs exposed over the public debugging endpoint.
func NewPublicNgindAPI ¶ added in v0.1.4
func NewPublicNgindAPI(ngin *Ngin) *PublicNgindAPI
NewPublicDebugAPI creates a new API definition for the public debug methods of the Ethereum service.
func (*PublicNgindAPI) BuildATXI ¶ added in v0.1.4
func (api *PublicNgindAPI) BuildATXI(start, stop, step rpc.BlockNumber) (bool, error)
func (*PublicNgindAPI) GetATXIBuildStatus ¶ added in v0.1.4
func (api *PublicNgindAPI) GetATXIBuildStatus() (*core.AtxiProgressT, error)
func (*PublicNgindAPI) GetAddressTransactions ¶ added in v0.1.4
func (api *PublicNgindAPI) GetAddressTransactions(address common.Address, blockStartN uint64, blockEndN rpc.BlockNumber, toOrFrom string, txKindOf string, pagStart, pagEnd int, reverse bool) (list []string, err error)
AddressTransactions gets transactions for a given address. Optional values include start and stop block numbers, and to/from/both value for tx/address relation. Returns a slice of strings of transactions hashes.
func (*PublicNgindAPI) GetTransactionsByAddress ¶ added in v0.1.4
func (api *PublicNgindAPI) GetTransactionsByAddress(address common.Address, blockStartN uint64, blockEndN rpc.BlockNumber, toOrFrom string, txKindOf string, pagStart, pagEnd int, reverse bool) (list []string, err error)
GetTransactionsByAddress is an alias for GetAddressTransactions which aligns more closely with established ngin_transaction api namespace
type PublicTransactionPoolAPI ¶
type PublicTransactionPoolAPI struct {
// contains filtered or unexported fields
}
PublicTransactionPoolAPI exposes methods for the RPC interface
func NewPublicTransactionPoolAPI ¶
func NewPublicTransactionPoolAPI(ngin *Ngin) *PublicTransactionPoolAPI
NewPublicTransactionPoolAPI creates a new RPC service with methods specific for the transaction pool.
func (*PublicTransactionPoolAPI) GetBlockTransactionCountByHash ¶
func (s *PublicTransactionPoolAPI) GetBlockTransactionCountByHash(blockHash common.Hash) *rpc.HexNumber
GetBlockTransactionCountByHash returns the number of transactions in the block with the given hash.
func (*PublicTransactionPoolAPI) GetBlockTransactionCountByNumber ¶
func (s *PublicTransactionPoolAPI) GetBlockTransactionCountByNumber(blockNr rpc.BlockNumber) *rpc.HexNumber
GetBlockTransactionCountByNumber returns the number of transactions in the block with the given block number.
func (*PublicTransactionPoolAPI) GetTransactionByBlockHashAndIndex ¶
func (s *PublicTransactionPoolAPI) GetTransactionByBlockHashAndIndex(blockHash common.Hash, index rpc.HexNumber) (*RPCTransaction, error)
GetTransactionByBlockHashAndIndex returns the transaction for the given block hash and index.
func (*PublicTransactionPoolAPI) GetTransactionByBlockNumberAndIndex ¶
func (s *PublicTransactionPoolAPI) GetTransactionByBlockNumberAndIndex(blockNr rpc.BlockNumber, index rpc.HexNumber) (*RPCTransaction, error)
GetTransactionByBlockNumberAndIndex returns the transaction for the given block number and index.
func (*PublicTransactionPoolAPI) GetTransactionByHash ¶
func (s *PublicTransactionPoolAPI) GetTransactionByHash(txHash common.Hash) (*RPCTransaction, error)
GetTransactionByHash returns the transaction for the given hash
func (*PublicTransactionPoolAPI) GetTransactionCount ¶
func (s *PublicTransactionPoolAPI) GetTransactionCount(address common.Address, blockNr rpc.BlockNumber) (*rpc.HexNumber, error)
GetTransactionCount returns the number of transactions the given address has sent for the given block number
func (*PublicTransactionPoolAPI) GetTransactionReceipt ¶
func (s *PublicTransactionPoolAPI) GetTransactionReceipt(txHash common.Hash) (map[string]interface{}, error)
GetTransactionReceipt returns the transaction receipt for the given transaction hash.
func (*PublicTransactionPoolAPI) NewPendingTransactions ¶
func (s *PublicTransactionPoolAPI) NewPendingTransactions(ctx context.Context) (rpc.Subscription, error)
NewPendingTransactions creates a subscription that is triggered each time a transaction enters the transaction pool and is send from one of the transactions this nodes manages.
func (*PublicTransactionPoolAPI) PendingTransactions ¶
func (s *PublicTransactionPoolAPI) PendingTransactions() []*RPCTransaction
PendingTransactions returns the transactions that are in the transaction pool and have a from address that is one of the accounts this node manages.
func (*PublicTransactionPoolAPI) Resend ¶
func (s *PublicTransactionPoolAPI) Resend(tx Tx, gasPrice, gasLimit *rpc.HexNumber) (common.Hash, error)
Resend accepts an existing transaction and a new gas price and limit. It will remove the given transaction from the pool and reinsert it with the new gas price and limit.
func (*PublicTransactionPoolAPI) SendRawTransaction ¶
func (s *PublicTransactionPoolAPI) SendRawTransaction(encodedTx string) (string, error)
SendRawTransaction will add the signed transaction to the transaction pool. The sender is responsible for signing the transaction and using the correct nonce.
func (*PublicTransactionPoolAPI) SendTransaction ¶
func (s *PublicTransactionPoolAPI) SendTransaction(args SendTxArgs) (common.Hash, error)
SendTransaction creates a transaction for the given argument, sign it and submit it to the transaction pool.
func (*PublicTransactionPoolAPI) SignTransaction ¶
func (s *PublicTransactionPoolAPI) SignTransaction(args SignTransactionArgs) (*SignTransactionResult, error)
SignTransaction will sign the given transaction with the from account. The node needs to have the private key of the account corresponding with the given from address and it needs to be unlocked.
type PublicTxPoolAPI ¶
type PublicTxPoolAPI struct {
// contains filtered or unexported fields
}
PublicTxPoolAPI offers and API for the transaction pool. It only operates on data that is non confidential.
func NewPublicTxPoolAPI ¶
func NewPublicTxPoolAPI(e *Ngin) *PublicTxPoolAPI
NewPublicTxPoolAPI creates a new tx pool service that gives information about the transaction pool.
func (*PublicTxPoolAPI) Content ¶
func (s *PublicTxPoolAPI) Content() map[string]map[string]map[string][]*RPCTransaction
Content returns the transactions contained within the transaction pool.
type RPCTransaction ¶
type RPCTransaction struct { BlockHash common.Hash `json:"blockHash"` BlockNumber *rpc.HexNumber `json:"blockNumber"` From common.Address `json:"from"` Gas *rpc.HexNumber `json:"gas"` GasPrice *rpc.HexNumber `json:"gasPrice"` Hash common.Hash `json:"hash"` Input string `json:"input"` Nonce *rpc.HexNumber `json:"nonce"` To *common.Address `json:"to"` TransactionIndex *rpc.HexNumber `json:"transactionIndex"` Value *rpc.HexNumber `json:"value"` ReplayProtected bool `json:"replayProtected"` ChainId *big.Int `json:"chainId,omitempty"` V *rpc.HexNumber `json:"v"` R *rpc.HexNumber `json:"r"` S *rpc.HexNumber `json:"s"` }
RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction
type SendTxArgs ¶
type SendTxArgs struct { From common.Address `json:"from"` To *common.Address `json:"to"` Gas *rpc.HexNumber `json:"gas"` GasPrice *rpc.HexNumber `json:"gasPrice"` Value *rpc.HexNumber `json:"value"` Data string `json:"data"` Nonce *rpc.HexNumber `json:"nonce"` }
SendTxArgs represents the arguments to sumbit a new transaction into the transaction pool.
type SignTransactionArgs ¶
type SignTransactionArgs struct { From common.Address To *common.Address Nonce *rpc.HexNumber Value *rpc.HexNumber Gas *rpc.HexNumber GasPrice *rpc.HexNumber Data string BlockNumber int64 }
SignTransactionArgs represents the arguments to sign a transaction.
type SignTransactionResult ¶
SignTransactionResult represents a RLP encoded signed transaction.
type Tx ¶
type Tx struct { To *common.Address `json:"to"` From common.Address `json:"from"` Nonce *rpc.HexNumber `json:"nonce"` Value *rpc.HexNumber `json:"value"` Data string `json:"data"` GasLimit *rpc.HexNumber `json:"gas"` GasPrice *rpc.HexNumber `json:"gasPrice"` Hash common.Hash `json:"hash"` // contains filtered or unexported fields }
Tx is a helper object for argument and return values
func (*Tx) UnmarshalJSON ¶
UnmarshalJSON parses JSON data into tx.
Source Files ¶
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. |