Golos/Steem PHP Event Listener [v0.0.1rc3]

in #utopian-io7 years ago (edited)

golos-php-event-listener

PHP event listener for STEEM/GOLOS blockchains

Github or packagist with MIT license. Author @t3ran13

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
Sort:  

Thank you for your contribution. Since you have fixed few bugs but as per our guidelines "Bug Fixes for contributor’s Own Projects will not be considered for the potential reward unless the Bugs were caused by third-party dependencies." and another feature seems to be very less. Please try to add more features in a single contribution.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

Loading...

In any case thx for feedback.

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!

Coin Marketplace

STEEM 0.09
TRX 0.30
JST 0.037
BTC 105232.86
ETH 3570.32
USDT 1.00
SBD 0.57