light

package
v0.0.0-...-84a2c7a Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2020 License: GPL-3.0, GPL-3.0 Imports: 47 Imported by: 0

Documentation

Overview

Package les implements the Light Ethereum Subprotocol.

Package les implements the Light Palletone Subprotocol.

Package les implements the Light Palletone Subprotocol.

Package les implements the Light Ethereum Subprotocol.

Package les implements the Light Ethereum Subprotocol.

Package les implements the Light Ethereum Subprotocol.

  • @author PalletOne core developer Jiyou Wang <dev@pallet.one>

  • @date 2018

    This file is part of go-palletone. go-palletone is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. go-palletone is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with go-palletone. If not, see <http://www.gnu.org/licenses/>.

  • @author PalletOne core developer Jiyou Wang <dev@pallet.one>

  • @date 2018

Index

Constants

View Source
const (
	NetworkId          = 1
	ProtocolMaxMsgSize = 10 * 1024 * 1024 // Maximum cap on the size of a protocol message
)
View Source
const (
	// Protocol messages belonging to LPV1
	StatusMsg          = 0x00
	AnnounceMsg        = 0x01
	GetBlockHeadersMsg = 0x02
	BlockHeadersMsg    = 0x03
	GetUTXOsMsg        = 0x04
	UTXOsMsg           = 0x05
	GetProofsMsg       = 0x06
	ProofsMsg          = 0x07
	SendTxMsg          = 0x08
	GetLeafNodesMsg    = 0x09
	LeafNodesMsg       = 0x0a
)

les protocol message codes

View Source
const (
	ErrMsgTooLarge = iota
	ErrDecode
	ErrInvalidMsgCode
	ErrProtocolVersionMismatch
	ErrNetworkIdMismatch
	ErrGenesisBlockMismatch
	ErrNoStatusMsg
	ErrExtraStatusMsg
	ErrSuspendedPeer
	ErrUselessPeer
	ErrRequestRejected
	ErrUnexpectedResponse
	ErrInvalidResponse
	ErrTooManyTimeouts
	ErrMissingKey
)
View Source
const (
	CodeErr        = "error"
	CodeOK         = "ok"
	CodeTimeout    = "timeout"
	CodeEmptyPeers = "empty peers"
)
View Source
const (
	OKUTXOsSync   = 0
	ERRUTXOsExist = 3
)
View Source
const (
	ERRSPVOTHERS  = 1
	ERRSPVTIMEOUT = 2
)
View Source
const (
	MaxHeaderFetch = 192 // Amount of block headers to be fetched per retrieval request

)

Variables

View Source
var (
	ClientProtocolVersions = []uint{lpv1}
	ServerProtocolVersions = []uint{lpv1}
)

Supported versions of the les protocol (first is primary)

View Source
var ProtocolLengths = map[uint]uint64{/* contains filtered or unexported fields */}

Number of implemented message corresponding to different protocol versions.

Functions

func NewProofReq

func NewProofReq(txhash common.Hash, valid *Validation) *proofReq

func NewUTXOsReq

func NewUTXOsReq(addr string, utxosync *UtxosSync) *utxosReq

func NewUtxosRespData

func NewUtxosRespData() *utxosRespData

Types

type BlockChain

type BlockChain interface {
	//Config() *params.ChainConfig
	HasHeader(hash common.Hash, number uint64) bool
	GetHeader(hash common.Hash, number uint64) *modules.Header
	GetHeaderByHash(hash common.Hash) *modules.Header
	CurrentHeader() *modules.Header
	GetTd(hash common.Hash, number uint64) *big.Int
	//State() (*state.StateDB, error)
	InsertHeaderChain(chain []*modules.Header, checkFreq int) (int, error)
	Rollback(chain []common.Hash)
	GetHeaderByNumber(number uint64) *modules.Header
	GetBlockHashesFromHash(hash common.Hash, max uint64) []common.Hash
	//Genesis() *types.Block
	SubscribeChainHeadEvent(ch chan<- modules.ChainHeadEvent) event.Subscription
}

