diff options
author | obscuren <geffobscura@gmail.com> | 2015-04-20 03:45:58 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-04-20 03:46:19 +0800 |
commit | 5dd56bb474e9001db6decb75b7abfca99050d844 (patch) | |
tree | 3a4e323d0941f4c2d4f7ae17f3d8385867a837ff /eth | |
parent | 2c1a6a349b4f8bb23e37a75d8d8ceaa0fbfced8d (diff) | |
download | dexon-5dd56bb474e9001db6decb75b7abfca99050d844.tar.gz dexon-5dd56bb474e9001db6decb75b7abfca99050d844.tar.zst dexon-5dd56bb474e9001db6decb75b7abfca99050d844.zip |
geth: admin download status
Diffstat (limited to 'eth')
-rw-r--r-- | eth/downloader/downloader.go | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go index c4af5e17b..addcbcc44 100644 --- a/eth/downloader/downloader.go +++ b/eth/downloader/downloader.go @@ -41,6 +41,17 @@ type chainInsertFn func(types.Blocks) error type hashIterFn func() (common.Hash, error) type currentTdFn func() *big.Int +type blockPack struct { + peerId string + blocks []*types.Block +} + +type syncPack struct { + peer *peer + hash common.Hash + ignoreInitial bool +} + type Downloader struct { mu sync.RWMutex queue *queue @@ -65,17 +76,6 @@ type Downloader struct { quit chan struct{} } -type blockPack struct { - peerId string - blocks []*types.Block -} - -type syncPack struct { - peer *peer - hash common.Hash - ignoreInitial bool -} - func New(hasBlock hashCheckFn, insertChain chainInsertFn, currentTd currentTdFn) *Downloader { downloader := &Downloader{ queue: newqueue(), @@ -95,6 +95,10 @@ func New(hasBlock hashCheckFn, insertChain chainInsertFn, currentTd currentTdFn) return downloader } +func (d *Downloader) Stats() (current int, max int) { + return d.queue.blockHashes.Size(), d.queue.fetchPool.Size() + d.queue.hashPool.Size() +} + func (d *Downloader) RegisterPeer(id string, td *big.Int, hash common.Hash, getHashes hashFetcherFn, getBlocks blockFetcherFn) error { d.mu.Lock() defer d.mu.Unlock() |