예제 #1
0
void WalletSerializer::save(const std::string& password, Common::IOutputStream& destination, bool saveDetails, bool saveCache) {
  CryptoContext cryptoContext = generateCryptoContext(password);

  CryptoNote::BinaryOutputStreamSerializer s(destination);
  s.beginObject("wallet");

  saveVersion(destination);
  saveIv(destination, cryptoContext.iv);

  saveKeys(destination, cryptoContext);
  saveWallets(destination, saveCache, cryptoContext);
  saveFlags(saveDetails, saveCache, destination, cryptoContext);

  if (saveDetails) {
    saveTransactions(destination, cryptoContext);
    saveTransfers(destination, cryptoContext);
  }

  if (saveCache) {
    saveBalances(destination, saveCache, cryptoContext);
    saveTransfersSynchronizer(destination, cryptoContext);
    saveSpentOutputs(destination, cryptoContext);
    saveUnlockTransactionsJobs(destination, cryptoContext);
    saveChange(destination, cryptoContext);
  }

  s.endObject();
}
예제 #2
0
void external_function::serialize(::zorba::serialization::Archiver& ar)
{
  zorba::serialization::serialize_baseclass(ar, (function*)this);

  ar & theNamespace;
  ar & theScriptingKind;

  // also serialize the localname of the function
  zstring lLocalName;
  if (ar.is_serializing_out()) 
  {
    computeCacheSettings(NULL);
    ZORBA_ASSERT(theImpl);
    lLocalName = Unmarshaller::getInternalString(theImpl->getLocalName());
  }
  ar.set_is_temp_field(true);
  ar & lLocalName;
  ar.set_is_temp_field(false);

  // if loaded, theImpl needs to be set immediately
  // this is covered by test/unit/external_function.cpp
  if (!ar.is_serializing_out()) 
  {
    try
    {
      theImpl = theModuleSctx->lookup_external_function(theNamespace, lLocalName);
    }
    catch (XQueryException& e)
    {
      set_source( e, theLoc );
      throw;
    }

    if (theImpl == NULL)
    {
      RAISE_ERROR(zerr::ZXQP0008_FUNCTION_IMPL_NOT_FOUND, theLoc,
        ERROR_PARAMS(BUILD_STRING( '{', theNamespace, '}', lLocalName)));
    }
  }

  ar & theLoc;
  ar & theHasCache;
  ar & theCacheAcrossSnapshots;
  if (ar.is_serializing_out())
  {
    saveFlags(theExcludeFromCacheKey, ar);
    saveFlags(theCompareWithDeepEqual, ar);
  }
  else
  {
    loadFlags(theExcludeFromCacheKey, ar);
    loadFlags(theCompareWithDeepEqual, ar);
  }
  ar & theAreCacheSettingsComputed;
  ar & theIsCacheAutomatic;

  if (!ar.is_serializing_out())
  {
    theCache.reset(new FunctionCache(
      theModuleSctx,
      theExcludeFromCacheKey,
      theCompareWithDeepEqual,
      theCacheAcrossSnapshots));
  }
}