type CodeData

type CodeData []struct {
	Value []byte
}

CodeData is the network response packet for a node data retrieval.

type LesApiBackend

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

func (*LesApiBackend) AccountManager

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

func (*LesApiBackend) BlockByNumber

func (b *LesApiBackend) BlockByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*modules.Unit, error)

func (*LesApiBackend) ChainDb

func (b *LesApiBackend) ChainDb() ptndb.Database

func (*LesApiBackend) ContractDeploy

func (b *LesApiBackend) ContractDeploy(templateId []byte, txid string, args [][]byte,
	timeout time.Duration) (deployId []byte, err error)

func (*LesApiBackend) ContractDeployReqTx

func (b *LesApiBackend) ContractDeployReqTx(from, to common.Address, daoAmount, daoFee uint64,
	templateId []byte, args [][]byte, extData []byte, timeout time.Duration) (reqId common.Hash,
	depId common.Address, err error)

func (*LesApiBackend) ContractDeployReqTxFee

func (b *LesApiBackend) ContractDeployReqTxFee(from, to common.Address, daoAmount, daoFee uint64, templateId []byte,
	args [][]byte, extData []byte, timeout time.Duration) (fee float64, size float64, tm uint32, err error)

func (*LesApiBackend) ContractInstall

func (b *LesApiBackend) ContractInstall(ccName string, ccPath string, ccVersion string, ccDescription, ccAbi,
	ccLanguage string) (TemplateId []byte, err error)

contract control

func (*LesApiBackend) ContractInstallReqTx

func (b *LesApiBackend) ContractInstallReqTx(from, to common.Address, daoAmount, daoFee uint64,
	tplName, path, version string, description, abi, language string, addrs []common.Address) (reqId common.Hash,
	tplId []byte, err error)

func (*LesApiBackend) ContractInstallReqTxFee

func (b *LesApiBackend) ContractInstallReqTxFee(from, to common.Address, daoAmount, daoFee uint64, tplName,
	path, version string, description, abi, language string, addrs []common.Address) (fee float64, size float64, tm uint32,
	err error)

func (*LesApiBackend) ContractInvoke

func (b *LesApiBackend) ContractInvoke(deployId []byte, txid string, args [][]byte,
	timeout time.Duration) (rspPayload []byte, err error)

ContractInvoke(txBytes []byte) (rspPayload []byte, err error)

func (*LesApiBackend) ContractInvokeReqTokenTx

func (b *LesApiBackend) ContractInvokeReqTokenTx(from, to common.Address, token *modules.Asset, amountToken, fee uint64,
	contractAddress common.Address, args [][]byte, timeout uint32) (reqId common.Hash, err error)

func (*LesApiBackend) ContractInvokeReqTx

func (b *LesApiBackend) ContractInvokeReqTx(from, to common.Address, daoAmount, daoFee uint64,
	certID *big.Int, contractAddress common.Address, args [][]byte, timeout uint32) (reqId common.Hash, err error)

func (*LesApiBackend) ContractInvokeReqTxFee

func (b *LesApiBackend) ContractInvokeReqTxFee(from, to common.Address, daoAmount, daoFee uint64, certID *big.Int,
	contractAddress common.Address, args [][]byte, timeout uint32) (fee float64, size float64, tm uint32, err error)

func (*LesApiBackend) ContractQuery

func (b *LesApiBackend) ContractQuery(id []byte, args [][]byte,
	timeout time.Duration) (rspPayload []byte, err error)

func (*LesApiBackend) ContractStop

func (b *LesApiBackend) ContractStop(deployId []byte, txid string, deleteImage bool) error

func (*LesApiBackend) ContractStopReqTx

func (b *LesApiBackend) ContractStopReqTx(from, to common.Address, daoAmount, daoFee uint64,
	contractId common.Address, deleteImage bool) (reqId common.Hash, err error)

