Notify announces the fetcher of the potential availability of a new block in the network.
(peer string, hash common.Hash, number uint64, time time.Time, headerFetcher headerRequesterFn, bodyFetcher bodyRequesterFn)
| 186 | // Notify announces the fetcher of the potential availability of a new block in |
| 187 | // the network. |
| 188 | func (f *Fetcher) Notify(peer string, hash common.Hash, number uint64, time time.Time, |
| 189 | headerFetcher headerRequesterFn, bodyFetcher bodyRequesterFn) error { |
| 190 | block := &announce{ |
| 191 | hash: hash, |
| 192 | number: number, |
| 193 | time: time, |
| 194 | origin: peer, |
| 195 | fetchHeader: headerFetcher, |
| 196 | fetchBodies: bodyFetcher, |
| 197 | } |
| 198 | select { |
| 199 | case f.notify <- block: |
| 200 | return nil |
| 201 | case <-f.quit: |
| 202 | return errTerminated |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | // Enqueue tries to fill gaps the the fetcher's future import queue. |
| 207 | func (f *Fetcher) Enqueue(peer string, block *types.Block) error { |
no outgoing calls