From ee8025e0d803b025921375bfb2ee03ff5c36ddcc Mon Sep 17 00:00:00 2001 From: cc32d9 Date: Wed, 12 May 2021 12:47:13 +0000 Subject: [PATCH] workaround for https://github.com/EOSIO/abieos/issues/124 --- eosio_token_accounting_dbwriter.pl | 17 ++++++++++++++++- eosio_token_accounting_tables.psql | 16 +++++++++++++--- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/eosio_token_accounting_dbwriter.pl b/eosio_token_accounting_dbwriter.pl index 2044fe6..3983377 100644 --- a/eosio_token_accounting_dbwriter.pl +++ b/eosio_token_accounting_dbwriter.pl @@ -84,6 +84,12 @@ ' (SELECT balance FROM ' . $network . '_BALANCES WHERE account_name=? AND contract=? AND currency=?), ?, ?)'); +my $sth_add_failure = $dbh->prepare + ('INSERT INTO ' . $network . '_FAILED_DECODING ' . + '(seq, block_num, block_time, trx_id, contract) ' . + 'VALUES(?,?,?,?,?)'); + + my $sth_upd_sync = $dbh->prepare ('INSERT INTO SYNC (network, block_num) VALUES(?,?) ' . 'ON DUPLICATE KEY UPDATE block_num=?'); @@ -265,7 +271,16 @@ sub process_atrace my $aname = $act->{'name'}; my $data = $act->{'data'}; - return unless ( ref($data) eq 'HASH' ); + + if( ref($data) ne 'HASH' ) + { + if( $contract ne 'eosio.null' ) + { + $sth_add_failure->execute($receipt->{'global_sequence'}, $tx->{'block_num'}, + $tx->{'block_time'}, $tx->{'trx_id'}, $contract); + } + return; + } if( ($aname eq 'transfer' or $aname eq 'issue') and defined($data->{'quantity'}) and diff --git a/eosio_token_accounting_tables.psql b/eosio_token_accounting_tables.psql index fcebd40..b9a799b 100644 --- a/eosio_token_accounting_tables.psql +++ b/eosio_token_accounting_tables.psql @@ -17,7 +17,7 @@ CREATE TABLE %%_BALANCES account_name VARCHAR(13) NOT NULL, contract VARCHAR(13) NOT NULL, currency VARCHAR(8) NOT NULL, - balance BIGINT UNSIGNED NOT NULL, + balance BIGINT NOT NULL, block_num BIGINT NOT NULL, block_time DATETIME NOT NULL, trx_id VARCHAR(64) NOT NULL @@ -36,9 +36,9 @@ CREATE TABLE %%_TRANSFERS currency VARCHAR(8) NOT NULL, account_name VARCHAR(13) NOT NULL, delta BIGINT NOT NULL, - balance BIGINT UNSIGNED NOT NULL, + balance BIGINT NOT NULL, other_party VARCHAR(13) NULL, - memo TEXT + memo BLOB ) ENGINE=InnoDB; CREATE UNIQUE INDEX %%_TRANSFERS_I01 ON %%_TRANSFERS (seq, account_name); @@ -47,3 +47,13 @@ CREATE INDEX %%_TRANSFERS_I03 ON %%_TRANSFERS (account_name, contract, currency, CREATE INDEX %%_TRANSFERS_I04 ON %%_TRANSFERS (trx_id(8)); +CREATE TABLE %%_FAILED_DECODING + ( + seq BIGINT UNSIGNED NOT NULL, + block_num BIGINT NOT NULL, + block_time DATETIME NOT NULL, + trx_id VARCHAR(64) NOT NULL, + contract VARCHAR(13) NOT NULL +) ENGINE=InnoDB; + +CREATE INDEX %%_FAILED_DECODING_I01 ON %%_FAILED_DECODING (contract, seq);