func (*LesApiBackend) ContractStopReqTxFee

func (b *LesApiBackend) ContractStopReqTxFee(from, to common.Address, daoAmount, daoFee uint64, contractId common.Address,
	deleteImage bool) (fee float64, size float64, tm uint32, err error)

func (*LesApiBackend) CurrentBlock

func (b *LesApiBackend) CurrentBlock() *modules.Unit

func (*LesApiBackend) Dag

func (b *LesApiBackend) Dag() dag.IDag

func (*LesApiBackend) DecodeJsonTx

func (b *LesApiBackend) DecodeJsonTx(hex string) (string, error)

func (*LesApiBackend) DecodeTx

func (b *LesApiBackend) DecodeTx(hex string) (string, error)

func (*LesApiBackend) Downloader

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

func (*LesApiBackend) ElectionVrf

func (b *LesApiBackend) ElectionVrf(id uint32) ([]byte, error)

func (*LesApiBackend) EncodeTx

func (b *LesApiBackend) EncodeTx(jsonStr string) (string, error)

func (*LesApiBackend) EventMux

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

func (*LesApiBackend) GetAddrByOutPoint

func (b *LesApiBackend) GetAddrByOutPoint(outPoint *modules.OutPoint) (common.Address, error)

func (*LesApiBackend) GetAddrOutpoints

func (b *LesApiBackend) GetAddrOutpoints(addr string) ([]modules.OutPoint, error)

GetAddrOutput(addr string) ([]modules.Output, error) ------- Get addr utxo start ------//

func (*LesApiBackend) GetAddrRawUtxos

func (b *LesApiBackend) GetAddrRawUtxos(addr string) (map[modules.OutPoint]*modules.Utxo, error)

func (*LesApiBackend) GetAddrTokenFlow

func (b *LesApiBackend) GetAddrTokenFlow(addr, token string) ([]*ptnjson.TokenFlowJson, error)

func (*LesApiBackend) GetAddrTxHistory

func (b *LesApiBackend) GetAddrTxHistory(addr string) ([]*ptnjson.TxHistoryJson, error)

func (*LesApiBackend) GetAddrUtxos

func (b *LesApiBackend) GetAddrUtxos(addr string) ([]*ptnjson.UtxoJson, error)

func (*LesApiBackend) GetAddrUtxos2

func (b *LesApiBackend) GetAddrUtxos2(addr string) ([]*ptnjson.UtxoJson, error)

func (*LesApiBackend) GetAddressBalanceStatistics

func (b *LesApiBackend) GetAddressBalanceStatistics(token string, topN int) (*statistics.TokenAddressBalanceJson,
	error)

func (*LesApiBackend) GetAllContractTpl

func (b *LesApiBackend) GetAllContractTpl() ([]*ptnjson.ContractTemplateJson, error)

func (*LesApiBackend) GetAllContracts

func (b *LesApiBackend) GetAllContracts() ([]*ptnjson.ContractJson, error)

func (*LesApiBackend) GetAllData

func (b *LesApiBackend) GetAllData() ([][]byte, [][]byte)

func (*LesApiBackend) GetAllUtxos

func (b *LesApiBackend) GetAllUtxos() ([]*ptnjson.UtxoJson, error)

func (*LesApiBackend) GetAssetExistence

func (b *LesApiBackend) GetAssetExistence(asset string) ([]*ptnjson.ProofOfExistenceJson, error)

func (*LesApiBackend) GetAssetTxHistory

func (b *LesApiBackend) GetAssetTxHistory(asset *modules.Asset) ([]*ptnjson.TxHistoryJson, error)

func (*LesApiBackend) GetBlock

func (b *LesApiBackend) GetBlock(ctx context.Context, blockHash common.Hash) (*modules.Unit, error)

func (*LesApiBackend) GetChainParameters

func (b *LesApiBackend) GetChainParameters() *core.ChainParameters

func (*LesApiBackend) GetCommon

