<commit_before><?php

namespace BitWasp\Bitcoin\Chain;

use BitWasp\Bitcoin\Networking\Serializer\Structure\BlockLocatorSerializer;
use BitWasp\Bitcoin\Serializable;
use BitWasp\Buffertools\Buffer;

class BlockLocator extends Serializable
{
    /**
     * @var Buffer[]
     */
    private $hashes;

    /**
     * @var Buffer
     */
    private $hashStop;

    /**
     * @param Buffer[] $hashes
     * @param Buffer $hashStop
     */
    public function __construct(array $hashes, Buffer $hashStop)
    {
        foreach ($hashes as $hash) {
            $this->addHash($hash);
        }

        $this->hashStop = $hashStop;
    }

    /**
     * @param Buffer $hash
     */
    private function addHash(Buffer $hash)
    {
        $this->hashes[] = $hash;
    }

    /**
     * @return \BitWasp\Buffertools\Buffer[]
     */
    public function getHashes()
    {
        return $this->hashes;
    }

    /**
     * @return Buffer
     */
    public function getHashStop()
    {
        return $this->hashStop;
    }

    /**
     * @return Buffer
     */
    public function getBuffer()
    {
        return (new BlockLocatorSerializer())->serialize($this);
    }

    /**
     * @param int $height
     * @param BlockIndex $index
     * @param bool $all
     * @return BlockLocator
     */
    public static function create($height, BlockIndex $index, $all = false)
    {
        $step = 1;
        $hashes = [];
        $pIndex = $index->hash()->fetch($height);

        while (true) {
            array_push($hashes, Buffer::hex($pIndex, 32));
            if ($height == 0) {
                break;
            }

            $height = max($height - $step, 0);
            $pIndex = $index->hash()->fetch($height);
            if (count($hashes) >= 10) {
                $step *= 2;
            }
        }

        $hashStop = ($all || count($hashes) == 1)
            ? Buffer::hex('00', 32)
            : array_pop($hashes);

        return new self(
            $hashes,
            $hashStop
        );
    }
}<commit_msg>Code style for BlockLocator<commit_after><?php

namespace BitWasp\Bitcoin\Chain;

use BitWasp\Bitcoin\Networking\Serializer\Structure\BlockLocatorSerializer;
use BitWasp\Bitcoin\Serializable;
use BitWasp\Buffertools\Buffer;

class BlockLocator extends Serializable
{
    /**
     * @var Buffer[]
     */
    private $hashes;

    /**
     * @var Buffer
     */
    private $hashStop;

    /**
     * @param Buffer[] $hashes
     * @param Buffer $hashStop
     */
    public function __construct(array $hashes, Buffer $hashStop)
    {
        foreach ($hashes as $hash) {
            $this->addHash($hash);
        }

        $this->hashStop = $hashStop;
    }

    /**
     * @param Buffer $hash
     */
    private function addHash(Buffer $hash)
    {
        $this->hashes[] = $hash;
    }

    /**
     * @return \BitWasp\Buffertools\Buffer[]
     */
    public function getHashes()
    {
        return $this->hashes;
    }

    /**
     * @return Buffer
     */
    public function getHashStop()
    {
        return $this->hashStop;
    }

    /**
     * @return Buffer
     */
    public function getBuffer()
    {
        return (new BlockLocatorSerializer())->serialize($this);
    }

    /**
     * @param int $height
     * @param BlockIndex $index
     * @param bool $all
     * @return BlockLocator
     */
    public static function create($height, BlockIndex $index, $all = false)
    {
        $step = 1;
        $hashes = [];
        $pIndex = $index->hash()->fetch($height);

        while (true) {
            array_push($hashes, Buffer::hex($pIndex, 32));
            if ($height == 0) {
                break;
            }

            $height = max($height - $step, 0);
            $pIndex = $index->hash()->fetch($height);
            if (count($hashes) >= 10) {
                $step *= 2;
            }
        }

        if ($all || count($hashes) == 1) {
            $hashStop = Buffer::hex('00', 32);
        } else {
            $hashStop = array_pop($hashes);
        }

        return new self(
            $hashes,
            $hashStop
        );
    }
}
{'fraction_non_alphanumeric': 0.14389711235137104, 'fraction_numerical': 0.006309148264984227, 'mean_word_length': 1.6696891191709844, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7527409', 'n_tokens_mistral': 1292, 'n_tokens_neox': 1244, 'n_words': 260}