* Get the crypto instance and hash the data with no extra salt because
* the other peer doesn't have *this* peer's salt.
*/
- $hash = $this->getCryptoInstance()->hashString($rawData, '', false);
+ $hash = $this->getCryptoInstance()->hashString($rawData, '', FALSE);
// Return it
return $hash;
* @param $prepend Whether append (default) or prepend the chunk
* @return void
*/
- private function addChunkData ($finalHash, $chunkData, $prepend = false) {
+ private function addChunkData ($finalHash, $chunkData, $prepend = FALSE) {
// Hash it
- $rawDataHash = $this->getCryptoInstance()->hashString($chunkData, '', false);
+ $rawDataHash = $this->getCryptoInstance()->hashString($chunkData, '', FALSE);
// Prepend the hash to the chunk
$rawData = (
// @TODO This assert broke packages where the hash chunk was very large: assert(strlen($rawData) <= NetworkPackage::TCP_PACKAGE_SIZE);
// Add it to the array
- if ($prepend === true) {
+ if ($prepend === TRUE) {
// Debug message
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': Prepending ' . strlen($rawData) . ' bytes of a chunk, finalHash=' . $finalHash . ' ...');
array_unshift($this->chunkHashes[$finalHash], $rawDataHash);
} else {
// Debug message
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': Appending ' . strlen($rawData) . ' bytes of a chunk, finalHash=' . $finalHash . ' ...');
- $this->chunks[$finalHash][] = $rawData;
+
+ // Is the array there?
+ if (!isset($this->chunks[$finalHash])) {
+ // Then initialize it
+ $this->chunks[$finalHash] = array();
+ $this->chunkHashes[$finalHash] = array();
+ } // END - if
+
+ // Add both
+ array_push($this->chunks[$finalHash] , $rawData);
array_push($this->chunkHashes[$finalHash], $rawDataHash);
}
}