func (b *LesApiBackend) GetCommon(key []byte, stableDb bool) ([]byte, error)

dag's get common

func (*LesApiBackend) GetCommonByPrefix

func (b *LesApiBackend) GetCommonByPrefix(prefix []byte, stableDb bool) map[string][]byte

func (*LesApiBackend) GetContract

func (b *LesApiBackend) GetContract(contractAddr common.Address) (*ptnjson.ContractJson, error)

Get Contract Api

func (*LesApiBackend) GetContractInvokeHistory

func (b *LesApiBackend) GetContractInvokeHistory(addr string) ([]*ptnjson.ContractInvokeHistoryJson, error)

func (*LesApiBackend) GetContractState

func (b *LesApiBackend) GetContractState(contractid []byte, key string) ([]byte, *modules.StateVersion, error)

func (*LesApiBackend) GetContractStateJsonByPrefix

func (b *LesApiBackend) GetContractStateJsonByPrefix(contractid []byte, prefix string) ([]ptnjson.ContractStateJson, error)

func (*LesApiBackend) GetContractStatesByPrefix

func (b *LesApiBackend) GetContractStatesByPrefix(id []byte, prefix string) (map[string]*modules.ContractStateValue,
	error)

func (*LesApiBackend) GetContractTpl

func (b *LesApiBackend) GetContractTpl(tplId []byte) (*modules.ContractTemplate, error)

func (*LesApiBackend) GetContractsByTpl

func (b *LesApiBackend) GetContractsByTpl(tplId []byte) ([]*ptnjson.ContractJson, error)

func (*LesApiBackend) GetContractsWithJuryAddr

func (b *LesApiBackend) GetContractsWithJuryAddr(addr common.Hash) []*modules.Contract

func (*LesApiBackend) GetFileInfo

func (b *LesApiBackend) GetFileInfo(filehash string) ([]*modules.FileInfo, error)

func (*LesApiBackend) GetHeaderByHash

func (b *LesApiBackend) GetHeaderByHash(hash common.Hash) (*modules.Header, error)

func (*LesApiBackend) GetHeaderByNumber

func (b *LesApiBackend) GetHeaderByNumber(number *modules.ChainIndex) (*modules.Header, error)

func (*LesApiBackend) GetJuryAccount

func (b *LesApiBackend) GetJuryAccount() []common.Address

func (*LesApiBackend) GetKeyStore

func (b *LesApiBackend) GetKeyStore() *keystore.KeyStore

func (*LesApiBackend) GetPoolNonce

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

func (*LesApiBackend) GetPoolTransaction

func (b *LesApiBackend) GetPoolTransaction(txHash common.Hash) *modules.Transaction

func (*LesApiBackend) GetPoolTransactions

func (b *LesApiBackend) GetPoolTransactions() (modules.Transactions, error)

func (*LesApiBackend) GetPoolTxsByAddr

func (b *LesApiBackend) GetPoolTxsByAddr(addr string) ([]*txspool.TxPoolTransaction, error)

func (*LesApiBackend) GetPrefix

func (b *LesApiBackend) GetPrefix(prefix string) map[string][]byte

TODO wangjiyou

func (*LesApiBackend) GetProofTxInfoByHash

func (b *LesApiBackend) GetProofTxInfoByHash(txhash string) ([][]byte, error)

SPV

func (*LesApiBackend) GetStxoEntry

func (b *LesApiBackend) GetStxoEntry(outpoint *modules.OutPoint) (*ptnjson.StxoJson, error)

func (*LesApiBackend) GetTd

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

func (*LesApiBackend) GetTxByHash

func (b *LesApiBackend) GetTxByHash(hash common.Hash) (*ptnjson.TxWithUnitInfoJson, error)

func (*LesApiBackend) GetTxByReqId

func (b *LesApiBackend) GetTxByReqId(hash common.Hash) (*ptnjson.TxWithUnitInfoJson, error)

