api

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 2, 2020 License: LGPL-3.0 Imports: 35 Imported by: 2

Documentation

Overview

Fractal implements the Fractal full node service.

Fractal implements the Fractal full node service.

Fractal implements the Fractal full node service.

Fractal implements the Fractal full node service.

Fractal implements the Fractal full node service.

Fractal implements the Fractal full node service.

Fractal implements the Fractal full node service.

Fractal implements the Fractal full node service.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBatchPackNotEnabled = errors.New("batch pack not enabled")
)
View Source
var ErrNodeStopped = errors.New("node not started")

Functions

func ReadTransaction

func ReadTransaction(bc *chain.BlockChain, hash common.Hash) (*types.Transaction, common.Hash)

ReadTransaction retrieves a specific transaction from the database, along with its added positional metadata.

Types

type AdminAPI

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

AdminAPI is the collection of administrative API methods.

func NewAdminAPI

func NewAdminAPI(server *p2p.Server, ftl fractal) *AdminAPI

NewAdminAPI creates a new AdminAPI.

func (*AdminAPI) AddBlack

func (api *AdminAPI) AddBlack(url string) (bool, error)

func (*AdminAPI) AddPeer

func (api *AdminAPI) AddPeer(url string) (bool, error)

AddPeer requests connecting to a remote node, and also maintaining the new connection at all times, even reconnecting if it is lost.

func (*AdminAPI) AddTrustedPeer

func (api *AdminAPI) AddTrustedPeer(url string) (bool, error)

AddTrustedPeer allows a remote node to always connect, even if slots are full

func (*AdminAPI) GenerateMiningKey

func (api *AdminAPI) GenerateMiningKey(address common.Address) keys.MiningPubkey

func (*AdminAPI) IsPacking

func (api *AdminAPI) IsPacking() bool

func (*AdminAPI) Mining

func (api *AdminAPI) Mining() bool

Mining returns an indication if this node is currently mining.

func (*AdminAPI) RemoveBlack

func (api *AdminAPI) RemoveBlack(url string) (bool, error)

func (*AdminAPI) RemovePeer

func (api *AdminAPI) RemovePeer(url string) (bool, error)

RemovePeer disconnects from a remote node if the connection exists

func (*AdminAPI) RemoveTrustedPeer

func (api *AdminAPI) RemoveTrustedPeer(url string) (bool, error)

RemoveTrustedPeer removes a remote node from the trusted peer set, but it does not disconnect it automatically.

func (*AdminAPI) StartMining

func (api *AdminAPI) StartMining() error

Start the miner

func (*AdminAPI) StartPacking

func (api *AdminAPI) StartPacking(packerIndex uint32)

func (*AdminAPI) StopMining

func (api *AdminAPI) StopMining()

Stop the miner

func (*AdminAPI) StopPacking

func (api *AdminAPI) StopPacking()

type BlockChainAPI

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

BlockChainAPI provides an API to access the Fractal blockchain. It offers only methods that operate on public data that is freely available to anyone.

func NewBlockChainAPI

func NewBlockChainAPI(ftl fractal) *BlockChainAPI

NewBlockChainAPI creates a new Fractal blockchain API.

func (*BlockChainAPI) BlockHeight

func (s *BlockChainAPI) BlockHeight() hexutil.Uint64

BlockHeight returns the block heigth of the chain head.

func (*BlockChainAPI) Genesis

func (s *BlockChainAPI) Genesis() *types.Block

Genesis returns the first block in the chain.

func (*BlockChainAPI) GetAncestorBlocks

func (s *BlockChainAPI) GetAncestorBlocks(fullHash common.Hash, num uint32) types.Blocks

func (*BlockChainAPI) GetBackwardBlocks

func (s *BlockChainAPI) GetBackwardBlocks(fullHash common.Hash, num uint32) types.Blocks

func (*BlockChainAPI) GetBalance

