bool OTSocket_ZMQ_2::HandleReceivingError() { bool bRetVal = false; switch (errno) { // Non-blocking mode was requested and no messages are available at the moment. case EAGAIN: OTLog::vOutput(0, "OTSocket::HandleReceivingError: Non-blocking mode was requested and no messages are available at the moment. Re-trying...\n"); bRetVal = true; break; // The zmq_recv() operation is not supported by this socket type. case ENOTSUP: OTLog::Error("OTSocket::HandleReceivingError: Failure: The zmq_recv() operation is not supported by this socket type.\n"); break; // The zmq_recv() operation cannot be performed on this socket at the moment due to the socket not being in the appropriate state. This error may occur with socket types that switch between several states, such as ZMQ_REP. See the messaging patterns section of zmq_socket(3) for more information. case EFSM: OTLog::vOutput(0, "OTSocket::HandleReceivingError: The zmq_recv() operation cannot be performed on this socket at the moment due to the socket not being in the appropriate state. (Deleting socket and re-trying...)\n"); this->RemakeSocket(); { OTASCIIArmor ascTemp(m_ascLastMsgSent); bRetVal = this->Send(ascTemp); } break; // The ØMQ context associated with the specified socket was terminated. case ETERM: OTLog::Error("OTSocket::HandleReceivingError: The ØMQ context associated with the specified socket was terminated. (Re-creating the context, and trying again...)\n"); this->RemakeSocket(true); { OTASCIIArmor ascTemp(m_ascLastMsgSent); bRetVal = this->Send(ascTemp); } break; // The provided socket was invalid. case ENOTSOCK: OTLog::Error("OTSocket::HandleReceivingError: The provided socket was invalid. (Deleting socket and re-trying.)\n"); this->RemakeSocket(); { OTASCIIArmor ascTemp(m_ascLastMsgSent); bRetVal = this->Send(ascTemp); } break; // The operation was interrupted by delivery of a signal before a message was available. case EINTR: OTLog::Error("OTSocket::HandleSendingError: The operation was interrupted by delivery of a signal before the message was sent. (Re-trying...)\n"); bRetVal = true; break; // The message passed to the function was invalid. case EFAULT: OTLog::Error("OTSocket::HandleReceivingError: Failure: The message passed to the function was invalid.\n"); break; default: OTLog::Error("OTSocket::HandleReceivingError: Default case. Re-trying...\n"); bRetVal = true; break; } return bRetVal; }
// Setup the default location for the Sever Main File... // maybe this should be set differently... // should be set in the servers configuration. // bool MainFile::SaveMainFile() { // Get the loaded (or new) version of the Server's Main File. // String strMainFile; if (!SaveMainFileToString(strMainFile)) { Log::vError( "%s: Error saving to string. (Giving up on save attempt.)\n", __FUNCTION__); return false; } // Try to save the notary server's main datafile to local storage... // String strFinal; OTASCIIArmor ascTemp(strMainFile); if (false == ascTemp.WriteArmoredString(strFinal, "NOTARY")) // todo hardcoding. { Log::vError("%s: Error saving notary (failed writing armored string)\n", __FUNCTION__); return false; } // Save the Main File to the Harddrive... (or DB, if other storage module is // being used). // const bool bSaved = OTDB::StorePlainString( strFinal.Get(), ".", server_->m_strWalletFilename.Get()); if (!bSaved) { Log::vError("%s: Error saving main file: %s\n", __FUNCTION__, server_->m_strWalletFilename.Get()); } return bSaved; }
bool OTMint::SaveMint(const char * szAppend/*=NULL*/) { if (!m_strFoldername.Exists()) m_strFoldername.Set(OTFolders::Mint().Get()); const OTString strServerID(m_ServerID), strAssetTypeID(m_AssetID); if (!m_strFilename.Exists()) { if (NULL != szAppend) m_strFilename.Format("%s%s%s%s", strServerID.Get(), OTLog::PathSeparator(), // server side strAssetTypeID.Get(), szAppend); else m_strFilename.Format("%s%s%s", strServerID.Get(), OTLog::PathSeparator(), strAssetTypeID.Get()); // client side } OTString strFilename; if (NULL != szAppend) strFilename.Format("%s%s", strAssetTypeID.Get(), szAppend); else strFilename = strAssetTypeID.Get(); const char * szFolder1name = OTFolders::Mint().Get(); const char * szFolder2name = strServerID.Get(); const char * szFilename = strFilename.Get(); // -------------------------------------------------------------------- OTString strRawFile; if (!SaveContractRaw(strRawFile)) { OTLog::vError("OTMint::SaveMint: Error saving Mintfile (to string):\n%s%s%s%s%s\n", szFolder1name, OTLog::PathSeparator(), szFolder2name, OTLog::PathSeparator(), szFilename); return false; } // -------------------------------------------------------------------- OTString strFinal; OTASCIIArmor ascTemp(strRawFile); if (false == ascTemp.WriteArmoredString(strFinal, m_strContractType.Get())) { OTLog::vError("OTMint::SaveMint: Error saving mint (failed writing armored string):\n%s%s%s%s%s\n", szFolder1name, OTLog::PathSeparator(), szFolder2name, OTLog::PathSeparator(), szFilename); return false; } // -------------------------------------------------------------------- bool bSaved = OTDB::StorePlainString(strFinal.Get(), szFolder1name, szFolder2name, szFilename); // <=== SAVING TO LOCAL DATA STORE. if (!bSaved) { if (NULL != szAppend) OTLog::vError("OTMint::SaveMint: Error writing to file: %s%s%s%s%s%s\n", szFolder1name, OTLog::PathSeparator(), szFolder2name, OTLog::PathSeparator(), szFilename, szAppend); else OTLog::vError("OTMint::SaveMint: Error writing to file: %s%s%s%s%s\n", szFolder1name, OTLog::PathSeparator(), szFolder2name, OTLog::PathSeparator(), szFilename); return false; } // -------------------------------------------------------------------- return true; }