blob: 4ad99c3a110a19174556ea3603fa7db893986125 [file] [log] [blame]
Zhenkai Zhu8224bb62013-01-06 15:58:02 -08001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2013 University of California, Los Angeles
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
Alexander Afanasyev20bc8e22013-01-17 10:56:04 -080018 * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
19 * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
Zhenkai Zhu8224bb62013-01-06 15:58:02 -080020 */
21
22#include "sync-core.h"
Alexander Afanasyev49a30d02013-01-21 21:38:48 -080023#include "sync-state-helper.h"
Alexander Afanasyevc507ac22013-01-21 16:01:58 -080024#include "logging.h"
Alexander Afanasyevabe952a2013-01-17 17:06:32 -080025#include "random-interval-generator.h"
Zhenkai Zhu3566f2f2013-01-25 23:47:59 -080026#include "simple-interval-generator.h"
27#include "periodic-task.h"
Alexander Afanasyevabe952a2013-01-17 17:06:32 -080028
Alexander Afanasyevc507ac22013-01-21 16:01:58 -080029#include <boost/lexical_cast.hpp>
Zhenkai Zhu3b406592013-01-25 21:07:49 -080030#include <boost/make_shared.hpp>
Alexander Afanasyevc507ac22013-01-21 16:01:58 -080031
32INIT_LOGGER ("Sync.Core");
33
Zhenkai Zhue851b952013-01-13 22:29:57 -080034const string SyncCore::RECOVER = "RECOVER";
Zhenkai Zhue573ae82013-01-15 13:15:52 -080035const double SyncCore::WAIT = 0.05;
Zhenkai Zhue851b952013-01-13 22:29:57 -080036const double SyncCore::RANDOM_PERCENT = 0.5;
37
Alexander Afanasyevc507ac22013-01-21 16:01:58 -080038using namespace boost;
Alexander Afanasyev49a30d02013-01-21 21:38:48 -080039using namespace Ccnx;
Alexander Afanasyevc507ac22013-01-21 16:01:58 -080040
Alexander Afanasyev49a30d02013-01-21 21:38:48 -080041SyncCore::SyncCore(SyncLogPtr syncLog, const Name &userName, const Name &localPrefix, const Name &syncPrefix,
Zhenkai Zhu95160102013-01-25 21:54:57 -080042 const StateMsgCallback &callback, CcnxWrapperPtr ccnx, double syncInterestInterval/*= -1.0*/)
Alexander Afanasyev49a30d02013-01-21 21:38:48 -080043 : m_ccnx (ccnx)
44 , m_log(syncLog)
Alexander Afanasyevd94a8c62013-01-24 13:53:40 -080045 , m_scheduler(new Scheduler ())
46 , m_stateMsgCallback(callback)
47 , m_syncPrefix(syncPrefix)
48 , m_recoverWaitGenerator(new RandomIntervalGenerator(WAIT, RANDOM_PERCENT, RandomIntervalGenerator::UP))
Zhenkai Zhu95160102013-01-25 21:54:57 -080049 , m_syncInterestInterval(syncInterestInterval)
Zhenkai Zhu8224bb62013-01-06 15:58:02 -080050{
Zhenkai Zhub330aed2013-01-17 13:29:37 -080051 m_rootHash = m_log->RememberStateInStateLog();
Alexander Afanasyevd6c2a902013-01-19 21:24:30 -080052
Alexander Afanasyev49a30d02013-01-21 21:38:48 -080053 m_ccnx->setInterestFilter(m_syncPrefix, boost::bind(&SyncCore::handleInterest, this, _1));
Alexander Afanasyevdac84922013-01-20 23:32:17 -080054 // m_log->initYP(m_yp);
Alexander Afanasyev7326a252013-01-20 23:43:25 -080055 m_log->UpdateLocalLocator (localPrefix);
56
Zhenkai Zhue573ae82013-01-15 13:15:52 -080057 m_scheduler->start();
Zhenkai Zhu3b406592013-01-25 21:07:49 -080058 string tag = userName.toString() + "send-sync-interest";
Zhenkai Zhu95160102013-01-25 21:54:57 -080059 double interval = (m_syncInterestInterval > 0 && m_syncInterestInterval < 30.0) ? m_syncInterestInterval : 4.0;
Zhenkai Zhu3566f2f2013-01-25 23:47:59 -080060 m_sendSyncInterestTask = make_shared<PeriodicTask>(bind(&SyncCore::sendSyncInterest, this), tag, m_scheduler, make_shared<SimpleIntervalGenerator>(interval));
Zhenkai Zhu74dd53c2013-01-10 23:39:57 -080061 sendSyncInterest();
62}
63
64SyncCore::~SyncCore()
65{
Alexander Afanasyevfc720362013-01-24 21:49:48 -080066 // m_scheduler->shutdown ();
Alexander Afanasyevd6c2a902013-01-19 21:24:30 -080067 // need to "deregister" closures
Zhenkai Zhue851b952013-01-13 22:29:57 -080068}
69
Zhenkai Zhu74dd53c2013-01-10 23:39:57 -080070void
Alexander Afanasyevcbda9922013-01-22 11:21:12 -080071SyncCore::updateLocalPrefix (const Name &localPrefix)
Zhenkai Zhu74dd53c2013-01-10 23:39:57 -080072{
Alexander Afanasyevcbda9922013-01-22 11:21:12 -080073 m_log->UpdateLocalLocator (localPrefix);
Zhenkai Zhu74dd53c2013-01-10 23:39:57 -080074}
75
76void
Zhenkai Zhue851b952013-01-13 22:29:57 -080077SyncCore::updateLocalState(sqlite3_int64 seqno)
Zhenkai Zhu74dd53c2013-01-10 23:39:57 -080078{
Alexander Afanasyev7326a252013-01-20 23:43:25 -080079 m_log->UpdateLocalSeqNo (seqno);
Zhenkai Zhuc3fd51e2013-01-22 10:45:54 -080080 localStateChanged();
Zhenkai Zhuc3fd51e2013-01-22 10:45:54 -080081}
Alexander Afanasyev49a30d02013-01-21 21:38:48 -080082
Zhenkai Zhuc3fd51e2013-01-22 10:45:54 -080083void
84SyncCore::localStateChanged()
85{
Zhenkai Zhu74dd53c2013-01-10 23:39:57 -080086 HashPtr oldHash = m_rootHash;
Zhenkai Zhub330aed2013-01-17 13:29:37 -080087 m_rootHash = m_log->RememberStateInStateLog();
Zhenkai Zhu74dd53c2013-01-10 23:39:57 -080088
Zhenkai Zhub330aed2013-01-17 13:29:37 -080089 SyncStateMsgPtr msg = m_log->FindStateDifferences(*oldHash, *m_rootHash);
Zhenkai Zhu74dd53c2013-01-10 23:39:57 -080090
91 // reply sync Interest with oldHash as last component
Alexander Afanasyev49a30d02013-01-21 21:38:48 -080092 Name syncName = Name (m_syncPrefix)(oldHash->GetHash(), oldHash->GetHashBytes());
Alexander Afanasyev08aa70a2013-01-22 22:16:25 -080093 BytesPtr syncData = serializeMsg (*msg);
Alexander Afanasyev49a30d02013-01-21 21:38:48 -080094
95 m_ccnx->publishData(syncName, *syncData, FRESHNESS);
Alexander Afanasyevfc720362013-01-24 21:49:48 -080096 _LOG_DEBUG ("[" << m_log->GetLocalName () << "] localStateChanged ");
Alexander Afanasyevfcf81dc2013-01-25 20:36:58 -080097 _LOG_TRACE ("[" << m_log->GetLocalName () << "] publishes: " << oldHash->shortHash ());
Alexander Afanasyevfc720362013-01-24 21:49:48 -080098 // _LOG_TRACE (msg);
Zhenkai Zhu74dd53c2013-01-10 23:39:57 -080099
100 // no hurry in sending out new Sync Interest; if others send the new Sync Interest first, no problem, we know the new root hash already;
101 // this is trying to avoid the situation that the order of SyncData and new Sync Interest gets reversed at receivers
Alexander Afanasyevcbda9922013-01-22 11:21:12 -0800102 Scheduler::scheduleOneTimeTask (m_scheduler, 0.05,
Alexander Afanasyevc507ac22013-01-21 16:01:58 -0800103 bind(&SyncCore::sendSyncInterest, this),
104 lexical_cast<string> (*m_rootHash));
105
Zhenkai Zhud276f1e2013-01-24 17:37:31 -0800106 //sendSyncInterest();
Zhenkai Zhu74dd53c2013-01-10 23:39:57 -0800107}
108
109void
Zhenkai Zhue851b952013-01-13 22:29:57 -0800110SyncCore::handleInterest(const Name &name)
111{
112 int size = name.size();
113 int prefixSize = m_syncPrefix.size();
114 if (size == prefixSize + 1)
115 {
116 // this is normal sync interest
117 handleSyncInterest(name);
118 }
119 else if (size == prefixSize + 2 && name.getCompAsString(m_syncPrefix.size()) == RECOVER)
120 {
121 // this is recovery interest
122 handleRecoverInterest(name);
123 }
124}
125
126void
127SyncCore::handleRecoverInterest(const Name &name)
128{
Alexander Afanasyevfc720362013-01-24 21:49:48 -0800129 _LOG_DEBUG ("[" << m_log->GetLocalName () << "] <<<<< RECOVER Interest with name " << name);
130
Zhenkai Zhue851b952013-01-13 22:29:57 -0800131 Bytes hashBytes = name.getComp(name.size() - 1);
132 // this is the hash unkonwn to the sender of the interest
133 Hash hash(head(hashBytes), hashBytes.size());
Zhenkai Zhub330aed2013-01-17 13:29:37 -0800134 if (m_log->LookupSyncLog(hash) > 0)
Zhenkai Zhue851b952013-01-13 22:29:57 -0800135 {
136 // we know the hash, should reply everything
Zhenkai Zhub330aed2013-01-17 13:29:37 -0800137 SyncStateMsgPtr msg = m_log->FindStateDifferences(*(Hash::Origin), *m_rootHash);
Alexander Afanasyev49a30d02013-01-21 21:38:48 -0800138
Alexander Afanasyev08aa70a2013-01-22 22:16:25 -0800139 BytesPtr syncData = serializeMsg (*msg);
Alexander Afanasyev49a30d02013-01-21 21:38:48 -0800140 m_ccnx->publishData(name, *syncData, FRESHNESS);
Alexander Afanasyevfcf81dc2013-01-25 20:36:58 -0800141 _LOG_TRACE ("[" << m_log->GetLocalName () << "] publishes " << hash.shortHash ());
Alexander Afanasyevfc720362013-01-24 21:49:48 -0800142 // _LOG_TRACE (msg);
Zhenkai Zhue851b952013-01-13 22:29:57 -0800143 }
Alexander Afanasyevfc720362013-01-24 21:49:48 -0800144 else
145 {
146 // we don't recognize this hash, can not help
147 }
Zhenkai Zhue851b952013-01-13 22:29:57 -0800148}
149
150void
Zhenkai Zhu74dd53c2013-01-10 23:39:57 -0800151SyncCore::handleSyncInterest(const Name &name)
152{
Alexander Afanasyevfc720362013-01-24 21:49:48 -0800153 _LOG_DEBUG ("[" << m_log->GetLocalName () << "] <<<<< SYNC Interest with name " << name);
154
Zhenkai Zhue851b952013-01-13 22:29:57 -0800155 Bytes hashBytes = name.getComp(name.size() - 1);
156 HashPtr hash(new Hash(head(hashBytes), hashBytes.size()));
157 if (*hash == *m_rootHash)
158 {
159 // we have the same hash; nothing needs to be done
Alexander Afanasyevfcf81dc2013-01-25 20:36:58 -0800160 _LOG_TRACE ("same as root hash: " << hash->shortHash ());
Zhenkai Zhue851b952013-01-13 22:29:57 -0800161 return;
162 }
Zhenkai Zhub330aed2013-01-17 13:29:37 -0800163 else if (m_log->LookupSyncLog(*hash) > 0)
Zhenkai Zhue851b952013-01-13 22:29:57 -0800164 {
165 // we know something more
Alexander Afanasyev49a30d02013-01-21 21:38:48 -0800166 _LOG_TRACE ("found hash in sync log");
Zhenkai Zhub330aed2013-01-17 13:29:37 -0800167 SyncStateMsgPtr msg = m_log->FindStateDifferences(*hash, *m_rootHash);
Zhenkai Zhue851b952013-01-13 22:29:57 -0800168
Alexander Afanasyev08aa70a2013-01-22 22:16:25 -0800169 BytesPtr syncData = serializeMsg (*msg);
Alexander Afanasyev49a30d02013-01-21 21:38:48 -0800170 m_ccnx->publishData(name, *syncData, FRESHNESS);
Alexander Afanasyevfcf81dc2013-01-25 20:36:58 -0800171 _LOG_TRACE (m_log->GetLocalName () << " publishes: " << hash->shortHash ());
Alexander Afanasyev49a30d02013-01-21 21:38:48 -0800172 _LOG_TRACE (msg);
Zhenkai Zhue851b952013-01-13 22:29:57 -0800173 }
174 else
175 {
176 // we don't recognize the hash, send recover Interest if still don't know the hash after a randomized wait period
Zhenkai Zhue573ae82013-01-15 13:15:52 -0800177 double wait = m_recoverWaitGenerator->nextInterval();
Alexander Afanasyevfcf81dc2013-01-25 20:36:58 -0800178 _LOG_TRACE (m_log->GetLocalName () << ", rootHash: " << *m_rootHash << ", hash: " << hash->shortHash ());
Alexander Afanasyev49a30d02013-01-21 21:38:48 -0800179 _LOG_TRACE ("recover task scheduled after wait: " << wait);
Zhenkai Zhue573ae82013-01-15 13:15:52 -0800180
Alexander Afanasyevc507ac22013-01-21 16:01:58 -0800181 Scheduler::scheduleOneTimeTask (m_scheduler,
182 wait, boost::bind(&SyncCore::recover, this, hash),
183 "r-"+lexical_cast<string> (*hash));
Zhenkai Zhue851b952013-01-13 22:29:57 -0800184 }
Zhenkai Zhu74dd53c2013-01-10 23:39:57 -0800185}
186
187Closure::TimeoutCallbackReturnValue
188SyncCore::handleSyncInterestTimeout(const Name &name)
189{
Zhenkai Zhu3b406592013-01-25 21:07:49 -0800190 // sync interest will be resent by scheduler
Zhenkai Zhue851b952013-01-13 22:29:57 -0800191 return Closure::RESULT_OK;
192}
193
194Closure::TimeoutCallbackReturnValue
195SyncCore::handleRecoverInterestTimeout(const Name &name)
196{
197 // We do not re-express recovery interest for now
198 // if difference is not resolved, the sync interest will trigger
199 // recovery anyway; so it's not so important to have recovery interest
200 // re-expressed
201 return Closure::RESULT_OK;
202}
203
204void
Alexander Afanasyevf278db32013-01-21 14:41:01 -0800205SyncCore::handleRecoverData(const Name &name, PcoPtr content)
Zhenkai Zhue851b952013-01-13 22:29:57 -0800206{
Alexander Afanasyevfc720362013-01-24 21:49:48 -0800207 _LOG_DEBUG ("[" << m_log->GetLocalName () << "] <<<<< RECOVER DATA with name: " << name);
Alexander Afanasyevc507ac22013-01-21 16:01:58 -0800208 //cout << "handle recover data" << end;
Alexander Afanasyev30ef9222013-01-26 10:41:38 -0800209 if (content && content->contentPtr () && content->contentPtr ()->size () > 0)
210 {
211 handleStateData(*content->contentPtr ());
212 }
213 else
214 {
215 _LOG_ERROR ("Got recovery DATA with empty content");
216 }
Zhenkai Zhu6e7d4d22013-01-15 18:18:18 -0800217 sendSyncInterest();
Zhenkai Zhu74dd53c2013-01-10 23:39:57 -0800218}
219
220void
Alexander Afanasyevf278db32013-01-21 14:41:01 -0800221SyncCore::handleSyncData(const Name &name, PcoPtr content)
Zhenkai Zhu74dd53c2013-01-10 23:39:57 -0800222{
Alexander Afanasyevfc720362013-01-24 21:49:48 -0800223 _LOG_DEBUG ("[" << m_log->GetLocalName () << "] <<<<< SYNC DATA with name: " << name);
224
Zhenkai Zhue851b952013-01-13 22:29:57 -0800225 // suppress recover in interest - data out of order case
Alexander Afanasyev30ef9222013-01-26 10:41:38 -0800226 if (content && content->contentPtr () && content->contentPtr ()->size () > 0)
227 {
228 handleStateData(*content->contentPtr ());
229 }
230 else
231 {
232 _LOG_ERROR ("Got sync DATA with empty content");
233 }
Zhenkai Zhue851b952013-01-13 22:29:57 -0800234
235 // resume outstanding sync interest
236 sendSyncInterest();
237}
238
239void
240SyncCore::handleStateData(const Bytes &content)
241{
Zhenkai Zhu74dd53c2013-01-10 23:39:57 -0800242 SyncStateMsgPtr msg(new SyncStateMsg);
243 bool success = msg->ParseFromArray(head(content), content.size());
244 if(!success)
245 {
246 // ignore misformed SyncData
Alexander Afanasyevc507ac22013-01-21 16:01:58 -0800247 _LOG_ERROR ("Misformed SyncData");
Zhenkai Zhu74dd53c2013-01-10 23:39:57 -0800248 return;
249 }
250
Alexander Afanasyev49a30d02013-01-21 21:38:48 -0800251 _LOG_TRACE (m_log->GetLocalName () << " receives Msg ");
252 _LOG_TRACE (msg);
Zhenkai Zhu74dd53c2013-01-10 23:39:57 -0800253 int size = msg->state_size();
254 int index = 0;
255 while (index < size)
256 {
257 SyncState state = msg->state(index);
Zhenkai Zhue851b952013-01-13 22:29:57 -0800258 string devStr = state.name();
259 Name deviceName((const unsigned char *)devStr.c_str(), devStr.size());
Zhenkai Zhu6e7d4d22013-01-15 18:18:18 -0800260 // cout << "Got Name: " << deviceName;
Zhenkai Zhue851b952013-01-13 22:29:57 -0800261 if (state.type() == SyncState::UPDATE)
262 {
263 sqlite3_int64 seqno = state.seq();
Zhenkai Zhu6e7d4d22013-01-15 18:18:18 -0800264 // cout << ", Got seq: " << seqno << endl;
Zhenkai Zhub330aed2013-01-17 13:29:37 -0800265 m_log->UpdateDeviceSeqNo(deviceName, seqno);
Zhenkai Zhue851b952013-01-13 22:29:57 -0800266 if (state.has_locator())
267 {
268 string locStr = state.locator();
269 Name locatorName((const unsigned char *)locStr.c_str(), locStr.size());
Zhenkai Zhu6e7d4d22013-01-15 18:18:18 -0800270 // cout << ", Got loc: " << locatorName << endl;
Zhenkai Zhub330aed2013-01-17 13:29:37 -0800271 m_log->UpdateLocator(deviceName, locatorName);
Alexander Afanasyev49a30d02013-01-21 21:38:48 -0800272
273 _LOG_TRACE ("self: " << m_log->GetLocalName () << ", device: " << deviceName << " < == > " << locatorName);
Zhenkai Zhue851b952013-01-13 22:29:57 -0800274 }
275 }
276 else
277 {
Alexander Afanasyev49a30d02013-01-21 21:38:48 -0800278 _LOG_ERROR ("Receive SYNC DELETE, but we don't support it yet");
Zhenkai Zhue851b952013-01-13 22:29:57 -0800279 deregister(deviceName);
280 }
Zhenkai Zhu74dd53c2013-01-10 23:39:57 -0800281 index++;
282 }
283
Zhenkai Zhue851b952013-01-13 22:29:57 -0800284 // find the actuall difference and invoke callback on the actual difference
285 HashPtr oldHash = m_rootHash;
Zhenkai Zhub330aed2013-01-17 13:29:37 -0800286 m_rootHash = m_log->RememberStateInStateLog();
Zhenkai Zhu085aae72013-01-17 21:09:01 -0800287 // get diff with both new SeqNo and old SeqNo
288 SyncStateMsgPtr diff = m_log->FindStateDifferences(*oldHash, *m_rootHash, true);
Zhenkai Zhu6e7d4d22013-01-15 18:18:18 -0800289
Zhenkai Zhu9501b8b2013-01-17 12:37:00 -0800290 if (diff->state_size() > 0)
291 {
Alexander Afanasyevfc720362013-01-24 21:49:48 -0800292 m_stateMsgCallback (diff);
Zhenkai Zhu9501b8b2013-01-17 12:37:00 -0800293 }
Zhenkai Zhu74dd53c2013-01-10 23:39:57 -0800294}
295
296void
297SyncCore::sendSyncInterest()
298{
Alexander Afanasyev49a30d02013-01-21 21:38:48 -0800299 Name syncInterest = Name (m_syncPrefix)(m_rootHash->GetHash(), m_rootHash->GetHashBytes());
300
Alexander Afanasyevfcf81dc2013-01-25 20:36:58 -0800301 _LOG_DEBUG ("[" << m_log->GetLocalName () << "] >>> SYNC Interest for " << m_rootHash->shortHash () << ": " << syncInterest);
Alexander Afanasyevfc720362013-01-24 21:49:48 -0800302
Zhenkai Zhu95160102013-01-25 21:54:57 -0800303 Selectors selectors;
304 if (m_syncInterestInterval > 0 && m_syncInterestInterval < 30.0)
305 {
306 selectors.interestLifetime(m_syncInterestInterval);
307 }
Alexander Afanasyev49a30d02013-01-21 21:38:48 -0800308 m_ccnx->sendInterest(syncInterest,
309 Closure (boost::bind(&SyncCore::handleSyncData, this, _1, _2),
Zhenkai Zhu95160102013-01-25 21:54:57 -0800310 boost::bind(&SyncCore::handleSyncInterestTimeout, this, _1)),
311 selectors);
Zhenkai Zhu3b406592013-01-25 21:07:49 -0800312
Zhenkai Zhu95160102013-01-25 21:54:57 -0800313 // if there is a pending syncSyncInterest task, reschedule it to be m_syncInterestInterval seconds from now
Zhenkai Zhu3b406592013-01-25 21:07:49 -0800314 // if no such task exists, it will be added
Zhenkai Zhu3b406592013-01-25 21:07:49 -0800315 m_scheduler->rescheduleTask(m_sendSyncInterestTask);
Zhenkai Zhue851b952013-01-13 22:29:57 -0800316}
317
318void
319SyncCore::recover(const HashPtr &hash)
320{
Zhenkai Zhub330aed2013-01-17 13:29:37 -0800321 if (!(*hash == *m_rootHash) && m_log->LookupSyncLog(*hash) <= 0)
Zhenkai Zhue851b952013-01-13 22:29:57 -0800322 {
Alexander Afanasyevfcf81dc2013-01-25 20:36:58 -0800323 _LOG_TRACE (m_log->GetLocalName () << ", Recover for: " << hash->shortHash ());
Zhenkai Zhue851b952013-01-13 22:29:57 -0800324 // unfortunately we still don't recognize this hash
325 Bytes bytes;
326 readRaw(bytes, (const unsigned char *)hash->GetHash(), hash->GetHashBytes());
Alexander Afanasyev49a30d02013-01-21 21:38:48 -0800327
Zhenkai Zhue851b952013-01-13 22:29:57 -0800328 // append the unknown hash
Alexander Afanasyev49a30d02013-01-21 21:38:48 -0800329 Name recoverInterest = Name (m_syncPrefix)(RECOVER)(bytes);
330
Alexander Afanasyevfcf81dc2013-01-25 20:36:58 -0800331 _LOG_DEBUG ("[" << m_log->GetLocalName () << "] >>> RECOVER Interests for " << hash->shortHash ());
Alexander Afanasyevfc720362013-01-24 21:49:48 -0800332
Alexander Afanasyev49a30d02013-01-21 21:38:48 -0800333 m_ccnx->sendInterest(recoverInterest,
334 Closure (boost::bind(&SyncCore::handleRecoverData, this, _1, _2),
335 boost::bind(&SyncCore::handleRecoverInterestTimeout, this, _1)));
336
Zhenkai Zhue851b952013-01-13 22:29:57 -0800337 }
338 else
339 {
340 // we already learned the hash; cheers!
341 }
342}
343
344void
345SyncCore::deregister(const Name &name)
346{
347 // Do nothing for now
348 // TODO: handle deregistering
Zhenkai Zhu74dd53c2013-01-10 23:39:57 -0800349}
350
Zhenkai Zhu9501b8b2013-01-17 12:37:00 -0800351sqlite3_int64
352SyncCore::seq(const Name &name)
353{
Zhenkai Zhub330aed2013-01-17 13:29:37 -0800354 return m_log->SeqNo(name);
Zhenkai Zhu9501b8b2013-01-17 12:37:00 -0800355}