golos-php-event-listener
PHP event listener for STEEM/GOLOS blockchains
Github or packagist with MIT license. Author
In Release v0.0.1rc3
- Critical bug of MainProcess was fixed
- Errors from api answers are catched in BlockchainExplorerProcess
- Key prefix was added for redis db manager
- Default last block was set to 1
- Errors and exceptions are catched and handled from child processes
- clearParentResources was renamed to clearLegacyResourcesInChild and clearing resourses for Main and Event processes was made
Critical bug of MainProcess was fixed
It was php auto types bug
//was
if ($process->getId() === $processId) {
$processObj = $process;
break;
}
//now
if ((string)$process->getId() == (string)$processId) {
$processObj = $process;
break;
}
It is mean that $process->getId() has always string type, but $processId could be string or integer. When it was different types it made one more the same process.
It was fixed with setting string types for each variable.
Errors from api answers are catched in BlockchainExplorerProcess
When api sent wrong answer in BlockchainExplorerProcess, it was hendled like empty answer, now it throws exception
<?php
//was
$data = $command->execute(
$commandQuery,
'result'
);
//now
$data = $command->execute(
$commandQuery
);
if (!isset($data['result'])) {
throw new \Exception(' - got wrong answer for block ' . $blockNumber);
}
Key prefix was added for redis db manager
Now redis keys have 'GEL' prefix as default, or you can set own in RedisManager. It is convinient when you use 1 redis storage for many aplications, fore example for Steem and Golos.
See example below
<?php
namespace MySteemApp;
use GolosPhpEventListener\app\db\RedisManager;
class RedisManagerForSteem extends RedisManager
{
protected $keyPrefix = 'MySteemApp';
}
and the same for Golos
<?php
namespace MyGolosApp;
use GolosPhpEventListener\app\db\RedisManager;
class RedisManagerForGolos extends RedisManager
{
protected $keyPrefix = 'MyGolosApp';
}
Now you can use 1 redis storage for 2 aplications.
Default last block was set to 1
Last block was set to 1 in BlockchainExplorerProcess as default value.
Errors and exceptions are catched and handled from child processes
Only exceptions were catched and handled in child process before, errors and exceptions are catched and handled now
<?php
public function forkProcess(ProcessInterface $process)
{
//..
//was
catch (\Exception $e)
//now
catch (\Throwable $e)
//..
}
clearParentResources was renamed to clearLegacyResourcesInChild and clearing resourses for Main and Event processes was made
Now child process is cleared from legacy parent resources after forking in MainProcess and EventsHandlersProcess
<?php
// MainProcess
public function clearLegacyResourcesInChild()
{
unset($this->appConfig);
unset($this->processesList);
unset($this->dbManager);
}
// EventsHandlersProcess
public function clearLegacyResourcesInChild()
{
unset($this->processesList);
unset($this->dbManager);
}
It is better with each commit
Commits were done by me for last 14 days
https://github.com/t3ran13/golos-php-event-listener/compare/v0.0.1rc2...v0.0.1rc3
- upd README.md
- fix critical bug of MainProcess
- upd BlockchainExplorerProcess
- added key prefix for redis db
- upd default last block
- upd catch errors and exceptions of child processes
- rename clearParentResources to clearLegacyResourcesInChild and clear resources