void WalletSerializer::loadCurrentVersion(Common::IInputStream& source, const std::string& password) { CryptoNote::CryptoContext cryptoContext; bool details = false; bool cache = false; loadIv(source, cryptoContext.iv); generateKey(password, cryptoContext.key); loadKeys(source, cryptoContext); checkKeys(); loadWallets(source, cryptoContext); subscribeWallets(); loadFlags(details, cache, source, cryptoContext); if (details) { loadTransactions(source, cryptoContext); loadTransfers(source, cryptoContext); } if (cache) { loadBalances(source, cryptoContext); loadTransfersSynchronizer(source, cryptoContext); loadSpentOutputs(source, cryptoContext); loadUnlockTransactionsJobs(source, cryptoContext); loadChange(source, cryptoContext); } if (details && cache) { updateTransactionsBaseStatus(); } }
void WalletSerializerV1::loadWallet(Common::IInputStream& source, const Crypto::chacha8_key& key, uint32_t version) { CryptoContext cryptoContext; bool details = false; bool cache = false; loadIv(source, cryptoContext.iv); cryptoContext.key = key; loadKeys(source, cryptoContext); checkKeys(); loadWallets(source, cryptoContext); subscribeWallets(); loadFlags(details, cache, source, cryptoContext); if (details) { loadTransactions(source, cryptoContext); loadTransfers(source, cryptoContext, version); } if (version < 5) { updateTransfersSign(); cache = false; } if (cache) { loadBalances(source, cryptoContext); loadTransfersSynchronizer(source, cryptoContext); if (version < 5) { loadObsoleteSpentOutputs(source, cryptoContext); } loadUnlockTransactionsJobs(source, cryptoContext); if (version < 5) { loadObsoleteChange(source, cryptoContext); } if (version > 3) { loadUncommitedTransactions(source, cryptoContext); } } else { resetCachedBalance(); } if (details && cache) { updateTransactionsBaseStatus(); } }
// operand count((operand0 flags, operand0 operator index, operand0 result index)...(operand0 flags, [operandN operator index, operandN result index|operandN constant value])) // alternate operand specification: // (operand0 flags, constant count(constant0 value,...,constantN value)) bool ATKIOperator::load(Stream *program) { if (!loadProperties(program)) { program->flush(); return false; } char buffer[21]; memset(buffer, 0, 21); int index = 0; bool valid = false; while(Antikythera::readProgram(program)) { char c = (char)program->read(); program->print(c); if (c == '(') { valid = true; break; } if (index == 3) { #ifdef ANTIKYTHERA_DEBUG m_lastErrorString = m_name + "::load() - operand count has too many digits."; #endif program->flush(); return false; } if (!isdigit(c)) { #ifdef ANTIKYTHERA_DEBUG m_lastErrorString = m_name + "::load() - operand count contains invalid character: " + String(c); #endif program->flush(); return false; } buffer[index++] = c; } if (!valid) { #ifdef ANTIKYTHERA_DEBUG m_lastErrorString = m_name + "::load() - unexpected end of stream while reading operand count."; #endif program->flush(); return false; } initializeOperands((uint8_t)strtoul(buffer, NULL, 10)); #ifdef ANTIKYTHERA_DEBUG program->print("[num operands:"); program->print(buffer); program->println("]"); #endif for (int count = 0; count < m_numOperands; count++) { valid = false; while(Antikythera::readProgram(program)) { char c = (char)program->read(); program->print(c); if (c == '(') { valid = true; break; } #ifdef ANTIKYTHERA_DEBUG m_lastErrorString = m_name + "::load() - operand[" + String(count) + "] expected opening parenthesis, read invalid character: " + String(c); #endif program->flush(); return false; } if (!valid) { #ifdef ANTIKYTHERA_DEBUG m_lastErrorString = m_name + "::load() - operand[" + String(count) + "] unexpected end of stream while reading opening parenthesis."; #endif program->flush(); return false; } if (!loadFlags(program, &m_operands[count].flags)) { return false; } if (m_operands[count].flags & OPERANDFLAG_LINK) { if (!loadOperatorIndex(program, &m_operands[count].operatorIndex)) { return false; } if (!loadResultIndex(program, &m_operands[count].resultIndex)) { return false; } } else { if (!loadConstant(program, count, m_operands[count].flags)) { return false; } valid = false; while(Antikythera::readProgram(program)) { char c = (char)program->read(); program->print(c); if (c == ')') { valid = true; break; } #ifdef ANTIKYTHERA_DEBUG m_lastErrorString = m_name + "::load() - expected closing parenthesis, read invalid character: " + String(c); #endif program->flush(); return false; } if (!valid) { #ifdef ANTIKYTHERA_DEBUG m_lastErrorString = m_name + "::load() - unexpected end of stream while reading closing parenthesis."; #endif program->flush(); return false; } } } valid = false; while(Antikythera::readProgram(program)) { char c = (char)program->read(); program->print(c); if (c == ')') { valid = true; break; } #ifdef ANTIKYTHERA_DEBUG m_lastErrorString = m_name + "::load() - expected closing parenthesis, read invalid character: " + String(c); #endif program->flush(); return false; } if (!valid) { #ifdef ANTIKYTHERA_DEBUG m_lastErrorString = m_name + "::load() - unexpected end of stream while reading closing parenthesis."; #endif program->flush(); return false; } // connect root to leaf nodes return true; }
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)); } }