func (*LesApiBackend) GetTxByTxid_back

func (b *LesApiBackend) GetTxByTxid_back(txid string) (*ptnjson.GetTxIdResult, error)

TxPool API SendTx(ctx context.Context, signedTx *modules.Transaction) error GetPoolTransactions() (modules.Transactions, error) GetPoolTransaction(txHash common.Hash) *modules.Transaction

func (*LesApiBackend) GetTxHashByReqId

func (b *LesApiBackend) GetTxHashByReqId(reqid common.Hash) (common.Hash, error)

get tx hash by req id

func (*LesApiBackend) GetTxPoolTxByHash

func (b *LesApiBackend) GetTxPoolTxByHash(hash common.Hash) (*ptnjson.TxPoolTxJson, error)

func (*LesApiBackend) GetTxSearchEntry

func (b *LesApiBackend) GetTxSearchEntry(hash common.Hash) (*ptnjson.TxSerachEntryJson, error)

func (*LesApiBackend) GetUnitByHash

func (b *LesApiBackend) GetUnitByHash(hash common.Hash) *modules.Unit

get level db

func (*LesApiBackend) GetUnitByNumber

func (b *LesApiBackend) GetUnitByNumber(number *modules.ChainIndex) *modules.Unit

func (*LesApiBackend) GetUnitTxsHashHex

func (b *LesApiBackend) GetUnitTxsHashHex(hash common.Hash) ([]string, error)

func (*LesApiBackend) GetUnitTxsInfo

func (b *LesApiBackend) GetUnitTxsInfo(hash common.Hash) ([]*ptnjson.TxSummaryJson, error)

get transaction interface

func (*LesApiBackend) GetUnitsByIndex

func (b *LesApiBackend) GetUnitsByIndex(start, end decimal.Decimal, asset string) []*modules.Unit

func (*LesApiBackend) GetUnstableUnits

func (b *LesApiBackend) GetUnstableUnits() []*ptnjson.UnitSummaryJson

func (*LesApiBackend) GetUtxoEntry

func (b *LesApiBackend) GetUtxoEntry(outpoint *modules.OutPoint) (*ptnjson.UtxoJson, error)

func (*LesApiBackend) HeaderByNumber

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

func (*LesApiBackend) MemdagInfos

func (b *LesApiBackend) MemdagInfos() (*modules.MemdagInfos, error)

func (*LesApiBackend) ProofTransactionByHash

func (b *LesApiBackend) ProofTransactionByHash(tx string) (string, error)

func (*LesApiBackend) ProofTransactionByRlptx

func (b *LesApiBackend) ProofTransactionByRlptx(rlptx [][]byte) (string, error)

func (*LesApiBackend) ProtocolVersion

func (b *LesApiBackend) ProtocolVersion() int

func (*LesApiBackend) QueryDbByKey

func (b *LesApiBackend) QueryDbByKey(key []byte) *ptnjson.DbRowJson

func (*LesApiBackend) QueryDbByPrefix

func (b *LesApiBackend) QueryDbByPrefix(prefix []byte) []*ptnjson.DbRowJson

func (*LesApiBackend) QueryProofOfExistenceByReference

func (b *LesApiBackend) QueryProofOfExistenceByReference(ref string) ([]*ptnjson.ProofOfExistenceJson, error)

func (*LesApiBackend) Queued

func (b *LesApiBackend) Queued() ([]*txspool.TxPoolTransaction, error)

func (*LesApiBackend) RemoveTx

func (b *LesApiBackend) RemoveTx(txHash common.Hash)

func (*LesApiBackend) SaveCommon

func (b *LesApiBackend) SaveCommon(key, val []byte) error

func (*LesApiBackend) SendConsensus

func (b *LesApiBackend) SendConsensus(ctx context.Context) error

test

func (*LesApiBackend) SendContractInvokeReqTx

func (b *LesApiBackend) SendContractInvokeReqTx(requestTx *modules.Transaction) (common.Hash, error)

