PHP Graphene Node Client [v4.0.4 - v4.0.9]
php-graphene-node-client
It is PHP API client for Steem/GOLOS blockchain
Github or packagist with MIT license. Author @t3ran13 and active contributor @semasping
In Release v4.0.4
- fix of string serialization bug fix for strings between 128-256 length
In Release v4.0.6
- critical bug was fixed for serializer string
- GetConfig command was added
In Release v4.0.7
- added expiration time parameter for transaction init
In Release v4.0.8
- updated algorithm for ordering nodes by timeout
- update WS nodes list for steem connector
- update HttpJsonRpc nodes list for steem connector
In Release v4.0.9
- added class for calculating bandwidth for accounts
- added ability on the fly change timeout and reconnect tries for connectors
Critical bug was fixed for serializer string
Now serialization of strings is correct before 11k latin symbols.
You could saw error 3030000 tx_missing_posting_auth: missing required posting authority in answer from node before
GetConfig command was added
You can use new command in two ways
use GrapheneNodeClient\Commands\CommandQueryData;
use GrapheneNodeClient\Commands\Commands;
use GrapheneNodeClient\Commands\Single\GetConfig;
//single command class
$command = new GetConfig($connector);
$commandQueryData = new CommandQueryData();
$answer = $command->execute(
$commandQueryData
);
//or commands aggregator class
$commands = new Commands($connector);
$commands->get_config();
$commandQueryData = new CommandQueryData();
$answer = $commands->execute(
$commandQueryData
);
Expiration time parameter was added for transaction init
Now you can set any expiration time (it is 2 min by default) for transaction in DateInterval format as show below.
If transaction do not get to blockchain during expiration time it will be canceled.
<?php
use GrapheneNodeClient\Tools\Transaction;
use GrapheneNodeClient\Connectors\Http\SteemitHttpConnector;
use GrapheneNodeClient\Connectors\WebSocket\GolosWSConnector;
$connector = new SteemitHttpConnector();
/** @var CommandQueryData $tx */
$tx = Transaction::init($connector, 'PT4M');// expiration time is 4 min in DateInterval format
$tx->setParamByKey(
'0:operations:0',
[
'vote',
[
'voter' => $voter,
'author' => $author,
'permlink' => $permlink,
'weight' => $weight
]
]
);
$command = new BroadcastTransactionSynchronousCommand($connector);
Transaction::sign($chainName, $tx, ['posting' => $publicWif]);
$answer = $command->execute(
$tx
);
The algorithm for ordering nodes by timeout was updated
The idea of this feature is testing and ordering nodes in connector by timeout.
All down or slow nodes will be skip and faster nodes will be in top. It is enough to test only 1 time during each php process. Each command will be know state of connector after privious. It is awesome for cron scripts with many calls to api.
Now it is 2 get_discussions_by_created requests to each node and this give more good ordering of nodes by timeout.
Update WS/HttpJsonRpc nodes list for Steem connectors
I found that some public nodes in connectors is bad for some resongs during testing of connectors
- https://steemd.pevo.science answers too often 503
- wss://steemd.minnowsupportproject.org or https://steemd.minnowsupportproject.org send not full answers, some fields are empty
Actual nodes list in connector:
- ws:
- 'wss://steemd.privex.io'
- 'wss://rpc.buildteam.io'
- 'wss://steemd.pevo.science'
- http:
Class for calculating bandwidth for accounts was added
Sometimes you can't send transaction to blockchain because your account has not enough bandwidth. Now you can check this before sending transaction to blockchain as shown below
<?php
use GrapheneNodeClient\Connectors\Http\SteemitHttpConnector;
use GrapheneNodeClient\Commands\CommandQueryData;
use GrapheneNodeClient\Tools\Bandwidth;
use GrapheneNodeClient\Tools\Transaction;
$connector = new SteemitHttpConnector();
/** @var CommandQueryData $tx */
$tx = Transaction::init($connector, 'PT4M');
$tx->setParamByKey(
'0:operations:0',
[
'vote',
[
'voter' => $voter,
'author' => $author,
'permlink' => $permlink,
'weight' => $weight
]
]
);
$command = new BroadcastTransactionSynchronousCommand($connector);
Transaction::sign($chainName, $tx, ['posting' => $publicWif]);
$bandwidth = Bandwidth::getBandwidthByAccountName($this->rewardPoolName, 'market', $connector);
//Array
//(
// [used] => 3120016
// [available] => 148362781
//)
$trxString = mb_strlen(json_encode($tx->getParams()), '8bit');
if ($trxString * 10 + $bandwidth['used'] < $bandwidth['available']) {
$answer = $command->execute(
$tx
);
}
Ability was added on the fly change timeout and reconnect tries for connectors
see example below
<?php
use GrapheneNodeClient\Connectors\Http\SteemitHttpConnector;
use GrapheneNodeClient\Commands\CommandQueryData;
use GrapheneNodeClient\Commands\Single\GetConfig;
use GrapheneNodeClient\Tools\Bandwidth;
use GrapheneNodeClient\Tools\Transaction;
$connector = new SteemitHttpConnector();
$connector->setConnectionTimeoutSeconds(3); //timeout
$connector->setMaxNumberOfTriesToReconnect(1); //tries
$command = new GetConfig($connector);
$commandQueryData = new CommandQueryData();
$answer = $command->execute(
$commandQueryData
);
/** @var CommandQueryData $tx */
$tx = Transaction::init($connector, 'PT4M');
$tx->setParamByKey(
'0:operations:0',
[
'vote',
[
'voter' => $voter,
'author' => $author,
'permlink' => $permlink,
'weight' => $weight
]
]
);
$command = new BroadcastTransactionSynchronousCommand($connector);
Transaction::sign($chainName, $tx, ['posting' => $publicWif]);
$connector->setConnectionTimeoutSeconds(20); //timeout
$connector->setMaxNumberOfTriesToReconnect(3); //tries
$answer = $command->execute(
$tx
);
It is better with each commit
Commits were done by me for last 12 days
https://github.com/t3ran13/php-graphene-node-client/compare/v4.0.3...v4.0.9
Release v4.0.4
- fix critical bug OperationSerializer
Release v4.0.6
- added GetConfigCommand
- fix critical bug for serializer string
- upd README.md
- hide debug info OperationSerializer
Release v4.0.7
- added expiration time parameter for transaction init
Release v4.0.8
- update HttpJsonRpc nodes list for steem connector
- update WS nodes list for steem connector
- updated algorithm for ordering nodes by timeout
Release v4.0.9
- added class for calculating bandwidth for accounts
- added ability on the fly change timeout and reconnect tries for connections
- upd README.md
Thanks for the contribution!
A great overview of all the features you added, the code is well-commented and the commit messages are very clear. Also, the link to the comparison is greatly appreciated! Keep up the good work!
Click here to see how your contribution was evaluated.
Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]
thanks you too for feedback)
@t3ran13 thank you for contribution to the "php-graphene-node-client" lib.
it is my pleasure
https://steemit.com/coding/@gaottantacinque/rasmus-lerdorf-php-inventor-in-milan
Thanks :)
https://steemit.com/coding/@gaottantacinque/rasmus-lerdorf-php-inventor-in-milan
Thanks :)
Hey @t3ran13
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!
Contributing on Utopian
Learn how to contribute on our website or by watching this tutorial on Youtube.
Want to chat? Join us on Discord https://discord.gg/h52nFrV.
Vote for Utopian Witness!
thx)
https://steemit.com/community/@faldi81/laugh-with-a-friend-steemit-where-it-or-beginners-steemit-9c83f7905b81a