Skip to content
Snippets Groups Projects
Commit 11635abe authored by Robert Martin-Legene's avatar Robert Martin-Legene
Browse files

Import from sanctioned servers

parent ade0a55a
No related branches found
No related tags found
No related merge requests found
FROM debian
RUN useradd --create-home --shell /bin/bash bfa && mkdir /home/bfa/collector
RUN useradd --create-home --shell /bin/bash bfa && install --owner=bfa --directory /home/bfa/collector
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y libjson-perl libnet-dns-perl libdbd-pg-perl libwww-perl libclass-accessor-perl
RUN apt-get install -y libjson-perl libdbd-pg-perl libwww-perl libclass-accessor-perl less
WORKDIR /home/bfa
COPY collector.pl sql.pm /home/bfa/collector/
RUN chown -R bfa /home/bfa
USER bfa
CMD /home/bfa/collector/collector.pl
#CMD sleep 14d
ENV BFANODE http://public.47525974938.bfa.martin-legene.dk:8545/
COPY sql.pm collectorcommon.pm collector.pl txfetcher.pl /home/bfa/collector/
CMD sleep 14d
This diff is collapsed.
......@@ -16,7 +16,7 @@ sub new
my $self = bless {}, ref $class || $class;
$self->dbh( DBI->connect(
'dbi:Pg:dbname=postgres;host=postgres','postgres',$ENV{'POSTGRES_PASSWORD'},
{AutoCommit=>0,RaiseError=>1}
{ AutoCommit=>0, RaiseError=>1 }
));
return $self;
}
......@@ -93,28 +93,24 @@ sub maxBlockNumber
return $ref->[0];
}
__PACKAGE__->mk_accessors( 'sth_insertTransactionWithContractAddress' );
sub insertTransactionWithContractAddress
__PACKAGE__->mk_accessors( 'sth_updateRcptInfo' );
sub updateRcptInfo
{
my $self = shift;
if ( not defined $self->sth_insertTransactionWithContractAddress )
if ( not defined $self->sth_updateRcptInfo )
{
$self->sth_insertTransactionWithContractAddress(
$self->sth_updateRcptInfo(
$self->dbh->prepare(q(
INSERT INTO transaction
( hash, "blockId", nonce, gas,
"gasPrice", value, "fromAccountId","toAccountId",
status, "gasUsed", input, inputlen,
"contractaddressAccountId", "type" )
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)
UPDATE transaction
SET status=?, "gasUsed"=?, "contractaddressAccountId"=?
WHERE hash=?
))
);
}
$_[1] = $self->selectBlockhashByHash( $_[1] );
$_[6] = $self->selectAccountIdByAddress( $_[6] );
$_[7] = $self->selectAccountIdByAddress( $_[7] ) if defined $_[7];
$_[12] = $self->selectAccountIdByAddress( $_[12] ) if defined $_[12];
$self->sth_insertTransactionWithContractAddress->execute( @_, 'explicit' );
$_[3] = $self->selectAccountIdByAddress( $_[3] ) if defined $_[3];
# hash is in the front but goes in the back in SQL
push @_, shift;
$self->sth_updateRcptInfo->execute( @_ );
}
__PACKAGE__->mk_accessors( 'sth_insertTransaction' );
......@@ -128,16 +124,15 @@ sub insertTransaction
INSERT INTO transaction
( hash, "blockId", nonce, gas,
"gasPrice", value, "fromAccountId","toAccountId",
status, "gasUsed", input, inputlen,
"type" )
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)
input, inputlen, "type" )
VALUES (?,?,?,?,?,?,?,?,?,?,?)
))
);
}
$_[1] = $self->selectBlockhashByHash( $_[1] );
$_[1] = $self->selectBlockhashByHash( $_[1] );
$_[6] = $self->selectAccountIdByAddress( $_[6] );
$_[7] = $self->selectAccountIdByAddress( $_[7] ) if defined $_[7];
$self->sth_insertTransaction->execute( @_, 'explicit' );
$self->sth_insertTransaction->execute( @_ );
}
my @cacheBlockhash;
......@@ -405,7 +400,7 @@ sub selectTransactionByHash
{
$self->sth_selectTransactionByHash(
$self->dbh->prepare(q(
SELECT 1
SELECT "blockId", "fromAccountId", nonce
FROM transaction
WHERE hash=?
))
......@@ -466,4 +461,99 @@ sub selectMaxUnknownSigned
return $blockhash;
}
__PACKAGE__->mk_accessors( 'sth_selecttxwhichmissreceipts' );
sub selecttxwhichmissreceipts
{
my ( $self, $maxinarow ) = @_;
if ( not defined $self->sth_selecttxwhichmissreceipts )
{
$self->sth_selecttxwhichmissreceipts(
$self->dbh->prepare(q(
SELECT hash, "type"
FROM transaction
WHERE "gasUsed" IS NULL
ORDER BY "toAccountId" desc,
nonce
))
);
}
my @txhashes;
$self->sth_selecttxwhichmissreceipts->execute();
while ( my $ref = $self->sth_selecttxwhichmissreceipts->fetchrow_arrayref and $maxinarow-- != 0 )
{
next if $ref->[1] eq 'external';
push @txhashes, $ref->[0];
}
$self->sth_selecttxwhichmissreceipts->finish();
return @txhashes;
}
__PACKAGE__->mk_accessors( 'sth_selectduplicateblocknumbers' );
sub selectduplicateblocknumbers
{
my ( $self ) = shift;
if ( not defined $self->sth_selectduplicateblocknumbers )
{
$self->sth_selectduplicateblocknumbers(
$self->dbh->prepare(q(
SELECT number
FROM block
WHERE number < (
SELECT MAX(number)
FROM block)-30
GROUP BY number
HAVING COUNT(number) > 1
))
);
}
my @blocknumbers;
$self->sth_selectduplicateblocknumbers->execute();
while ( my $ref = $self->sth_selectduplicateblocknumbers->fetchrow_arrayref )
{
push @blocknumbers, $ref->[0];
}
$self->sth_selectduplicateblocknumbers->finish();
return @blocknumbers;
}
__PACKAGE__->mk_accessors( 'sth_deletetransactionsinblocknumbers' );
sub deletetransactionsinblocknumbers
{
my ( $self ) = shift;
if ( not defined $self->sth_deletetransactionsinblocknumbers )
{
$self->sth_deletetransactionsinblocknumbers(
$self->dbh->prepare(q(
DELETE FROM transaction
WHERE "blockId" IN (
SELECT id
FROM block
WHERE number = ?
)
))
);
}
$self->sth_deletetransactionsinblocknumbers->execute($_)
foreach @_;
$self->sth_deletetransactionsinblocknumbers->finish();
}
__PACKAGE__->mk_accessors( 'sth_deleteblocknumber' );
sub deleteblocknumbers
{
my ( $self ) = shift;
if ( not defined $self->sth_deleteblocknumber )
{
$self->sth_deleteblocknumber(
$self->dbh->prepare(q(
DELETE FROM block
WHERE number = ?
))
);
}
$self->sth_deleteblocknumber->execute($_)
foreach @_;
$self->sth_deleteblocknumber->finish();
}
1;
## POSTGRES SUPERUSER user name is postgres
## POSTGRES SUPERUSER password is onlythelonely
## POSTGRES USER leer has password bfa defined in postgres/90-add-db-user.sh
......@@ -20,10 +19,13 @@ services:
collector:
build: collector
#command: "collector/colletor.pl"
restart: always
depends_on:
- postgres
environment:
POSTGRES_PASSWORD: theswampthing
BFANODE: http://200.108.146.200:8545/
BFANODE: http://public.47525974938.bfa.martin-legene.dk:8545/
volumes:
- ./collector:/home/bfa/collector
......
......@@ -101,10 +101,8 @@ CREATE TABLE "public"."transaction" (
"toAccountId" bigint,
"contractaddressAccountId"
bigint,
"status" smallint
NOT NULL,
"gasUsed" numeric(79)
NOT NULL,
"status" smallint,
"gasUsed" numeric(79),
"inputlen" integer
NOT NULL,
"input" text
......@@ -126,6 +124,9 @@ CREATE TABLE "public"."transaction" (
REFERENCES block(id)
NOT DEFERRABLE
) WITH (oids = false);
CREATE INDEX "transaction_hash"
ON "public"."transaction"
USING btree ("hash");
CREATE INDEX "transaction_contractaddressAccountId"
ON "public"."transaction"
USING btree ("contractaddressAccountId");
......@@ -138,6 +139,9 @@ CREATE INDEX "transaction_toAccountId"
CREATE INDEX "transaction_blockId"
ON "public"."transaction"
USING btree ("blockId");
CREATE INDEX "transaction_gasUsed"
ON "public"."transaction"
USING btree ("gasUsed");
CREATE VIEW b
AS
......@@ -167,9 +171,9 @@ CREATE VIEW t
gas,
"gasPrice" "gas price",
value,
a1.address "from",
a2.address "to",
a3.address "contractaddress",
coalesce(a1.shortname, a1.name, a1.address) "from",
coalesce(a2.shortname, a2.name, a2.address) "to",
coalesce(a3.shortname, a3.name, a3.address) "contractaddress",
status,
transaction."gasUsed" "gas used",
inputlen
......@@ -184,33 +188,46 @@ CREATE VIEW t
AND a2.id = "toAccountId";
INSERT INTO "account" ("id", "address", "shortname", "name") VALUES
(1, '0x377ab0cd00744dbb07b369cd5c0872dcd362c8f0', 'UNER', 'Universidad Nacional de Entre Rios'),
(2, '0x2feb6a8876bd9e2116b47834b977506a08ea77bd', 'PNA', 'Prefectura Nacional Argentina'),
(1, '0x377ab0cd00744dbb07b369cd5c0872dcd362c8f0', 'UNER', 'Universidad Nacional de Entre Rios'),
(2, '0x2feb6a8876bd9e2116b47834b977506a08ea77bd', 'PNA', 'Prefectura Nacional Argentina'),
(3, '0x354779914a94ad428d2b53ae96cce3010bb0ce1e', 'RedLink', 'RedLink SA'),
(4, '0x998c2651db6f76ca568c0071667d265bcc1b1e98', NULL, 'ASI'),
(5, '0xd1f17aa41354d58940c300ffd79a200944dda2df', NULL, 'Marandu'),
(4, '0x998c2651db6f76ca568c0071667d265bcc1b1e98', NULL, 'ASI'),
(5, '0xd1f17aa41354d58940c300ffd79a200944dda2df', NULL, 'Marandu'),
(6, '0x39170a1ce03729d141dfaf8077c08b72c9cfdd0c', 'IXPBB', 'IXP Bahia Blanca'),
(7, '0x02665f10cb7b93b4491ac9594d188ef2973c310a', 'CABASE-MZA', 'CABASE Mendoza'),
(8, '0x19fe7b9b3a1bebde77c5374c8e13c623e3d1b5b2', 'ARIU', 'Asociación Redes de Interconexión Universitaria'),
(8, '0x19fe7b9b3a1bebde77c5374c8e13c623e3d1b5b2', 'ARIU', 'Asociación Redes de Interconexión Universitaria'),
(9, '0xe70fbc9d6be2fe509e4de7317637d8ee83d4f13c', 'CABASE-PMY', 'CABASE Puerto Madryn'),
(10, '0xe191ac3108cb2c5d70d0e978876c048d4ba41b03', 'ANSV', 'Agencia Nacional de Seguridad Vial'),
(11, '0xf36475eb25ba0c825455f150b26e24ab9449a443', 'SRT', 'Superintendencia de Riesgos del Trabajo'),
(10, '0xe191ac3108cb2c5d70d0e978876c048d4ba41b03', 'ANSV', 'Agencia Nacional de Seguridad Vial'),
(11, '0xf36475eb25ba0c825455f150b26e24ab9449a443', 'SRT', 'Superintendencia de Riesgos del Trabajo'),
(12, '0xd1420aa9dd092f50f68913e9e53b378a68e76ed7', 'SMGP/OPTIC', 'Secretaría de Modernización de la Gestión Pública / Oficina Provincial de Tecnologías de la Información y la Comunicación - Gobierno de la Provincia del Neuquén'),
(13, '0x2388d2cdb2cd6e7722b4af39c3bb406dd31f560e', 'UNR', 'Universidad Nacional de Rosario'),
(13, '0x2388d2cdb2cd6e7722b4af39c3bb406dd31f560e', 'UNR', 'Universidad Nacional de Rosario'),
(14, '0x342e1d075d820ed3f9d9a05967ec4055ab23fa1e', 'CABASE', 'CABASE CABA'),
(15, '0xb3d1209aefbe00c78b2247656e2ddfa9e3897526', 'Colescriba', 'Colegio de Escribanos de la Provincia de Buenos Aires'),
(16, '0xa14152753515674ae47453bea5e155a20c4ebabc', 'UP', 'Universidad de Palermo'),
(17, '0x97a47d718eab9d660b10de08ef42bd7fd915b783', 'UNLP', 'Universidad Nacional de La Plata'),
(18, '0x850b30dc584b39275a7ddcaf74a5c0e211523a30', 'UM', 'Ultima Milla'),
(19, '0x609043ebde4a06bd28a1de238848e8f82cca9c23', 'UNSJ', 'Universidad Nacional de San Juan'),
(20, '0xb43b53af0db2c3fac788195f4b4dcf2b3d72aa44', NULL, 'IPlan'),
(21, '0x46991ada2a2544468eb3673524641bf293f23ccc', 'UNC', 'Universidad Nacional de Cordoba'),
(22, '0x401d7a8432caa1025d5f093276cc6ec957b87c00', 'ONTI', 'Oficina Nacional de Tecnologias de Informacion'),
(23, '0x91c055c6478bd0ad6d19bcb58f5e7ca7b04e67f1', 'DGSI', 'Dirección General de Sistemas Informáticos'),
(16, '0xa14152753515674ae47453bea5e155a20c4ebabc', 'UP', 'Universidad de Palermo'),
(17, '0x97a47d718eab9d660b10de08ef42bd7fd915b783', 'UNLP', 'Universidad Nacional de La Plata'),
(18, '0x850b30dc584b39275a7ddcaf74a5c0e211523a30', 'UM', 'Ultima Milla'),
(19, '0x609043ebde4a06bd28a1de238848e8f82cca9c23', 'UNSJ', 'Universidad Nacional de San Juan'),
(20, '0xb43b53af0db2c3fac788195f4b4dcf2b3d72aa44', NULL, 'IPlan'),
(21, '0x46991ada2a2544468eb3673524641bf293f23ccc', 'UNC', 'Universidad Nacional de Cordoba'),
(22, '0x401d7a8432caa1025d5f093276cc6ec957b87c00', 'ONTI', 'Oficina Nacional de Tecnologias de Informacion'),
(23, '0x91c055c6478bd0ad6d19bcb58f5e7ca7b04e67f1', 'DGSI', 'Dirección General de Sistemas Informáticos'),
(24, '0x52f8a89484947cd29903b6f52ec6beda69965e38', 'CABASE-PSS', 'CABASE Posadas'),
(25, '0x9b3ac6719b02ec7bb4820ae178d31c0bbda3a4e0', 'Everis', 'Everis'),
(26, '0x99d6c9fca2a61d4ecdeb403515eb8508dc560c6b', NULL, NULL),
(27, '0xc0310a7b3b25f49b11b901a667208a3eda8d7ceb', '', 'SyT'),
(28, '0xabeff859aa6b0fb206d840dbf19de970065d4437', NULL, 'Belatrix');
(26, '0x99d6c9fca2a61d4ecdeb403515eb8508dc560c6b', NULL, 'Ultima Milla 0x99 anterior'),
(27, '0xc0310a7b3b25f49b11b901a667208a3eda8d7ceb', NULL, 'SyT'),
(28, '0xabeff859aa6b0fb206d840dbf19de970065d4437', NULL, 'Belatrix');
(401, '0xbfa02a9639318f5ed1291e2cee387aa9f9d68f98', NULL, 'BFA vault 01'),
(402, '0xbfa1c42c7381a4ad32e13ce3263b639a0e0488f2', NULL, 'BFA vault 02'),
(403, '0xbfa2c97c3f59cc929e8feb1aee2aca0b38235d18', NULL, 'BFA vault 03'),
(404, '0xbfa3eb31f6526a5b29ae2302508bb6b1400d1fd1', NULL, 'BFA vault 04'),
(405, '0xbfa846ddd1fb18af693f24d316c12d8e88f4b79f', NULL, 'BFA vault 05'),
(406, '0xbfa8b1acfb51da0975274c6ebd46704c6c670a07', NULL, 'BFA vault 06'),
(407, '0xbfab583022c5c18fec70965d63985b86f96c5657', NULL, 'BFA vault 07'),
(408, '0xbfae9512c1cf4d9ce549333725c02ee8b3e5f049', NULL, 'BFA vault 08'),
(500, '0xd15dd6dbbe722b451156a013c01b29d91e23c3d6', 'dist1-mgr', 'admin de destileria1'),
(501, '0xecb6aff6e38dc58c4d9aae2f7927a282bcb77ac2', 'SC dist1', 'SC destileria1'),
(502, '0xbf1ce9cca7dedea3fdb22d169b49643664602ee1', 'DGSI-dist2', 'Destileria de DGSI'),
(503, '0xc3cf96af51d3c41dfbe428de75a8e5597d4d7a7b', 'SC-dist2', 'SC destileria de DGSI'),
-- 2020-07-13 05:48:47.242334+00
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment