Skip to content

Commit

Permalink
workaround for EOSIO/abieos#124
Browse files Browse the repository at this point in the history
  • Loading branch information
cc32d9 committed May 12, 2021
1 parent 3df1e2d commit ee8025e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
17 changes: 16 additions & 1 deletion eosio_token_accounting_dbwriter.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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=?');
Expand Down Expand Up @@ -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
Expand Down
16 changes: 13 additions & 3 deletions eosio_token_accounting_tables.psql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand All @@ -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);

0 comments on commit ee8025e

Please sign in to comment.