func (s *BlockChainAPI) GetBalance(ctx context.Context, address common.Address, blockHashStr string) (*hexutil.Big, error)

GetBalance returns the amount of nFra for the given address in the state of the given block

func (*BlockChainAPI) GetBlock

func (s *BlockChainAPI) GetBlock(hash common.Hash) *types.Block

GetBlock returns the block with the hash.

func (*BlockChainAPI) GetBlockByHeight

func (s *BlockChainAPI) GetBlockByHeight(height hexutil.Uint64) *types.Block

func (*BlockChainAPI) GetCode

func (s *BlockChainAPI) GetCode(ctx context.Context, address common.Address, blockHashStr string) (hexutil.Bytes, error)

func (*BlockChainAPI) GetContractOwner

func (s *BlockChainAPI) GetContractOwner(ctx context.Context, contractAddress common.Address) (common.Address, error)

func (*BlockChainAPI) GetDescendantBlocks

func (s *BlockChainAPI) GetDescendantBlocks(fullHash common.Hash, num uint32) types.Blocks

func (*BlockChainAPI) GetNearbyBlocks

func (s *BlockChainAPI) GetNearbyBlocks(fullHash common.Hash, num uint32) types.Blocks

func (*BlockChainAPI) GetStorageAt

func (s *BlockChainAPI) GetStorageAt(ctx context.Context, address common.Address, table string, key hexutil.Bytes, blockHashStr string) (hexutil.Bytes, error)

func (*BlockChainAPI) GetTransferBlackList

func (s *BlockChainAPI) GetTransferBlackList(ctx context.Context, blockHashStr string) (string, error)

func (*BlockChainAPI) GetTransferWhiteList

func (s *BlockChainAPI) GetTransferWhiteList(ctx context.Context, blockHashStr string) (string, error)

func (*BlockChainAPI) HeadBlock

func (s *BlockChainAPI) HeadBlock() *types.Block

HeadBlock returns the head block in the chain.

func (*BlockChainAPI) SubNewBlock

func (s *BlockChainAPI) SubNewBlock(ctx context.Context) (*rpcserver.Subscription, error)

SubNewBlock provides information when new block arrived

type CallResult

type CallResult struct {
	Logs    []*types.Log
	GasUsed hexutil.Uint64
}

type FilterAPI

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

func NewFilterAPI

func NewFilterAPI(ftl fractal) *FilterAPI

type FilterCriteria

type FilterCriteria struct {
	BlockHash       *common.Hash     // used by ftl_getLogs, return logs only from block with this hash
	FromBlockHeight *big.Int         // beginning of the queried range, nil means genesis block
	ToBlockHeight   *big.Int         // end of the range, nil means latest block
	Addresses       []common.Address // restricts matches to events created by specific contracts

	// The Topic list restricts matches to particular event topics. Each event has a list
	// of topics. Topics matches a prefix of that list. An empty element slice matches any
	// topic. Non-empty elements represent an alternative that matches any of the
	// contained topics.
	//
	// Examples:
	// {} or nil          matches any topic list
	// {{A}}              matches topic A in first position
	// {{}, {B}}          matches any topic in first position, B in second position
	// {{A}, {B}}         matches topic A in first position, B in second position
	// {{A, B}}, {C, D}}  matches topic (A OR B) in first position, (C OR D) in second position
	Topics [][]common.Hash
}

type FractalAPI

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

FractalAPI provides an API to access Fractal related information. It offers only methods that operate on public data that is freely available to anyone.

func NewFractalAPI

func NewFractalAPI(ftl fractal) *FractalAPI

NewFractalAPI creates a new Fractal protocol API.

func (*FractalAPI) ChainId

func (s *FractalAPI) ChainId() hexutil.Uint64

func (*FractalAPI) Coinbase

func (s *FractalAPI) Coinbase() common.Address

Coinbase is the address that mining rewards will be send to

func (*FractalAPI) ProtocolVersion

