Browse Source

add multi-key reading by the block height #1

main
ghost 10 months ago
parent
commit
20a751ec7e
  1. 30
      kevacoin/get.php

30
kevacoin/get.php

@ -81,7 +81,7 @@ if (empty($clitoris->file->name))
} }
// Merge content data // Merge content data
$pieces = []; $chain = [];
foreach ( foreach (
(array) (array)
_exec( _exec(
@ -93,25 +93,47 @@ foreach (
) )
) as $piece) ) as $piece)
{ {
if (!isset($piece->key) || !isset($piece->value)) if (
!isset($piece->key) ||
!isset($piece->value) ||
!isset($piece->height)
)
{ {
exit( exit(
'please wait for all pieces sending complete!' 'please wait for all pieces sending complete!'
); );
} }
$pieces[$piece->key] = $piece->value; // Keep all key versions in memory
$chain[$piece->key][$piece->height] = $piece->value;
print_r( print_r(
$piece $piece
); );
} }
// Select last piece value by it max block height
//
// piece could have many of versions (with same key)
// this feature related to data reading correction after recovery #1
$pieces = [];
foreach ($chain as $key => $height)
{
ksort(
$height
);
$pieces[$key] = $height[array_key_last($height)];
}
ksort( ksort(
$pieces $pieces
); );
// Save merged data to destination // Save file to destination
$filename = isset($argv[3]) ? $argv[3] : sprintf( $filename = isset($argv[3]) ? $argv[3] : sprintf(
'%s/../data/import/[kevacoin][%s]%s', '%s/../data/import/[kevacoin][%s]%s',
__DIR__, __DIR__,

Loading…
Cancel
Save