From 20a751ec7e71772aaba78ca590cbb1a5130f9371 Mon Sep 17 00:00:00 2001 From: ghost Date: Wed, 22 Nov 2023 18:24:39 +0200 Subject: [PATCH] add multi-key reading by the block height #1 --- kevacoin/get.php | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/kevacoin/get.php b/kevacoin/get.php index 0a5d638..f479ab3 100644 --- a/kevacoin/get.php +++ b/kevacoin/get.php @@ -81,7 +81,7 @@ if (empty($clitoris->file->name)) } // Merge content data -$pieces = []; +$chain = []; foreach ( (array) _exec( @@ -93,25 +93,47 @@ foreach ( ) ) as $piece) { - if (!isset($piece->key) || !isset($piece->value)) + if ( + !isset($piece->key) || + !isset($piece->value) || + !isset($piece->height) + ) { exit( '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( $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( $pieces ); -// Save merged data to destination +// Save file to destination $filename = isset($argv[3]) ? $argv[3] : sprintf( '%s/../data/import/[kevacoin][%s]%s', __DIR__,