GetBlockHashesFromHash retrieves a number of block hashes starting at a given hash, fetching towards the genesis block.
(hash common.Hash, max uint64)
| 282 | // GetBlockHashesFromHash retrieves a number of block hashes starting at a given |
| 283 | // hash, fetching towards the genesis block. |
| 284 | func (hc *HeaderChain) GetBlockHashesFromHash(hash common.Hash, max uint64) []common.Hash { |
| 285 | // Get the origin header from which to fetch |
| 286 | header := hc.GetHeaderByHash(hash) |
| 287 | if header == nil { |
| 288 | return nil |
| 289 | } |
| 290 | // Iterate the headers until enough is collected or the genesis reached |
| 291 | chain := make([]common.Hash, 0, max) |
| 292 | for i := uint64(0); i < max; i++ { |
| 293 | next := header.ParentHash |
| 294 | if header = hc.GetHeader(next, header.Number.Uint64()-1); header == nil { |
| 295 | break |
| 296 | } |
| 297 | chain = append(chain, next) |
| 298 | if header.Number.Sign() == 0 { |
| 299 | break |
| 300 | } |
| 301 | } |
| 302 | return chain |
| 303 | } |
| 304 | |
| 305 | // GetAncestor retrieves the Nth ancestor of a given block. It assumes that either the given block or |
| 306 | // a close ancestor of it is canonical. maxNonCanonical points to a downwards counter limiting the |
nothing calls this directly
no test coverage detected