예제 #1
0
bool Context::InitializeNymbox()
{
    Lock lock(lock_);
    const auto& ownerNymID = client_nym_id(lock);
    auto nymbox{
        api_.Factory().Ledger(ownerNymID, server_nym_id(lock), server_id_)};

    if (false == bool(nymbox)) {
        otErr << OT_METHOD << __FUNCTION__
              << ": Unable to instantiate nymbox for " << ownerNymID.str()
              << std::endl;

        return false;
    }

    const auto generated = nymbox->GenerateLedger(
        ownerNymID, server_id_, ledgerType::nymbox, true);

    if (false == generated) {
        otErr << OT_METHOD << __FUNCTION__ << ": Unable to generate nymbox for "
              << ownerNymID.str() << std::endl;

        return false;
    }

    nymbox->ReleaseSignatures();

    OT_ASSERT(nym_)

    if (false == nymbox->SignContract(*nym_)) {
        otErr << OT_METHOD << __FUNCTION__ << ": Unable to sign nymbox for "
              << ownerNymID.str() << std::endl;

        return false;
    }

    if (false == nymbox->SaveContract()) {
        otErr << OT_METHOD << __FUNCTION__
              << ": Unable to serialize nymbox for " << ownerNymID.str()
              << std::endl;

        return false;
    }

    if (false == nymbox->SaveNymbox(local_nymbox_hash_)) {
        otErr << OT_METHOD << __FUNCTION__ << ": Unable to save nymbox for "
              << ownerNymID.str() << std::endl;

        return false;
    }

    return true;
}
예제 #2
0
bool OTCron::SaveCron()
{
	const char * szFoldername	= OTFolders::Cron().Get();
	const char * szFilename		= "OT-CRON.crn"; // todo stop hardcoding filenames.
	
	OT_ASSERT(NULL != GetServerNym());
	
	
	ReleaseSignatures();

	// Sign it, save it internally to string, and then save that out to the file.
	if (!SignContract(*m_pServerNym) || !SaveContract() || !SaveContract(szFoldername, szFilename))
	{
		OTLog::vError("Error saving main Cronfile:\n%s%s%s\n", szFoldername,
					  OTLog::PathSeparator(), szFilename);
		return false;
	}
	else
		return true;	
}