func (*LesApiBackend) SendTx

func (b *LesApiBackend) SendTx(ctx context.Context, signedTx *modules.Transaction) error

func (*LesApiBackend) SendTxs

func (b *LesApiBackend) SendTxs(ctx context.Context, signedTxs []*modules.Transaction) []error

func (*LesApiBackend) SetHead

func (b *LesApiBackend) SetHead(number uint64)

func (*LesApiBackend) SignAndSendRequest

func (b *LesApiBackend) SignAndSendRequest(addr common.Address, tx *modules.Transaction) error

func (*LesApiBackend) SignAndSendTransaction

func (b *LesApiBackend) SignAndSendTransaction(addr common.Address, tx *modules.Transaction) error

func (*LesApiBackend) StartCorsSync

func (b *LesApiBackend) StartCorsSync() (string, error)

func (*LesApiBackend) StateAndHeaderByNumber

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

func (*LesApiBackend) Stats

func (b *LesApiBackend) Stats() (pending int, queued int, reserve int)

func (*LesApiBackend) SubscribeChainEvent

func (b *LesApiBackend) SubscribeChainEvent(ch chan<- modules.ChainEvent) event.Subscription

func (*LesApiBackend) SubscribeChainHeadEvent

func (b *LesApiBackend) SubscribeChainHeadEvent(ch chan<- modules.ChainHeadEvent) event.Subscription

func (*LesApiBackend) SubscribeChainSideEvent

func (b *LesApiBackend) SubscribeChainSideEvent(ch chan<- modules.ChainSideEvent) event.Subscription

func (*LesApiBackend) SubscribeLogsEvent

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

func (*LesApiBackend) SubscribeRemovedLogsEvent

func (b *LesApiBackend) SubscribeRemovedLogsEvent(ch chan<- modules.RemovedLogsEvent) event.Subscription

func (*LesApiBackend) SubscribeTxPreEvent

func (b *LesApiBackend) SubscribeTxPreEvent(ch chan<- modules.TxPreEvent) event.Subscription

func (*LesApiBackend) SuggestPrice

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

func (*LesApiBackend) SyncUTXOByAddr

func (b *LesApiBackend) SyncUTXOByAddr(addr string) string

func (*LesApiBackend) TransferPtn

func (b *LesApiBackend) TransferPtn(from, to string, amount decimal.Decimal,
	text *string) (*ptnapi.TxExecuteResult, error)

SignAndSendTransaction(addr common.Address, tx *modules.Transaction) error

func (*LesApiBackend) TxPool

func (b *LesApiBackend) TxPool() txspool.ITxPool

func (*LesApiBackend) TxPoolContent

func (*LesApiBackend) UpdateJuryAccount

func (b *LesApiBackend) UpdateJuryAccount(addr common.Address, pwd string) bool

type LesServer

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

func NewLesServer

func NewLesServer(ptn *ptn.PalletOne, config *ptn.Config, protocolname string) (*LesServer, error)

func (*LesServer) CorsProtocols

func (s *LesServer) CorsProtocols() []p2p.Protocol

func (*LesServer) Protocols

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

func (*LesServer) Start

func (s *LesServer) Start(srvr *p2p.Server, corss *p2p.Server, syncCh chan bool)

Start starts the LES server

func (*LesServer) StartCorsSync

func (s *LesServer) StartCorsSync() (string, error)

func (*LesServer) Stop

func (s *LesServer) Stop()

Stop stops the LES service

func (*LesServer) SubscribeCeEvent

func (s *LesServer) SubscribeCeEvent(ch chan<- *modules.Header) event.Subscription

type LightDummyAPI

type LightDummyAPI struct{}

func (*LightDummyAPI) Coinbase

func (s *LightDummyAPI) Coinbase() (common.Address, error)

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

func (*LightDummyAPI) Etherbase

func (s *LightDummyAPI) Etherbase() (common.Address, error)

Etherbase is the address that mining rewards will be send to

