src/danog/MadelineProto/Stream/Common/HashedBufferedStream.php
public function bufferReadAsync(int $length): \Generator
    {
        if ($this->read_check_after && $length + $this->read_check_pos >= $this->read_check_after) {
            if ($length + $this->read_check_pos > $this->read_check_after) {
                throw new \danog\MadelineProto\Exception('Tried to read too much out of frame data');
            }
            $data = yield $this->read_buffer->bufferRead($length);
            hash_update($this->read_hash, $data);
            $hash = $this->getReadHash();
            if ($hash !== yield $this->read_buffer->bufferRead(strlen($hash))) {
                throw new \danog\MadelineProto\Exception('Hash mismatch');
            }

            return $data;
        }
        $data = yield $this->read_buffer->bufferRead($length);
        hash_update($this->read_hash, $data);
        if ($this->read_check_after) {
            $this->read_check_pos += $length;
        }

        return $data;
    }
public function bufferReadAsync(int $length): \Generator
    {
        if ($this->read_check_after && $length + $this->read_check_pos >= $this->read_check_after) {
            if ($length + $this->read_check_pos > $this->read_check_after) {
                throw new \danog\MadelineProto\Exception('Tried to read too much out of frame data');
            }
            $data = yield $this->read_buffer->bufferRead($length);
            hash_update($this->read_hash, $data);
            $hash = $this->getReadHash();
            if ($hash !== yield $this->read_buffer->bufferRead(strlen($hash))) {
                throw new \danog\MadelineProto\Exception('Hash mismatch');
            }

            return $data;
        }
        $data = yield $this->read_buffer->bufferRead($length);
        hash_update($this->read_hash, $data);
        if ($this->read_check_after) {
            $this->read_check_pos += $length;
        }

        return $data;
    }
public function bufferReadAsync ( int $ length ) : \ Generator { if ( $ this -> read_check_after && $ length + $ this -> read_check_pos >= $ this -> read_check_after ) { if ( $ length + $ this -> read_check_pos > $ this -> read_check_after ) { throw new \ danog \ MadelineProto \ Exception ( 'Tried to read too much out of frame data' ) ; } $ data = yield $ this -> read_buffer -> bufferRead ( $ length ) ; hash_update ( $ this -> read_hash , $ data ) ; $ hash = $ this -> getReadHash ( ) ; if ( $ hash !== yield $ this -> read_buffer -> bufferRead ( strlen ( $ hash ) ) ) { throw new \ danog \ MadelineProto \ Exception ( 'Hash mismatch' ) ; } return $ data ; } $ data = yield $ this -> read_buffer -> bufferRead ( $ length ) ; hash_update ( $ this -> read_hash , $ data ) ; if ( $ this -> read_check_after ) { $ this -> read_check_pos += $ length ; } return $ data ; }
Hashes read data asynchronously.

@param int $length Read and hash $length bytes

@throws PendingReadError Thrown if another read operation is still pending.

@return Generator That resolves with a string when the provided promise is resolved and the data is added to the hashing context
Hashes read data asynchronously .