func (s *FractalAPI) ProtocolVersion() hexutil.Uint

ProtocolVersion returns the current Fractal protocol version this node supports

type NetAPI

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

NetAPI offers network related RPC methods

func NewNetAPI

func NewNetAPI(server *p2p.Server, networkVersion uint64) *NetAPI

NewNetAPI creates a new net API instance.

func (*NetAPI) Listening

func (s *NetAPI) Listening() bool

Listening returns an indication if the node is listening for network connections.

func (*NetAPI) NodeInfo

func (s *NetAPI) NodeInfo() (*p2p.NodeInfo, error)

NodeInfo retrieves all the information we know about the host node at the protocol granularity.

func (*NetAPI) PeerCount

func (s *NetAPI) PeerCount() (hexutil.Uint, error)

PeerCount returns the number of connected peers

func (*NetAPI) PeerEvents

func (s *NetAPI) PeerEvents(ctx context.Context) (*rpcserver.Subscription, error)

PeerEvents creates an RPC subscription which receives peer events from the node's p2p.Server

func (*NetAPI) Peers

func (s *NetAPI) Peers() ([]*p2p.PeerInfo, error)

Peers retrieves all the information we know about each individual peer at the protocol granularity.

func (*NetAPI) Version

func (s *NetAPI) Version() string

Version returns the current ftl protocol version.

type PackerAPI

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

func NewPackerAPI

func NewPackerAPI(chain *chain.BlockChain, packer packer.Packer) *PackerAPI

func (*PackerAPI) GetTxPackageByHash

func (s *PackerAPI) GetTxPackageByHash(hash common.Hash) *types.TxPackage

func (*PackerAPI) SendRawTransaction

func (s *PackerAPI) SendRawTransaction(ctx context.Context, encodedTx hexutil.Bytes) (common.Hash, error)

func (*PackerAPI) SendRawTransactions

func (s *PackerAPI) SendRawTransactions(ctx context.Context, encodedTxs hexutil.Bytes) ([]string, error)

type RPCTransaction

type RPCTransaction struct {
	From      common.Address  `json:"from"`
	Hash      common.Hash     `json:"hash"`
	Nonce     hexutil.Uint64  `json:"nonce"`
	To        *common.Address `json:"to"`
	Value     *hexutil.Big    `json:"value"`
	Price     *hexutil.Big    `json:"gasPrice"`
	GasLimit  hexutil.Uint64  `json:"gas"`
	Payload   hexutil.Bytes   `json:"input"`
	Broadcast bool            `json:"broadcast"`
	V         *hexutil.Big    `json:"v"`
	R         *hexutil.Big    `json:"r"`
	S         *hexutil.Big    `json:"s"`

	BlockHash common.Hash    `json:"blockHash"`
	Receipt   *types.Receipt `json:"receipt"`
}

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      *hexutil.Uint64 `json:"gas"`
	GasPrice *hexutil.Big    `json:"gasPrice"`
	Value    *hexutil.Big    `json:"value"`
	Nonce    *hexutil.Uint64 `json:"nonce"`
	// We accept "data" and "input" for backwards-compatibility reasons. "input" is the
	// newer name and should be preferred by clients.
	Data *hexutil.Bytes `json:"data"`
}

type StatusResult

type StatusResult struct {
	Status         string
	FastSyncMode   string
	FastSyncStatus string
}

type SynchronizerAPI

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

func NewSynchronizerAPI

func NewSynchronizerAPI(ftl fractal) *SynchronizerAPI

func (*SynchronizerAPI) Status

func (s *SynchronizerAPI) Status() StatusResult

type SynchronizerTestAPI

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

SynchronizerTestAPI provides an API to change config of sync

func NewSynchronizerTestAPI

func NewSynchronizerTestAPI(ftl fractal) *SynchronizerTestAPI

NewSynchronizerTestAPI creates a new SynchonizerTestAPI.