func (*LightDummyAPI) Hashrate

func (s *LightDummyAPI) Hashrate() hexutil.Uint

Hashrate returns the POW hashrate

func (*LightDummyAPI) Mining

func (s *LightDummyAPI) Mining() bool

Mining returns an indication if this node is currently mining.

type LightFetcher

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

Fetcher is responsible for accumulating block announcements from various peers and scheduling them for retrieval.

func NewLightFetcher

func NewLightFetcher(getHeaderByHash headerRetrievalFn, lightChainHeight lightChainHeightFn,
	verifyHeader headerVerifierFn,
	broadcastHeader headerBroadcasterFn, insertHeader headerInsertFn, dropPeer peerDropFn) *LightFetcher

New creates a block fetcher to retrieve blocks based on hash announcements.

func (*LightFetcher) Enqueue

func (f *LightFetcher) Enqueue(p *peer, header *modules.Header) error

Enqueue tries to fill gaps the the fetcher's future import queue.

func (*LightFetcher) Start

func (f *LightFetcher) Start()

Start boots up the announcement based synchroniser, accepting and processing hash notifications and block fetches until termination requested.

func (*LightFetcher) Stop

func (f *LightFetcher) Stop()

Stop terminates the announcement based synchroniser, canceling all pending operations.

type LightPalletone

type LightPalletone struct {
	ApiBackend *LesApiBackend
	// contains filtered or unexported fields
}

func New

func New(ctx *node.ServiceContext, config *ptn.Config, protocolname string, cache palletcache.ICache,
	isTestNet bool) (*LightPalletone, error)

func (*LightPalletone) APIs

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

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 (*LightPalletone) CorsProtocols

func (s *LightPalletone) CorsProtocols() []p2p.Protocol

func (*LightPalletone) Downloader

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

func (*LightPalletone) EventMux

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

func (*LightPalletone) GenesisHash

func (s *LightPalletone) GenesisHash() common.Hash

func (*LightPalletone) GetKeyStore

func (p *LightPalletone) GetKeyStore() *keystore.KeyStore

func (*LightPalletone) LesVersion

func (s *LightPalletone) LesVersion() int

func (s *LightPalletone) Engine() consensus.Engine { return s.engine }

func (*LightPalletone) ProtocolManager

func (s *LightPalletone) ProtocolManager() *ProtocolManager

func (*LightPalletone) Protocols

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

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

func (*LightPalletone) Start

func (s *LightPalletone) Start(srvr *p2p.Server, corss *p2p.Server) error

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

func (*LightPalletone) Stop

func (s *LightPalletone) Stop() error

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

func (*LightPalletone) TxPool

func (s *LightPalletone) TxPool() *txspool.TxPool

type NodeInfo

type NodeInfo struct {
	Network uint64      `json:"network"` // Palletone network ID (1=Frontier, 2=Morden, Ropsten=3, Rinkeby=4)
	Index   uint64      `json:"Index"`   // Total difficulty of the host's blockchain
	Head    common.Hash `json:"head"`    // SHA3 hash of the host's best owned block
	Genesis common.Hash `json:"genesis"` // SHA3 hash of the host's genesis block

}

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

type ProofReq

type ProofReq struct {
	BHash       common.Hash
	AccKey, Key []byte
	FromLevel   uint
	Index       string
}

type ProtocolManager

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

func NewProtocolManager

func NewProtocolManager(lightSync bool, peers *peerSet, networkId uint64, gasToken modules.AssetId, txpool txPool,
	dag dag.IDag, mux *event.TypeMux, genesis *modules.Unit, quitSync chan struct{},
	protocolname string) (*ProtocolManager, error)

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

func (*ProtocolManager) AnnounceMsg

func (pm *ProtocolManager) AnnounceMsg(msg p2p.Msg, p *peer) error

Block header query, collect the requested headers and reply

func (*ProtocolManager) BlockHeadersMsg

