From: Roland Häder Date: Mon, 27 Feb 2012 23:04:37 +0000 (+0000) Subject: Continued with development: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a28f861762e4e10f543f63798b23d31895e63524;p=hub.git Continued with development: - Renamed some methods in ChunkHandler (and interface) - Added another missing public method to HandleableChunks interface - Internal TODO added to implement a way to allow non-announcement packages being hashed with the extra-salt. This extra-salt then needs to be included in the announcement. - TODOs.txt updated --- diff --git a/application/hub/interfaces/handler/chunks/class_HandleableChunks.php b/application/hub/interfaces/handler/chunks/class_HandleableChunks.php index f19ee14c2..ab9c59318 100644 --- a/application/hub/interfaces/handler/chunks/class_HandleableChunks.php +++ b/application/hub/interfaces/handler/chunks/class_HandleableChunks.php @@ -31,6 +31,13 @@ interface HandleableChunks extends Handleable { */ function addAllChunksWithFinal (array $chunks); + /** + * Checks whether unhandled chunks are available + * + * @return $unhandledChunks Whether unhandled chunks are left + */ + function ifUnhandledChunksWithFinalAvailable (); + /** * Handles available chunks by processing one-by-one (not all together, * this would slow-down the whole application) with the help of an @@ -38,7 +45,7 @@ interface HandleableChunks extends Handleable { * * @return void */ - function handleAvailableChunks (); + function handleAvailableChunksWithFinal (); } // [EOF] diff --git a/application/hub/main/handler/chunks/class_ChunkHandler.php b/application/hub/main/handler/chunks/class_ChunkHandler.php index 14a726563..8ee59a934 100644 --- a/application/hub/main/handler/chunks/class_ChunkHandler.php +++ b/application/hub/main/handler/chunks/class_ChunkHandler.php @@ -94,7 +94,7 @@ class ChunkHandler extends BaseHandler implements HandleableChunks, Registerable * * @return $unhandledChunks Whether unhandled chunks are left */ - public function ifUnhandledChunksAvailable () { + public function ifUnhandledChunksWithFinalAvailable () { // Simply check if the stacker is not empty $unhandledChunks = $this->getStackerInstance()->isStackEmpty(self::STACKER_NAME_CHUNKS_WITH_FINAL_EOP) === false; @@ -109,9 +109,9 @@ class ChunkHandler extends BaseHandler implements HandleableChunks, Registerable * * @return void */ - public function handleAvailableChunks () { + public function handleAvailableChunksWithFinal () { // First check if there are undhandled chunks available - assert($this->ifUnhandledChunksAvailable()); + assert($this->ifUnhandledChunksWithFinalAvailable()); // Get an entry from the stacker $chunk = $this->getStackerInstance()->popNamed(self::STACKER_NAME_CHUNKS_WITH_FINAL_EOP); @@ -141,6 +141,12 @@ class ChunkHandler extends BaseHandler implements HandleableChunks, Registerable // Don't process this chunk return; } // END - if + + /* + * It is now known that (as long as the hash algorithm has no + * collisions) the content is the same as the sender sends it to this + * peer. + */ die('chunk=' . $chunk . chr(10)); } } diff --git a/application/hub/main/package/fragmenter/class_PackageFragmenter.php b/application/hub/main/package/fragmenter/class_PackageFragmenter.php index a254b3d18..8799f131c 100644 --- a/application/hub/main/package/fragmenter/class_PackageFragmenter.php +++ b/application/hub/main/package/fragmenter/class_PackageFragmenter.php @@ -271,6 +271,7 @@ class PackageFragmenter extends BaseFrameworkSystem implements Fragmentable, Reg * * @param $rawData Raw data bytes to hash * @return $hash Hash from the raw data + * @todo Implement a way to send non-announcement packages with extra-salt */ private function generateHashFromRawData ($rawData) { /* diff --git a/application/hub/main/tasks/hub/chunks/class_HubChunkAssemblerTask.php b/application/hub/main/tasks/hub/chunks/class_HubChunkAssemblerTask.php index cc2c5d753..8c040645b 100644 --- a/application/hub/main/tasks/hub/chunks/class_HubChunkAssemblerTask.php +++ b/application/hub/main/tasks/hub/chunks/class_HubChunkAssemblerTask.php @@ -70,9 +70,9 @@ class HubChunkAssemblerTask extends BaseTask implements Taskable, Visitable { */ public function executeTask () { // Are there chunks to handle? - if ($this->getHandlerInstance()->ifUnhandledChunksAvailable()) { + if ($this->getHandlerInstance()->ifUnhandledChunksWithFinalAvailable()) { // Then handle them (not all!) - $this->getHandlerInstance()->handleAvailableChunks(); + $this->getHandlerInstance()->handleAvailableChunksWithFinal(); } // END - if } } diff --git a/docs/TODOs.txt b/docs/TODOs.txt index 757301ad1..774faf82e 100644 --- a/docs/TODOs.txt +++ b/docs/TODOs.txt @@ -95,13 +95,14 @@ ./application/hub/main/package/class_NetworkPackage.php:225: * @todo $helperInstance is unused ./application/hub/main/package/class_NetworkPackage.php:229: // @TODO crc32() is very weak, but it needs to be fast ./application/hub/main/package/class_NetworkPackage.php:23: * @todo Needs to add functionality for handling the object's type -./application/hub/main/package/class_NetworkPackage.php:393: // @TODO We may want to do somthing more here? -./application/hub/main/package/class_NetworkPackage.php:499: // @TODO Add some logging here -./application/hub/main/package/class_NetworkPackage.php:525: // @TODO Add some logging here -./application/hub/main/package/class_NetworkPackage.php:629: // @TODO Add some logging here -./application/hub/main/package/class_NetworkPackage.php:728: // @TODO Add some content here -./application/hub/main/package/class_NetworkPackage.php:767: * @todo This may be enchanced for outgoing packages? -./application/hub/main/package/fragmenter/class_PackageFragmenter.php:427: * @todo $helperInstance is unused +./application/hub/main/package/class_NetworkPackage.php:392: // @TODO We may want to do somthing more here? +./application/hub/main/package/class_NetworkPackage.php:498: // @TODO Add some logging here +./application/hub/main/package/class_NetworkPackage.php:524: // @TODO Add some logging here +./application/hub/main/package/class_NetworkPackage.php:628: // @TODO Add some logging here +./application/hub/main/package/class_NetworkPackage.php:727: // @TODO Add some content here +./application/hub/main/package/class_NetworkPackage.php:766: * @todo This may be enchanced for outgoing packages? +./application/hub/main/package/fragmenter/class_PackageFragmenter.php:274: * @todo Implement a way to send non-announcement packages with extra-salt +./application/hub/main/package/fragmenter/class_PackageFragmenter.php:431: * @todo $helperInstance is unused ./application/hub/main/producer/cruncher/keys/class_CruncherKeyProducer.php:106: // @TODO Do something with it ./application/hub/main/producer/cruncher/keys/class_CruncherKeyProducer.php:62: * @todo Find something for init phase of this key producer ./application/hub/main/producer/cruncher/keys/class_CruncherKeyProducer.php:72: * @todo ~30% done