xrplwin/xrpl-ledgertime
Composer 安装命令:
composer require xrplwin/xrpl-ledgertime
包简介
This package will extract ledger index by giving date and time as input.
README 文档
README
XRPL Ledger Time
This package will extract ledger index by giving date and time as input.
Basically 2023-04-13 15:00:00 UTC will give you 79077871
Install
composer require xrplwin/xrpl-ledgertime
Why?
There is no available XRPL API method to extract exact time of ledger. Say you want to query list of account transactions between Jan 1, 2022 08:00:00 and 12:00:00. For that query you need to provide in account_tx method ledger_index_min and ledger_index_max.
You can lookup local pre-synced database to get required ledger indexes and add them to query.
You can sync and store daily starting ledgers, hourly starting ledgers, etc. Periods you will sync depends of your business needs.
Fair use notice
Always pre-sync times and store them in local or shared database!
DO NOT use this script to query XRPLedger live in production site. This script extracts single ledger datetime by making multiple connections to XRPL Rest API. Use background sync job to pre-sync ledger times.
System time
A rippled server relies on maintaining the correct time. It is recommended that the your system synchronize time using the Network Time Protocol (NTP) with daemons such as ntpd or chrony.
Usage
Option 1 (datetime to ledgerindex)
use XRPLWin\XRPLLedgerTime\XRPLLedgerTimeSyncer; use Carbon\Carbon; $syncer = new XRPLLedgerTimeSyncer(); //init syncer $datetime = Carbon::create(2023, 4, 13, 15, 0, 0, 'UTC'); //create Carbon datetime object $ledgerIndex = $syncer->datetimeToLedgerIndex($datetime); //will return: 79077871
Option 2 (ledgerindex to datetime)
use XRPLWin\XRPLLedgerTime\XRPLLedgerTimeSyncer; $syncer = new XRPLLedgerTimeSyncer(); //init syncer $carbon = $syncer->ledgerIndexToCarbon(79077871);
Options overview:
$syncer = new XRPLLedgerTimeSyncer( [ # Following values are defined by default, uncomment to override //'ledgerindex_low' => 0 ], [ # Following values are defined by default, uncomment to override # These options will be passed to \XRPLWin\XRPL\Client //'endpoint_fullhistory_uri' => 'https://xrplcluster.com' ] );
Running tests
Run all tests in "tests" directory.
composer test
or
./vendor/bin/phpunit --testdox
xrplwin/xrpl-ledgertime 适用场景与选型建议
xrplwin/xrpl-ledgertime 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 78 次下载、GitHub Stars 达 2, 最近一次更新时间为 2023 年 04 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「package」 「composer」 「time」 「datetime」 「ledger」 「index」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 xrplwin/xrpl-ledgertime 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 xrplwin/xrpl-ledgertime 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 xrplwin/xrpl-ledgertime 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Tools to convert between .NET and PHP date formats
Adds the EDTF data type to Wikibase
Date component is a set of methods to help with the manipulation of dates.
Bureaux A Partager Edit - Parse, validate, manipulate, and display dates in PHP w/ i18n support. Inspired by moment.js
Delayed Process For Laravel.
This composer plugin enables installation of GravityForms WordPress plugin and its addons.
统计信息
- 总下载量: 78
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 24
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-04-14