It is PHP API client for Steem/GOLOS blockchain
Github or packagist with MIT license. Author @t3ran13 and active contributor
@semasping
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
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
);
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 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.
I found that some public nodes in connectors is bad for some resongs during testing of connectors
Actual nodes list in connector:
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
);
}
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
Release v4.0.6
Release v4.0.7
Release v4.0.8
Release v4.0.9