drupol/phpmerkle

快速动态的Merkle树实现

2.2.1 2019-12-11 07:43 UTC

This package is auto-updated.

Last update: 2024-09-11 18:05:48 UTC


README

Latest Stable Version GitHub stars Total Downloads GitHub Workflow Status Scrutinizer code quality Code Coverage Mutation testing badge Read the Docs License Say Thanks! Donate!

PhpMerkle

使用简单数组快速实现的PHP版本的Merkle树

文档

待办事项。

需求

  • PHP >= 7.1

安装

composer require drupol/phpmerkle

用法

对象的使用方式与常规数组相同。

<?php

declare(strict_types=1);

include './vendor/autoload.php';

$tree = new drupol\phpmerkle\Merkle();

$sentence = 'Science is made up of so many things that appear obvious after they are explained .';

foreach (explode(' ', $sentence) as $word) {
    $tree[] = $word;
}

echo $tree->hash(); // c689102cdf2a5b30c2e21fdad85e4bb401085227aff672a7240ceb3410ff1fb6

代码质量、测试和基准测试

每次在库中引入更改时,Github都会运行测试和基准测试。

库使用PHPSpec编写了测试。您可以在spec目录中查看它们。运行composer phpspec以触发测试。

在每次提交之前,都会使用GrumPHP执行一些检查,手动运行./vendor/bin/grumphp run以进行检查。

使用PHPBench对库进行基准测试,要运行基准测试:运行composer bench

使用PHPInfection确保您的代码得到适当的测试,运行composer infection以测试您的代码。

贡献

请自由地向此库发送Github pull请求。我非常积极回应:-)