function syncResponse($chunkInfo, $objects)
 {
     global $db;
     if ($this->get('accept_incoming') != 't') {
         debug("node {$remoteId} is not allowed for incoming sync!");
         return NULL;
     }
     $timestamp = $db->getTimestampTz();
     $remoteId = $this->get('node_id');
     // save modified objects
     $db->begin(true);
     // TODO: itt gaz van! ha nem sikerul egy objektumot elmenteni, akkor soha tobbe nem lesz neki elkuldve!!!
     $updatedObjects = sotf_NodeObject::saveModifiedObjects($objects, $remoteId);
     // if db error: don't commit!
     if (is_null($updatedObjects)) {
         return array(array('error' => "store object failed, sync aborted"));
     }
     $db->commit();
     debug("number of updated objects", $updatedObjects);
     $replyInfo = array('received' => count($objects), 'updated' => $updatedObjects);
     if ($chunkInfo['objects_remaining'] == 0) {
         // last chunk,  save node and neighbour stats
         $node = sotf_Node::getLocalNode();
         $this->set('last_sync_in', $timestamp);
         $node->set('last_sync_in', $timestamp);
         // take out from pending nodes, update neighbour list
         if ($this->get('pending_url')) {
             $this->set('pending_url', '');
             $node->set('neighbours', $this->getNeighbourString());
         }
         $this->update();
         $node->update();
         //$replyInfo['node'] = $node->getAll();
     }
     return array($replyInfo);
 }
 function syncResponse($chunkInfo, $nodeData, $objects)
 {
     global $sotfVars;
     $timestamp = $this->db->getTimestampTz();
     // save modified objects
     $updatedObjects = sotf_NodeObject::saveModifiedObjects($objects);
     debug("number of updatd objects", count($updatedObjects));
     $remoteId = $this->get('node_id');
     $currentStamp = $sotfVars->get('sync_stamp', 0);
     $lastSyncStamp = $this->lastSyncStamp();
     $chunkInfo['old_stamp'] = $lastSyncStamp;
     $chunkInfo['current_stamp'] = $currentStamp;
     $count = sotf_NodeObject::countModifiedObjects($remoteId, $lastSyncStamp);
     if ($count > 0) {
         if ($chunkInfo['this_chunk'] == $chunkInfo['num_chunks']) {
             // last chunk: no limits
             $objectsPerPage = 1000000;
         } else {
             $objectsPerPage = ceil($count / $chunkInfo['num_chunks']);
         }
         $from = $objectsPerPage * ($chunkInfo['this_chunk'] - 1) + 1;
         debug("chunk info", $chunkInfo);
         // get new objects to send as reply
         $objects = sotf_NodeObject::getModifiedObjects($this->get('node_id'), $lastSyncStamp, $from, $objectsPerPage, $updatedObjects);
     } else {
         $objects = array();
     }
     // save time of this sync
     $this->saveSyncStatus($timestamp, $currentStamp);
     return array($chunkInfo, $objects);
 }