func (*SynchronizerTestAPI) ChangeLongTimeOutOfFixPointFinish

func (s *SynchronizerTestAPI) ChangeLongTimeOutOfFixPointFinish(time int) string

func (*SynchronizerTestAPI) ChangeLongTimeOutOfFixPointPreBlock

func (s *SynchronizerTestAPI) ChangeLongTimeOutOfFixPointPreBlock(time int) string

func (*SynchronizerTestAPI) ChangeLongTimeOutOfFullfillLongList

func (s *SynchronizerTestAPI) ChangeLongTimeOutOfFullfillLongList(time int) string

func (*SynchronizerTestAPI) ChangeLongTimeOutOfIntevalList

func (s *SynchronizerTestAPI) ChangeLongTimeOutOfIntevalList(time int) string

func (*SynchronizerTestAPI) ChangeLongTimeOutOfLongList

func (s *SynchronizerTestAPI) ChangeLongTimeOutOfLongList(time int) string

func (*SynchronizerTestAPI) ChangeShortTimeOutOfShortLists

func (s *SynchronizerTestAPI) ChangeShortTimeOutOfShortLists(time int) string

func (*SynchronizerTestAPI) ChangeShortTimeOutOfSyncVeryHigh

func (s *SynchronizerTestAPI) ChangeShortTimeOutOfSyncVeryHigh(time int) string

type TxPoolAPI

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

TxPoolAPI offers and API for the transaction pool. It only operates on data that is non confidential.

func NewTxPoolAPI

func NewTxPoolAPI(ftl fractal, config *config.Config) *TxPoolAPI

NewTxPoolAPI creates a new tx pool service that gives information about the transaction pool.

func (*TxPoolAPI) Call

func (s *TxPoolAPI) Call(args SendTxArgs) (CallResult, error)

func (*TxPoolAPI) Content

func (s *TxPoolAPI) Content() map[string]map[string]map[string]*RPCTransaction

Content returns the transactions contained within the transaction pool.

func (*TxPoolAPI) EncodeAction

func (s *TxPoolAPI) EncodeAction(abi hexutil.Bytes, action string, args string) hexutil.Bytes

func (*TxPoolAPI) GasPrice

func (s *TxPoolAPI) GasPrice() *hexutil.Big

func (*TxPoolAPI) GetBlockTransactionCountByHash

func (s *TxPoolAPI) GetBlockTransactionCountByHash(ctx context.Context, blockHash common.Hash) *hexutil.Uint

GetBlockTransactionCountByHash returns the number of transactions in the block with the given hash.

func (*TxPoolAPI) GetTransactionByHash

func (s *TxPoolAPI) GetTransactionByHash(ctx context.Context, hash common.Hash) *RPCTransaction

GetTransactionByHash returns the transaction for the given hash

func (*TxPoolAPI) GetTransactionNonce

func (s *TxPoolAPI) GetTransactionNonce(ctx context.Context, address common.Address) *hexutil.Uint64

func (*TxPoolAPI) Inspect

func (s *TxPoolAPI) Inspect() map[string]map[string]map[string]string

Inspect retrieves the content of the transaction pool and flattens it into an easily inspectable list.

func (*TxPoolAPI) PendingTransactions

func (s *TxPoolAPI) PendingTransactions() types.Transactions

func (*TxPoolAPI) SendRawTransaction

func (s *TxPoolAPI) SendRawTransaction(ctx context.Context, encodedTx hexutil.Bytes) (common.Hash, error)

func (*TxPoolAPI) SendRawTransactionPeriodically

func (s *TxPoolAPI) SendRawTransactionPeriodically(ctx context.Context, encodedTx hexutil.Bytes) (common.Hash, error)

func (*TxPoolAPI) Status

func (s *TxPoolAPI) Status() map[string]hexutil.Uint

Status returns the number of pending and queued transaction in the pool.

Jump to

Keyboard shortcuts

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