/** * Produce a block locator for a given block height. * @param int $height * @param Buffer|null $final * @return BlockLocator */ public function getLocator($height, Buffer $final = null) { $step = 1; $hashes = []; $headerHash = $this->chain->getHashFromHeight($height); while (true) { $hashes[] = $headerHash; if ($height === 0) { break; } $height = max($height - $step, 0); $headerHash = $this->chain->getHashFromHeight($height); if (count($hashes) >= 10) { $step *= 2; } } if (null === $final) { $hashStop = new Buffer('', 32); } else { $hashStop = $final; } return new BlockLocator($hashes, $hashStop); }