Documentation ¶
Overview ¶
Package downloader contains the manual full chain synchronisation.
Index ¶
- Constants
- Variables
- func CheckDirAndCreate(dir string) error
- func CheckIpfsStatus(err error)
- func CompressFile(Dst string, Src string) error
- func DeCompressFile(Dst string, Src string) error
- func GetFileSize(filename string) int64
- func GetIpfsMode() bool
- func IpfsGetBlockByHash(strHash string, compress bool) (*os.File, error)
- func IpfsGetFileCache2ByHash(strhash, objfileName string) (*os.File, bool, error)
- func IpfsStartTimer(hash string)
- func IpfsStopTimer()
- func RandomSlice(arr []*peerConnection)
- func ReadJsFile(filename string, v interface{}) error
- func RestartIpfsDaemon()
- func StopIpfsProcess()
- func TimeoutExec(str string)
- func WriteJsFile(filename string, v interface{}) error
- type BatchBlockSt
- type BlockChain
- type BlockIpfs
- type BlockIpfsReq
- type BlockStore
- type Cache1StoreCfg
- type Caches2CfgMap
- type DoneEvent
- type DownloadFileInfo
- type DownloadRetry
- type Downloader
- func (d *Downloader) AddNewBatchBlockToIpfs()
- func (d *Downloader) AddStateRootInfoToIpfs(blockNum uint64, strheadHash string, filePath string)
- func (d *Downloader) BatchBlockStoreInit(bNeedClear bool)
- func (d *Downloader) BatchStoreAllBlock(stBlock *types.BlockAllSt) bool
- func (d *Downloader) Cancel()
- func (d *Downloader) ClearDirectoryContent()
- func (d *Downloader) ClearIpfsQueue()
- func (d *Downloader) DGetIPFSBlock(strHash string)
- func (d *Downloader) DGetIPFSSecondcache(strHash string)
- func (d *Downloader) DGetIPFSfirstcache()
- func (d *Downloader) DGetIPFSsnap(strHash string)
- func (d *Downloader) DeliverBodies(id string, transactions [][]types.CurrencyBlock, uncles [][]*types.Header) (err error)
- func (d *Downloader) DeliverHeaders(id string, headers []*types.Header) (err error)
- func (d *Downloader) DeliverNodeData(id string, data [][]byte) (err error)
- func (d *Downloader) DeliverReceipts(id string, receipts [][]types.CoinReceipts) (err error)
- func (d *Downloader) DownloadBatchBlock(headhash string, headNumber uint64, realBeginNum uint64, pendflag int, ...) int
- func (d *Downloader) GetBlockAndAnalysisSend(blockhash string, stype string) bool
- func (d *Downloader) GetBlockByIPFS(strHash string)
- func (d *Downloader) GetBlockHashFromCache(headhash string, coinstr string, headNumber uint64) bool
- func (d *Downloader) GetfirstcacheByIPFS()
- func (d *Downloader) GetsanpByIPFS(strHash string)
- func (d *Downloader) GetsecondcacheByIPFS(strHash string)
- func (d *Downloader) IPfsDirectoryUpdate() error
- func (d *Downloader) IpfsDownloadInit() error
- func (d *Downloader) IpfsDownloadTestInit() error
- func (d *Downloader) IpfsProcessRcvHead()
- func (d *Downloader) IpfsSynInsertNewBlockHashToLastest(curLastestInfo *LastestBlcokCfg, blockNum uint64, strheadHash string, ...) error
- func (d *Downloader) IpfsSyncGetFirstCache(index int) (*Cache1StoreCfg, error)
- func (d *Downloader) IpfsSyncGetLatestBlock(index int) (*LastestBlcokCfg, uint64, error)
- func (d *Downloader) IpfsSyncGetSecondCache()
- func (d *Downloader) IpfsSyncSaveBatchSecondCache(newFlg bool, blockNum uint64, headHash string, snapshootNum uint64, ...) error
- func (d *Downloader) IpfsSyncSaveLatestBlock()
- func (d *Downloader) IpfsSyncSaveSecondCache(newFlg bool, blockNum uint64, strheadHash string, fhash string, file *os.File) error
- func (d *Downloader) IpfsTimeoutTask()
- func (d *Downloader) IpsfAddNewBatchBlockToCache(stCfg *Cache1StoreCfg, blockNum uint64, snapshootNum uint64, ...) error
- func (d *Downloader) IpsfAddNewBlockBatchToCache(stCfg *Cache1StoreCfg, blockList []listBlockInfo) error
- func (d *Downloader) IpsfAddNewBlockToCache(stCfg *Cache1StoreCfg, blockNum uint64, headHash string, fhash string) error
- func (d *Downloader) ParseBatchBody(batchblockhash string, beginReqNumber uint64, realBeginNum uint64, flg int) bool
- func (d *Downloader) ParseBatchHeader(batchblockhash string, beginReqNumber uint64) bool
- func (d *Downloader) ParseBatchReceipt(batchblockhash string, beginReqNumber uint64, realBeginNum uint64) bool
- func (d *Downloader) ParseMPTstatus(batchblockhash string, beginReqNumber uint64, realstatusNumber uint64) bool
- func (d *Downloader) PrintSnapshotAccountMsg(blockNum uint64, hash string, filePath string)
- func (d *Downloader) ProcessSnapshoot(number uint64, hash string) error
- func (d *Downloader) Progress() matrix.SyncProgress
- func (d *Downloader) RecvBlockSaveToipfs(blockqueue *prque.Prque) error
- func (d *Downloader) RecvBlockToDeal(newBlock *types.Block) error
- func (d *Downloader) RegisterLightPeer(id string, version int, peer LightPeer) error
- func (d *Downloader) RegisterPeer(id string, version int, peer Peer) error
- func (d *Downloader) SaveSnapshootStatus(blockNum uint64, strheadHash string, filePath string) bool
- func (d *Downloader) SetSnapshootNum(number uint64)
- func (d *Downloader) SetbStoreSendIpfsFlg(flg bool)
- func (d *Downloader) StatusSnapshootDeal()
- func (d *Downloader) SynBlockFormBlockchain()
- func (d *Downloader) SynDealblock()
- func (d *Downloader) SynIPFSCheck()
- func (d *Downloader) SynOrignDownload(out interface{}, flag int, blockNum uint64)
- func (d *Downloader) SyncBlockFromIpfs(strHeadHash string, headNumber uint64, coin string, index int) int
- func (d *Downloader) Synchronise(id string, head common.Hash, td *big.Int, sbs uint64, sbh uint64, ...) error
- func (d *Downloader) Synchronising() bool
- func (d *Downloader) Terminate()
- func (d *Downloader) TestSnapshoot()
- func (d *Downloader) UnregisterPeer(id string, flg int) error
- func (d *Downloader) WaitBlockInfoFromIpfs()
- type FailedEvent
- type FakePeer
- func (p *FakePeer) Head() (common.Hash, *big.Int, uint64, uint64, uint64, uint64)
- func (p *FakePeer) RequestBodies(hashes []common.Hash) error
- func (p *FakePeer) RequestHeadersByHash(hash common.Hash, amount int, skip int, reverse bool) error
- func (p *FakePeer) RequestHeadersByNumber(number uint64, amount int, skip int, reverse bool) error
- func (p *FakePeer) RequestNodeData(hashes []common.Hash) error
- func (p *FakePeer) RequestReceipts(hashes []common.Hash) error
- type GetIpfsCache
- type Hash
- type IPFSBlockStat
- type IPfsDownloader
- type LastestBlcokCfg
- type LightChain
- type LightPeer
- type NumberMapingCoupledHash
- type Peer
- type PublicDownloaderAPI
- type SnapshootReq
- type StartEvent
- type StopIpfs
- type StoreIpfsCache
- type SyncMode
- type SyncStatusSubscription
- type SyncingResult
Constants ¶
const ( IpfsHashLen = 46 LastestBlockStroeNum = 100 //100 Cache2StoreHashMaxNum = 216000 //每月产生的区块//测试 2000 //要改成月216000 //2628000 //24 hour* (3600 second /12 second)*365 Cache1StoreCache2Num = 6000 //500年的 //测试10000 //改成12000 1000年 Cache2StoreBatchBlockMaxNum = 8800 //每年产生的//测试20 //要改为8800(24*365 )//约年 产生 的 300单位的区块 Cache1StoreBatchCache2Num = 500 //500年的//测试100 // 要改为1000 年 BATCH_NUM = 300 SingleBlockStore = false )
Variables ¶
var ( MaxHashFetch = 512 // Amount of hashes to be fetched per retrieval request MaxBlockFetch = 20 //128 // Amount of blocks to be fetched per retrieval request MaxHeaderFetch = 32 //100 //192 // Amount of block headers to be fetched per retrieval request MaxSkeletonSize = 32 //100 //128 // Number of header fetches to need for a skeleton assembly MaxBodyFetch = 128 // Amount of block bodies to be fetched per retrieval request MaxReceiptFetch = 64 //256 // Amount of transaction receipts to allow fetching per request MaxStateFetch = 384 // Amount of node state values to allow fetching per request MaxForkAncestry = 3 * params.EpochDuration // Maximum chain reorganisation )
var ( QSingleBlockStore = false NumBlockInfoFromIpfs = 0 )
var BodyBatchFlag uint64 = 0x23456781
var HeadBatchFlag uint64 = 0x12345678
var ReceiptBatchFlag uint64 = 0x34567812
var SnapshootNumber uint64
var StopIpfsHandler = StopIpfs{}
Functions ¶
func CheckDirAndCreate ¶
func CheckIpfsStatus ¶
func CheckIpfsStatus(err error)
func CompressFile ¶
func GetFileSize ¶
func GetIpfsMode ¶
func GetIpfsMode() bool
func IpfsGetBlockByHash ¶
IpfsGetBlockByHash get block
func IpfsGetFileCache2ByHash ¶
func IpfsStartTimer ¶
func IpfsStartTimer(hash string)
func IpfsStopTimer ¶
func IpfsStopTimer()
func RandomSlice ¶
func RandomSlice(arr []*peerConnection)
func RestartIpfsDaemon ¶
func RestartIpfsDaemon()
func StopIpfsProcess ¶
func StopIpfsProcess()
func TimeoutExec ¶
func TimeoutExec(str string)
Types ¶
type BatchBlockSt ¶
type BlockChain ¶
type BlockChain interface { LightChain // HasBlock verifies a block's presence in the local chain. HasBlock(common.Hash, uint64) bool // GetBlockByHash retrieves a block from the local chain. GetBlockByHash(common.Hash) *types.Block // CurrentBlock retrieves the head block from the local chain. CurrentBlock() *types.Block // CurrentFastBlock retrieves the head fast block from the local chain. CurrentFastBlock() *types.Block // FastSyncCommitHead directly commits the head block to a certain entity. FastSyncCommitHead(common.Hash) error // InsertChain inserts a batch of blocks into the local chain. InsertChain(types.Blocks, int) (int, error) // InsertReceiptChain inserts a batch of receipts into the local chain. InsertReceiptChain(types.Blocks) (int, error) //lb ipfs SetbSendIpfsFlg(bool) GetStoreBlockInfo() *prque.Prque //types.Blocks //(storeBlock types.Blocks) GetIpfsQMux() GetIpfsQUnMux() GetSuperBlockSeq() (uint64, error) GetSuperBlockNum() (uint64, error) GetSuperBlockInfo() (*mc.SuperBlkCfg, error) DPOSEngine(version []byte) consensus.DPOSEngine GetCurrentHash() common.Hash Genesis() *types.Block GetGraphByHash(hash common.Hash) (*mc.TopologyGraph, *mc.ElectGraph, error) GetBroadcastAccounts(blockHash common.Hash) ([]common.Address, error) GetVersionSuperAccounts(blockHash common.Hash) ([]common.Address, error) GetBlockSuperAccounts(blockHash common.Hash) ([]common.Address, error) GetBroadcastIntervalByHash(blockHash common.Hash) (*mc.BCIntervalInfo, error) GetA0AccountFromAnyAccount(account common.Address, blockHash common.Hash) (common.Address, common.Address, error) SynSnapshot(blockNum uint64, hash string, filePath string) bool SetSnapshotParam(period uint64, start uint64) PrintSnapshotAccountMsg(blockNum uint64, hash string, filePath string) }
BlockChain encapsulates functions required to sync a (full or fast) blockchain.
type BlockIpfs ¶
type BlockIpfs struct { Flag int BlockNum uint64 Headeripfs *types.Header Unclesipfs []*types.Header Transactionsipfs []types.CurrencyBlock //CoinSelfTransaction //Transactions//SelfTransaction????? Receipt []types.CoinReceipts }
type BlockIpfsReq ¶
type BlockStore ¶
type BlockStore struct {
Numberstore map[uint64]NumberMapingCoupledHash
}
type Cache1StoreCfg ¶
type Cache1StoreCfg struct { OriginBlockNum uint64 CurrentBlockNum uint64 Cache2FileNum uint32 StCahce2Hash [Cache1StoreCache2Num]string StBatchCahce2Hash [Cache1StoreBatchCache2Num]string }
cache1
type Caches2CfgMap ¶
type Caches2CfgMap struct { CurCacheBeignNum uint64 CurCacheBlockNum uint64 NumHashStore uint32 //CurOfCache1Pos uint32 MapList BlockStore }
new cache2
type DownloadFileInfo ¶
type DownloadFileInfo struct { Downloadflg bool IpfsPath string StrIPFSServerInfo string StrIPFSServer2Info string StrIPFSServer3Info string StrIPFSServer4Info string StrIPFSServer5Info string StrIPFSServer6Info string StrIPFSServer7Info string StrIPFSServer8Info string StrIPFSServer9Info string StrIPFSServer10Info string PrimaryDescription string SecondaryDescription string }
var IpfsInfo DownloadFileInfo
type DownloadRetry ¶
type DownloadRetry struct { ReqPendflg int // contains filtered or unexported fields }
type Downloader ¶
type Downloader struct { IpfsMode bool //liubo ipfs WaitSnapshoot chan int CheckNum int CheckWaitNum int // contains filtered or unexported fields }
func New ¶
func New(mode SyncMode, stateDb mandb.Database, mux *event.TypeMux, chain BlockChain, lightchain LightChain, dropPeer peerDropFn, getBlock blockQRetrievalFn) *Downloader
New creates a new downloader to fetch hashes and blocks from remote peers.
func (*Downloader) AddStateRootInfoToIpfs ¶
func (d *Downloader) AddStateRootInfoToIpfs(blockNum uint64, strheadHash string, filePath string)
func (*Downloader) BatchBlockStoreInit ¶
func (d *Downloader) BatchBlockStoreInit(bNeedClear bool)
func (*Downloader) BatchStoreAllBlock ¶
func (d *Downloader) BatchStoreAllBlock(stBlock *types.BlockAllSt) bool
func (*Downloader) Cancel ¶
func (d *Downloader) Cancel()
Cancel aborts all of the operations and waits for all download goroutines to finish before returning.
func (*Downloader) ClearDirectoryContent ¶
func (d *Downloader) ClearDirectoryContent()
func (*Downloader) ClearIpfsQueue ¶
func (d *Downloader) ClearIpfsQueue()
func (*Downloader) DGetIPFSBlock ¶
func (d *Downloader) DGetIPFSBlock(strHash string)
func (*Downloader) DGetIPFSSecondcache ¶
func (d *Downloader) DGetIPFSSecondcache(strHash string)
func (*Downloader) DGetIPFSfirstcache ¶
func (d *Downloader) DGetIPFSfirstcache()
func (*Downloader) DGetIPFSsnap ¶
func (d *Downloader) DGetIPFSsnap(strHash string)
func (*Downloader) DeliverBodies ¶
func (d *Downloader) DeliverBodies(id string, transactions [][]types.CurrencyBlock, uncles [][]*types.Header) (err error)
DeliverBodies injects a new batch of block bodies received from a remote node.
func (*Downloader) DeliverHeaders ¶
func (d *Downloader) DeliverHeaders(id string, headers []*types.Header) (err error)
DeliverHeaders injects a new batch of block headers received from a remote node into the download schedule.
func (*Downloader) DeliverNodeData ¶
func (d *Downloader) DeliverNodeData(id string, data [][]byte) (err error)
DeliverNodeData injects a new batch of node state data received from a remote node.
func (*Downloader) DeliverReceipts ¶
func (d *Downloader) DeliverReceipts(id string, receipts [][]types.CoinReceipts) (err error)
DeliverReceipts injects a new batch of receipts received from a remote node.
func (*Downloader) DownloadBatchBlock ¶
func (*Downloader) GetBlockAndAnalysisSend ¶
func (d *Downloader) GetBlockAndAnalysisSend(blockhash string, stype string) bool
func (*Downloader) GetBlockByIPFS ¶
func (d *Downloader) GetBlockByIPFS(strHash string)
func (*Downloader) GetBlockHashFromCache ¶
func (d *Downloader) GetBlockHashFromCache(headhash string, coinstr string, headNumber uint64) bool
func (*Downloader) GetfirstcacheByIPFS ¶
func (d *Downloader) GetfirstcacheByIPFS()
func (*Downloader) GetsanpByIPFS ¶
func (d *Downloader) GetsanpByIPFS(strHash string)
func (*Downloader) GetsecondcacheByIPFS ¶
func (d *Downloader) GetsecondcacheByIPFS(strHash string)
func (*Downloader) IPfsDirectoryUpdate ¶
func (d *Downloader) IPfsDirectoryUpdate() error
IPfsDirectoryUpdate
func (*Downloader) IpfsDownloadInit ¶
func (d *Downloader) IpfsDownloadInit() error
func (*Downloader) IpfsDownloadTestInit ¶
func (d *Downloader) IpfsDownloadTestInit() error
func (*Downloader) IpfsSynInsertNewBlockHashToLastest ¶
func (d *Downloader) IpfsSynInsertNewBlockHashToLastest(curLastestInfo *LastestBlcokCfg, blockNum uint64, strheadHash string, blockhash string) error
IpfsSynInsertNewBlockHashToLastest
func (*Downloader) IpfsSyncGetFirstCache ¶
func (d *Downloader) IpfsSyncGetFirstCache(index int) (*Cache1StoreCfg, error)
IpfsSyncGetFirstCache
func (*Downloader) IpfsSyncGetLatestBlock ¶
func (d *Downloader) IpfsSyncGetLatestBlock(index int) (*LastestBlcokCfg, uint64, error)
IpfsSyncGetLatestBlock
func (*Downloader) IpfsSyncGetSecondCache ¶
func (d *Downloader) IpfsSyncGetSecondCache()
IpfsSyncGetSecondCache
func (*Downloader) IpfsSyncSaveBatchSecondCache ¶
func (*Downloader) IpfsSyncSaveLatestBlock ¶
func (d *Downloader) IpfsSyncSaveLatestBlock()
IpfsSyncSaveLatestBlock
func (*Downloader) IpfsSyncSaveSecondCache ¶
func (d *Downloader) IpfsSyncSaveSecondCache(newFlg bool, blockNum uint64, strheadHash string, fhash string, file *os.File) error
IpfsSyncSaveSecondCache
func (*Downloader) IpfsTimeoutTask ¶
func (d *Downloader) IpfsTimeoutTask()
func (*Downloader) IpsfAddNewBatchBlockToCache ¶
func (d *Downloader) IpsfAddNewBatchBlockToCache(stCfg *Cache1StoreCfg, blockNum uint64, snapshootNum uint64, strheadHash string, allhash string) error
IpsfAddNewBlockToCache
func (*Downloader) IpsfAddNewBlockBatchToCache ¶
func (d *Downloader) IpsfAddNewBlockBatchToCache(stCfg *Cache1StoreCfg, blockList []listBlockInfo) error
func (*Downloader) IpsfAddNewBlockToCache ¶
func (d *Downloader) IpsfAddNewBlockToCache(stCfg *Cache1StoreCfg, blockNum uint64, headHash string, fhash string) error
IpsfAddNewBlockToCache
func (*Downloader) ParseBatchBody ¶
func (*Downloader) ParseBatchHeader ¶
func (d *Downloader) ParseBatchHeader(batchblockhash string, beginReqNumber uint64) bool
func (*Downloader) ParseBatchReceipt ¶
func (d *Downloader) ParseBatchReceipt(batchblockhash string, beginReqNumber uint64, realBeginNum uint64) bool
func (*Downloader) ParseMPTstatus ¶
func (d *Downloader) ParseMPTstatus(batchblockhash string, beginReqNumber uint64, realstatusNumber uint64) bool
func (*Downloader) PrintSnapshotAccountMsg ¶
func (d *Downloader) PrintSnapshotAccountMsg(blockNum uint64, hash string, filePath string)
func (*Downloader) ProcessSnapshoot ¶
func (d *Downloader) ProcessSnapshoot(number uint64, hash string) error
func (*Downloader) Progress ¶
func (d *Downloader) Progress() matrix.SyncProgress
Progress retrieves the synchronisation boundaries, specifically the origin block where synchronisation started at (may have failed/suspended); the block or header sync is currently at; and the latest known block which the sync targets.
In addition, during the state download phase of fast synchronisation the number of processed and the total number of known states are also returned. Otherwise these are zero.
func (*Downloader) RecvBlockSaveToipfs ¶
func (d *Downloader) RecvBlockSaveToipfs(blockqueue *prque.Prque) error
RecvBlockToDeal
func (*Downloader) RecvBlockToDeal ¶
func (d *Downloader) RecvBlockToDeal(newBlock *types.Block) error
RecvBlockToDeal
func (*Downloader) RegisterLightPeer ¶
func (d *Downloader) RegisterLightPeer(id string, version int, peer LightPeer) error
RegisterLightPeer injects a light client peer, wrapping it so it appears as a regular peer.
func (*Downloader) RegisterPeer ¶
func (d *Downloader) RegisterPeer(id string, version int, peer Peer) error
RegisterPeer injects a new download peer into the set of block source to be used for fetching hashes and blocks from.
func (*Downloader) SaveSnapshootStatus ¶
func (d *Downloader) SaveSnapshootStatus(blockNum uint64, strheadHash string, filePath string) bool
func (*Downloader) SetSnapshootNum ¶
func (d *Downloader) SetSnapshootNum(number uint64)
func (*Downloader) SetbStoreSendIpfsFlg ¶
func (d *Downloader) SetbStoreSendIpfsFlg(flg bool)
func (*Downloader) StatusSnapshootDeal ¶
func (d *Downloader) StatusSnapshootDeal()
func (*Downloader) SynBlockFormBlockchain ¶
func (d *Downloader) SynBlockFormBlockchain()
func (*Downloader) SynIPFSCheck ¶
func (d *Downloader) SynIPFSCheck()
func (*Downloader) SynOrignDownload ¶
func (d *Downloader) SynOrignDownload(out interface{}, flag int, blockNum uint64)
func (*Downloader) SyncBlockFromIpfs ¶
func (d *Downloader) SyncBlockFromIpfs(strHeadHash string, headNumber uint64, coin string, index int) int
下载区块 SyncBlockFromIpfs
func (*Downloader) Synchronise ¶
func (d *Downloader) Synchronise(id string, head common.Hash, td *big.Int, sbs uint64, sbh uint64, mode SyncMode) error
Synchronise tries to sync up our local block chain with a remote peer, both adding various sanity checks as well as wrapping it with various log entries.
func (*Downloader) Synchronising ¶
func (d *Downloader) Synchronising() bool
Synchronising returns whether the downloader is currently retrieving blocks.
func (*Downloader) Terminate ¶
func (d *Downloader) Terminate()
Terminate interrupts the downloader, canceling all pending operations. The downloader cannot be reused after calling Terminate.
func (*Downloader) TestSnapshoot ¶
func (d *Downloader) TestSnapshoot()
func (*Downloader) UnregisterPeer ¶
func (d *Downloader) UnregisterPeer(id string, flg int) error
UnregisterPeer remove a peer from the known list, preventing any action from the specified peer. An effort is also made to return any pending fetches into the queue.
type FailedEvent ¶
type FailedEvent struct{ Err error }
type FakePeer ¶
type FakePeer struct {
// contains filtered or unexported fields
}
FakePeer is a mock downloader peer that operates on a local database instance instead of being an actual live node. It's useful for testing and to implement sync commands from an existing local database.
func NewFakePeer ¶
func NewFakePeer(id string, db mandb.Database, hc *core.HeaderChain, dl *Downloader) *FakePeer
NewFakePeer creates a new mock downloader peer with the given data sources.
func (*FakePeer) Head ¶
Head implements downloader.Peer, returning the current head hash and number of the best known header.
func (*FakePeer) RequestBodies ¶
RequestBodies implements downloader.Peer, returning a batch of block bodies corresponding to the specified block hashes.
func (*FakePeer) RequestHeadersByHash ¶
RequestHeadersByHash implements downloader.Peer, returning a batch of headers defined by the origin hash and the associated query parameters.
func (*FakePeer) RequestHeadersByNumber ¶
RequestHeadersByNumber implements downloader.Peer, returning a batch of headers defined by the origin number and the associated query parameters.
func (*FakePeer) RequestNodeData ¶
RequestNodeData implements downloader.Peer, returning a batch of state trie nodes corresponding to the specified trie hashes.
type GetIpfsCache ¶
type GetIpfsCache struct {
// contains filtered or unexported fields
}
type IPFSBlockStat ¶
type IPFSBlockStat struct {
// contains filtered or unexported fields
}
type IPfsDownloader ¶
type IPfsDownloader struct { BIpfsIsRunning bool IpfsDealBlocking int32 StrIpfspeerID string StrIpfsSecondpeerID string StrIPFSLocationPath string StrIPFSServerInfo string StrIPFSExecName string HeaderIpfsCh chan []BlockIpfsReq //[]*types.Header // BlockRcvCh chan *types.Block //runQuit chan struct{} //timeOutCh chan struct{} DownMutex *sync.Mutex DownRetrans *list.List //*prque.Prque // []DownloadRetry prque.New() BatchStBlock *BatchBlockSt SnapshootInfoCh chan SnapshootReq }
type LastestBlcokCfg ¶
type LastestBlcokCfg struct { CurrentNum uint64 HashNum int MapList BlockStore }
lastest 100
type LightChain ¶
type LightChain interface { // HasHeader verifies a header's presence in the local chain. HasHeader(common.Hash, uint64) bool // GetHeaderByHash retrieves a header from the local chain. GetHeaderByHash(common.Hash) *types.Header // CurrentHeader retrieves the head header from the local chain. CurrentHeader() *types.Header // GetTd returns the total difficulty of a local block. GetTd(common.Hash, uint64) *big.Int // InsertHeaderChain inserts a batch of headers into the local chain. InsertHeaderChain([]*types.Header, int) (int, error) // Rollback removes a few recently added elements from the local chain. Rollback([]common.Hash) }
LightChain encapsulates functions required to synchronise a light chain.
type LightPeer ¶
type LightPeer interface { Head() (hash common.Hash, td *big.Int, sbs uint64, sbHash uint64, bt uint64, bn uint64) RequestHeadersByHash(common.Hash, int, int, bool) error RequestHeadersByNumber(uint64, int, int, bool) error }
LightPeer encapsulates the methods required to synchronise with a remote light peer.
type NumberMapingCoupledHash ¶
type Peer ¶
type Peer interface { LightPeer RequestBodies([]common.Hash) error RequestReceipts([]common.Hash) error RequestNodeData([]common.Hash) error }
Peer encapsulates the methods required to synchronise with a remote full peer.
type PublicDownloaderAPI ¶
type PublicDownloaderAPI struct {
// contains filtered or unexported fields
}
PublicDownloaderAPI provides an API which gives information about the current synchronisation status. It offers only methods that operates on data that can be available to anyone without security risks.
func NewPublicDownloaderAPI ¶
func NewPublicDownloaderAPI(d *Downloader, m *event.TypeMux) *PublicDownloaderAPI
NewPublicDownloaderAPI create a new PublicDownloaderAPI. The API has an internal event loop that listens for events from the downloader through the global event mux. In case it receives one of these events it broadcasts it to all syncing subscriptions that are installed through the installSyncSubscription channel.
func (*PublicDownloaderAPI) SubscribeSyncStatus ¶
func (api *PublicDownloaderAPI) SubscribeSyncStatus(status chan interface{}) *SyncStatusSubscription
SubscribeSyncStatus creates a subscription that will broadcast new synchronisation updates. The given channel must receive interface values, the result can either
func (*PublicDownloaderAPI) Syncing ¶
func (api *PublicDownloaderAPI) Syncing(ctx context.Context) (*rpc.Subscription, error)
Syncing provides information when this nodes starts synchronising with the Matrix network and when it's finished.
type SnapshootReq ¶
type StartEvent ¶
type StartEvent struct{}
type StoreIpfsCache ¶
type StoreIpfsCache struct {
// contains filtered or unexported fields
}
type SyncMode ¶
type SyncMode int
SyncMode represents the synchronisation mode of the downloader.
func (SyncMode) MarshalText ¶
func (*SyncMode) UnmarshalText ¶
type SyncStatusSubscription ¶
type SyncStatusSubscription struct {
// contains filtered or unexported fields
}
SyncStatusSubscription represents a syncing subscription.
func (*SyncStatusSubscription) Unsubscribe ¶
func (s *SyncStatusSubscription) Unsubscribe()
Unsubscribe uninstalls the subscription from the DownloadAPI event loop. The status channel that was passed to subscribeSyncStatus isn't used anymore after this method returns.
type SyncingResult ¶
type SyncingResult struct { Syncing bool `json:"syncing"` Status matrix.SyncProgress `json:"status"` }
SyncingResult provides information about the current synchronisation status for this node.