blob: c6c0c24bdab759cf8ce44319dead12945a60c01b [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 Afanasyevf278db32013-01-21 14:41:01 -0800209 handleStateData(*content->contentPtr ());
Zhenkai Zhu6e7d4d22013-01-15 18:18:18 -0800210 sendSyncInterest();
Zhenkai Zhu74dd53c2013-01-10 23:39:57 -0800211}
212
213void
Alexander Afanasyevf278db32013-01-21 14:41:01 -0800214SyncCore::handleSyncData(const Name &name, PcoPtr content)
Zhenkai Zhu74dd53c2013-01-10 23:39:57 -0800215{
Alexander Afanasyevfc720362013-01-24 21:49:48 -0800216 _LOG_DEBUG ("[" << m_log->GetLocalName () << "] <<<<< SYNC DATA with name: " << name);
217
Zhenkai Zhue851b952013-01-13 22:29:57 -0800218 // suppress recover in interest - data out of order case
Alexander Afanasyevf278db32013-01-21 14:41:01 -0800219 handleStateData(*content->contentPtr ());
Zhenkai Zhue851b952013-01-13 22:29:57 -0800220
221 // resume outstanding sync interest
222 sendSyncInterest();
223}
224
225void
226SyncCore::handleStateData(const Bytes &content)
227{
Zhenkai Zhu74dd53c2013-01-10 23:39:57 -0800228 SyncStateMsgPtr msg(new SyncStateMsg);
229 bool success = msg->ParseFromArray(head(content), content.size());
230 if(!success)
231 {
232 // ignore misformed SyncData
Alexander Afanasyevc507ac22013-01-21 16:01:58 -0800233 _LOG_ERROR ("Misformed SyncData");
Zhenkai Zhu74dd53c2013-01-10 23:39:57 -0800234 return;
235 }
236
Alexander Afanasyev49a30d02013-01-21 21:38:48 -0800237 _LOG_TRACE (m_log->GetLocalName () << " receives Msg ");
238 _LOG_TRACE (msg);
Zhenkai Zhu74dd53c2013-01-10 23:39:57 -0800239 int size = msg->state_size();
240 int index = 0;
241 while (index < size)
242 {
243 SyncState state = msg->state(index);
Zhenkai Zhue851b952013-01-13 22:29:57 -0800244 string devStr = state.name();
245 Name deviceName((const unsigned char *)devStr.c_str(), devStr.size());
Zhenkai Zhu6e7d4d22013-01-15 18:18:18 -0800246 // cout << "Got Name: " << deviceName;
Zhenkai Zhue851b952013-01-13 22:29:57 -0800247 if (state.type() == SyncState::UPDATE)
248 {
249 sqlite3_int64 seqno = state.seq();
Zhenkai Zhu6e7d4d22013-01-15 18:18:18 -0800250 // cout << ", Got seq: " << seqno << endl;
Zhenkai Zhub330aed2013-01-17 13:29:37 -0800251 m_log->UpdateDeviceSeqNo(deviceName, seqno);
Zhenkai Zhue851b952013-01-13 22:29:57 -0800252 if (state.has_locator())
253 {
254 string locStr = state.locator();
255 Name locatorName((const unsigned char *)locStr.c_str(), locStr.size());
Zhenkai Zhu6e7d4d22013-01-15 18:18:18 -0800256 // cout << ", Got loc: " << locatorName << endl;
Zhenkai Zhub330aed2013-01-17 13:29:37 -0800257 m_log->UpdateLocator(deviceName, locatorName);
Alexander Afanasyev49a30d02013-01-21 21:38:48 -0800258
259 _LOG_TRACE ("self: " << m_log->GetLocalName () << ", device: " << deviceName << " < == > " << locatorName);
Zhenkai Zhue851b952013-01-13 22:29:57 -0800260 }
261 }
262 else
263 {
Alexander Afanasyev49a30d02013-01-21 21:38:48 -0800264 _LOG_ERROR ("Receive SYNC DELETE, but we don't support it yet");
Zhenkai Zhue851b952013-01-13 22:29:57 -0800265 deregister(deviceName);
266 }
Zhenkai Zhu74dd53c2013-01-10 23:39:57 -0800267 index++;
268 }
269
Zhenkai Zhue851b952013-01-13 22:29:57 -0800270 // find the actuall difference and invoke callback on the actual difference
271 HashPtr oldHash = m_rootHash;
Zhenkai Zhub330aed2013-01-17 13:29:37 -0800272 m_rootHash = m_log->RememberStateInStateLog();
Zhenkai Zhu085aae72013-01-17 21:09:01 -0800273 // get diff with both new SeqNo and old SeqNo
274 SyncStateMsgPtr diff = m_log->FindStateDifferences(*oldHash, *m_rootHash, true);
Zhenkai Zhu6e7d4d22013-01-15 18:18:18 -0800275
Zhenkai Zhu9501b8b2013-01-17 12:37:00 -0800276 if (diff->state_size() > 0)
277 {
Alexander Afanasyevfc720362013-01-24 21:49:48 -0800278 m_stateMsgCallback (diff);
Zhenkai Zhu9501b8b2013-01-17 12:37:00 -0800279 }
Zhenkai Zhu74dd53c2013-01-10 23:39:57 -0800280}
281
282void
283SyncCore::sendSyncInterest()
284{
Alexander Afanasyev49a30d02013-01-21 21:38:48 -0800285 Name syncInterest = Name (m_syncPrefix)(m_rootHash->GetHash(), m_rootHash->GetHashBytes());
286
Alexander Afanasyevfcf81dc2013-01-25 20:36:58 -0800287 _LOG_DEBUG ("[" << m_log->GetLocalName () << "] >>> SYNC Interest for " << m_rootHash->shortHash () << ": " << syncInterest);
Alexander Afanasyevfc720362013-01-24 21:49:48 -0800288
Zhenkai Zhu95160102013-01-25 21:54:57 -0800289 Selectors selectors;
290 if (m_syncInterestInterval > 0 && m_syncInterestInterval < 30.0)
291 {
292 selectors.interestLifetime(m_syncInterestInterval);
293 }
Alexander Afanasyev49a30d02013-01-21 21:38:48 -0800294 m_ccnx->sendInterest(syncInterest,
295 Closure (boost::bind(&SyncCore::handleSyncData, this, _1, _2),
Zhenkai Zhu95160102013-01-25 21:54:57 -0800296 boost::bind(&SyncCore::handleSyncInterestTimeout, this, _1)),
297 selectors);
Zhenkai Zhu3b406592013-01-25 21:07:49 -0800298
Zhenkai Zhu95160102013-01-25 21:54:57 -0800299 // if there is a pending syncSyncInterest task, reschedule it to be m_syncInterestInterval seconds from now
Zhenkai Zhu3b406592013-01-25 21:07:49 -0800300 // if no such task exists, it will be added
Zhenkai Zhu3b406592013-01-25 21:07:49 -0800301 m_scheduler->rescheduleTask(m_sendSyncInterestTask);
Zhenkai Zhue851b952013-01-13 22:29:57 -0800302}
303
304void
305SyncCore::recover(const HashPtr &hash)
306{
Zhenkai Zhub330aed2013-01-17 13:29:37 -0800307 if (!(*hash == *m_rootHash) && m_log->LookupSyncLog(*hash) <= 0)
Zhenkai Zhue851b952013-01-13 22:29:57 -0800308 {
Alexander Afanasyevfcf81dc2013-01-25 20:36:58 -0800309 _LOG_TRACE (m_log->GetLocalName () << ", Recover for: " << hash->shortHash ());
Zhenkai Zhue851b952013-01-13 22:29:57 -0800310 // unfortunately we still don't recognize this hash
311 Bytes bytes;
312 readRaw(bytes, (const unsigned char *)hash->GetHash(), hash->GetHashBytes());
Alexander Afanasyev49a30d02013-01-21 21:38:48 -0800313
Zhenkai Zhue851b952013-01-13 22:29:57 -0800314 // append the unknown hash
Alexander Afanasyev49a30d02013-01-21 21:38:48 -0800315 Name recoverInterest = Name (m_syncPrefix)(RECOVER)(bytes);
316
Alexander Afanasyevfcf81dc2013-01-25 20:36:58 -0800317 _LOG_DEBUG ("[" << m_log->GetLocalName () << "] >>> RECOVER Interests for " << hash->shortHash ());
Alexander Afanasyevfc720362013-01-24 21:49:48 -0800318
Alexander Afanasyev49a30d02013-01-21 21:38:48 -0800319 m_ccnx->sendInterest(recoverInterest,
320 Closure (boost::bind(&SyncCore::handleRecoverData, this, _1, _2),
321 boost::bind(&SyncCore::handleRecoverInterestTimeout, this, _1)));
322
Zhenkai Zhue851b952013-01-13 22:29:57 -0800323 }
324 else
325 {
326 // we already learned the hash; cheers!
327 }
328}
329
330void
331SyncCore::deregister(const Name &name)
332{
333 // Do nothing for now
334 // TODO: handle deregistering
Zhenkai Zhu74dd53c2013-01-10 23:39:57 -0800335}
336
Zhenkai Zhu9501b8b2013-01-17 12:37:00 -0800337sqlite3_int64
338SyncCore::seq(const Name &name)
339{
Zhenkai Zhub330aed2013-01-17 13:29:37 -0800340 return m_log->SeqNo(name);
Zhenkai Zhu9501b8b2013-01-17 12:37:00 -0800341}