Skip to content

Commit

Permalink
ints from sqlite at last (php 8.1)
Browse files Browse the repository at this point in the history
  • Loading branch information
deemru committed Dec 2, 2021
1 parent 458f08d commit 260ac66
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 29 deletions.
6 changes: 3 additions & 3 deletions include/BlockchainParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private function getSponsorship( $asset )
if( $this->getSponsorship->execute( [ $asset ] ) === false )
w8_err( __FUNCTION__ );

$pts = ptsFilter( $this->getSponsorship->fetchAll() );
$pts = $this->getSponsorship->fetchAll();
if( isset( $pts[0] ) && $pts[0][AMOUNT] !== 0 )
$sponsorship = $pts[0];
else
Expand Down Expand Up @@ -328,7 +328,7 @@ private function getPTS( $from, $to )
if( $this->q_getPTS->execute( [ $from, $to ] ) === false )
w8_err( __FUNCTION__ );

return ptsFilter( $this->q_getPTS->fetchAll() );
return $this->q_getPTS->fetchAll();
}

private function getFeesAt( $height, $reward )
Expand Down Expand Up @@ -388,7 +388,7 @@ public function getNGFeesAt( $height )
if( $this->q_getNGFeesAt->execute( [ w8h2kg( $height ) ] ) === false )
w8io_error( 'getNGFeesAt' );

$pts = ptsFilter( $this->q_getNGFeesAt->fetchAll() );
$pts = $this->q_getNGFeesAt->fetchAll();
if( count( $pts ) < 1 )
w8_err( "unexpected getNGFeesAt( $height )" );

Expand Down
4 changes: 2 additions & 2 deletions include/RO.php
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ public function getPTSByAddressId( $id, $filter, $limit, $uid, $d )
$query = 'SELECT * FROM ( SELECT * FROM pts WHERE r3 = ' . $id . $where . ' ORDER BY r0 DESC LIMIT ' . $limit . ' ) UNION
SELECT * FROM pts WHERE r4 = ' . $id . $where . ' ORDER BY r0 DESC LIMIT ' . $limit;

return ptsFilter( $this->db->query( $query )->fetchAll() );
return $this->db->query( $query )->fetchAll();
}

public function getPTSAtHeight( $height )
Expand All @@ -396,7 +396,7 @@ public function getPTSAtHeight( $height )

$pts = $this->getPTSAtHeight->fetchAll();
if( isset( $pts[0] ) )
return ptsFilter( $pts );
return $pts;

return false;
}
Expand Down
20 changes: 0 additions & 20 deletions include/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,26 +139,6 @@ function w8io_tx_type( $type )
}
}

function ptsFilter( $pts )
{
$ptsInts = [];
foreach( $pts as $ts )
$ptsInts[] = [
UID => (int)$ts[UID],
TXKEY => (int)$ts[TXKEY],
TYPE => (int)$ts[TYPE],
A => (int)$ts[A],
B => (int)$ts[B],
ASSET => (int)$ts[ASSET],
AMOUNT => (int)$ts[AMOUNT],
FEEASSET => (int)$ts[FEEASSET],
FEE => (int)$ts[FEE],
ADDON => (int)$ts[ADDON],
GROUP => (int)$ts[GROUP],
];
return $ptsInts;
}

function isAliasType( $type )
{
switch( $type )
Expand Down
8 changes: 4 additions & 4 deletions include/w8_update_helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,14 @@ function procWeight( $blockchain, $parser )
$isWaves = true;
foreach( $pts as $ts )
{
if( $ts[TYPE] !== '7' )
if( $ts[TYPE] !== TX_EXCHANGE )
continue;
if( $ts[A] === $ts[B] )
continue;

$txkey = (int)$ts[TXKEY];
$asset = (int)$ts[ASSET];
$amount = (int)$ts[AMOUNT];
$txkey = $ts[TXKEY];
$asset = $ts[ASSET];
$amount = $ts[AMOUNT];

if( $lastTxKey === $txkey )
{
Expand Down

0 comments on commit 260ac66

Please sign in to comment.