func (pm *ProtocolManager) BlockHeadersMsg(msg p2p.Msg, p *peer) error

func (*ProtocolManager) BroadcastLightHeader

func (pm *ProtocolManager) BroadcastLightHeader(header *modules.Header)

func (*ProtocolManager) BroadcastTx

func (pm *ProtocolManager) BroadcastTx(hash common.Hash, tx *modules.Transaction)

func (*ProtocolManager) GetBlockHeadersMsg

func (pm *ProtocolManager) GetBlockHeadersMsg(msg p2p.Msg, p *peer) error

func (*ProtocolManager) GetLeafNodesMsg

func (pm *ProtocolManager) GetLeafNodesMsg(msg p2p.Msg, p *peer) error

func (*ProtocolManager) GetProofsMsg

func (pm *ProtocolManager) GetProofsMsg(msg p2p.Msg, p *peer) error

func (*ProtocolManager) GetUTXOsMsg

func (pm *ProtocolManager) GetUTXOsMsg(msg p2p.Msg, p *peer) error

func (*ProtocolManager) IsExistInCache

func (pm *ProtocolManager) IsExistInCache(id []byte) bool

func (*ProtocolManager) LeafNodesMsg

func (pm *ProtocolManager) LeafNodesMsg(msg p2p.Msg, p *peer) error

func (*ProtocolManager) NodeInfo

func (pm *ProtocolManager) NodeInfo(genesisHash common.Hash) *NodeInfo

NodeInfo retrieves some protocol metadata about the running host node.

func (*ProtocolManager) ProofsMsg

func (pm *ProtocolManager) ProofsMsg(msg p2p.Msg, p *peer) error

func (*ProtocolManager) ReqProofByRlptx

func (pm *ProtocolManager) ReqProofByRlptx(rlptx [][]byte) string

func (*ProtocolManager) ReqProofByTxHash

func (pm *ProtocolManager) ReqProofByTxHash(strhash string) string

func (*ProtocolManager) SendTxMsg

func (pm *ProtocolManager) SendTxMsg(msg p2p.Msg, p *peer) error

func (*ProtocolManager) Start

func (pm *ProtocolManager) Start(maxPeers int, corss *p2p.Server, syncCh chan bool)

func (*ProtocolManager) StatusMsg

func (pm *ProtocolManager) StatusMsg(msg p2p.Msg, p *peer) error

func (*ProtocolManager) Stop

func (pm *ProtocolManager) Stop()

func (*ProtocolManager) SyncUTXOByAddr

func (pm *ProtocolManager) SyncUTXOByAddr(addr string) string

func (*ProtocolManager) UTXOsMsg

func (pm *ProtocolManager) UTXOsMsg(msg p2p.Msg, p *peer) error

type ServerParams

type ServerParams struct {
	BufLimit, MinRecharge uint64
}

type UtxosSync

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

func NewUtxosSync

func NewUtxosSync(dag dag.IDag) *UtxosSync

func (*UtxosSync) AddUtxoSyncReq

func (u *UtxosSync) AddUtxoSyncReq(addr string) (*utxosReq, error)

func (*UtxosSync) SaveUtxoView

func (u *UtxosSync) SaveUtxoView(respdata *utxosRespData) error

type Validation

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

func NewValidation

func NewValidation(dag dag.IDag) *Validation

func (*Validation) AddSpvReq

func (v *Validation) AddSpvReq(strhash string) (*proofReq, error)

func (*Validation) AddSpvResp

func (v *Validation) AddSpvResp(resp *proofsRespData) error

func (*Validation) Check

func (v *Validation) Check(resp *proofsRespData) (int, error)

func (*Validation) Start

func (v *Validation) Start()

func (*Validation) Stop

func (v *Validation) Stop()

Stop terminates the announcement based synchroniser, canceling all pending operations.

Directories

Path Synopsis
This file is part of go-palletone.
This file is part of go-palletone.

Jump to

Keyboard shortcuts

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