Skip to content

Commit

Permalink
change balance in func aeron
Browse files Browse the repository at this point in the history
  • Loading branch information
kleninmaxim committed May 18, 2022
1 parent c5fad1e commit 4b47444
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions kernel/receive_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
$memcached = new Memcached();
$memcached->addServer('localhost', 11211);

$balances = [];

// получаем конфиг от конфигуратора
$config = DEBUG_HTML_VISION ? CONFIG : (new Configurator())->getConfig(EXCHANGE, INSTANCE);

Expand Down Expand Up @@ -54,18 +56,32 @@ function handler_orderbooks(string $message): void
function handler_balances(string $message): void
{

global $memcached;
global $memcached, $balances;

// если данные пришли
if ($data = Aeron::messageDecode($message)) {

// если event как data, а node как gate
if ($data['event'] == 'data' && $data['node'] == 'gate' && isset($data['data'])) {

if (empty($balances)) {

$balances[$data['exchange']] = $data['data'];

} else {

foreach ($data['data'] as $asset => $datum) {

$balances[$data['exchange']][$asset] = $datum;

}

}

// записать в memcached
$memcached->set(
$data['exchange'] . '_' . $data['action'],
$data['data']
$balances[$data['exchange']]
);

} else {
Expand Down

0 comments on commit 4b47444

Please sign in to comment.