Skip to content

Commit

Permalink
Removed custom log 5 level
Browse files Browse the repository at this point in the history
  • Loading branch information
EDDragonWolf committed Feb 21, 2018
1 parent d1b0069 commit 3aca8a0
Show file tree
Hide file tree
Showing 14 changed files with 18 additions and 69 deletions.
6 changes: 3 additions & 3 deletions src/supernode/AuthSample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ bool supernode::AuthSample::PosProxySale(const rpc_command::POS_PROXY_SALE::requ

Add(data);

LOG_PRINT_L5("ADD: "<<in.PaymentID<<" in: "<<m_DAPIServer->Port());
LOG_PRINT_L4("ADD: "<<in.PaymentID<<" in: "<<m_DAPIServer->Port());

return true;
}

bool supernode::AuthSample::WalletProxyPay(const rpc_command::WALLET_PROXY_PAY::request& in, rpc_command::WALLET_PROXY_PAY::response& out) {
boost::shared_ptr<BaseRTAObject> ff = ObjectByPayment(in.PaymentID);
boost::shared_ptr<AuthSampleObject> data = boost::dynamic_pointer_cast<AuthSampleObject>(ff);
if(!data) { LOG_PRINT_L5("not found object: "<<in.PaymentID<<" in: "<<m_DAPIServer->Port()); return false; }
if(!data) { LOG_PRINT_L4("not found object: "<<in.PaymentID<<" in: "<<m_DAPIServer->Port()); return false; }

if( !data->WalletProxyPay(in, out) ) { LOG_PRINT_L5("!WalletProxyPay"); Remove(data); return false; }
if( !data->WalletProxyPay(in, out) ) { LOG_PRINT_L4("!WalletProxyPay"); Remove(data); return false; }

return true;
}
Expand Down
9 changes: 2 additions & 7 deletions src/supernode/AuthSampleObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,10 @@ bool supernode::AuthSampleObject::Init(const RTA_TransactionRecord& src) {
bool supernode::AuthSampleObject::WalletProxyPay(const rpc_command::WALLET_PROXY_PAY::request& inp, rpc_command::WALLET_PROXY_PAY::response& out) {
RTA_TransactionRecord src;
rpc_command::ConvertToTR(src, inp, m_Servant);
if(src!=TransactionRecord) { LOG_PRINT_L5("not eq records"); return false; }
if(src!=TransactionRecord) { LOG_PRINT_L4("not eq records"); return false; }

string data = TransactionRecord.PaymentID + string(":") + inp.CustomerWalletAddr;
bool signok = tools::GraftWallet::verifySignedMessage(data, inp.CustomerWalletAddr, inp.CustomerWalletSign, m_Servant->IsTestnet());
//LOG_PRINT_L5("Check sign: "<<signok<<" data: "<<data<<" sign: "<<inp.CustomerWalletSign);


//LOG_PRINT_L5("PaymentID: "<<TransactionRecord.PaymentID<<" m_ReadyForDelete: "<<m_ReadyForDelete);

// TODO: send LOCK. WTF?? all our nodes got this packet by sub-net broadcast. so only top node must send broad cast

Expand Down Expand Up @@ -87,8 +83,7 @@ bool supernode::AuthSampleObject::WalletProxyRejectPay(const rpc_command::WALLET
}

string supernode::AuthSampleObject::GenerateSignForTransaction() {
string sign = m_Servant->SignByWalletPrivateKey( TransactionRecord.MessageForSign(), m_Servant->GetMyStakeWallet().Addr );
//LOG_PRINT_L5("GenerateSignForTransaction: mes: "<<TransactionRecord.MessageForSign()<<" addr: "<<m_Servant->GetMyStakeWallet().Addr<<" sign: "<<sign)
string sign = m_Servant->SignByWalletPrivateKey( TransactionRecord.MessageForSign(), m_Servant->GetMyStakeWallet().Addr );
return sign;
}

Expand Down
3 changes: 1 addition & 2 deletions src/supernode/BaseRTAProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ boost::shared_ptr<supernode::BaseRTAObject> supernode::BaseRTAProcessor::ObjectB

void supernode::BaseRTAProcessor::Remove(boost::shared_ptr<BaseRTAObject> obj) {
obj->MarkForDelete();
LOG_PRINT_L5("Remove: "<<obj->TransactionRecord.PaymentID);
LOG_PRINT_L4("Remove: "<<obj->TransactionRecord.PaymentID);
{
boost::lock_guard<boost::recursive_mutex> lock(m_ObjectsGuard);
auto it = find(m_Objects.begin(), m_Objects.end(), obj);
Expand Down Expand Up @@ -99,7 +99,6 @@ void supernode::BaseRTAProcessor::Tick() {
boost::lock_guard<boost::recursive_mutex> lock(m_RemoveObjectsGuard);
for(int i=0;i<int(m_RemoveObjects.size());i++) if( (now-m_RemoveObjects[i]->TimeMark).total_milliseconds()>(5*60*1000) ) {
m_RemoveObjects.erase( m_RemoveObjects.begin()+i );
//LOG_PRINT_L5("---- ERASE ----");
i--;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/supernode/DAPI_RPC_Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,18 @@ namespace supernode {

WasConnected = false;
if(!invoke(rpc_command::DAPI_URI, rpc_command::DAPI_METHOD, req_param, timeout, std::addressof(pri))) {
LOG_PRINT_L5("Failed to invoke http request to " << call<<" URI: "<<m_URI);
LOG_PRINT_L4("Failed to invoke http request to " << call<<" URI: "<<m_URI);
return false;
}
WasConnected = true;

if(!pri) {
LOG_PRINT_L5("Failed to invoke http request to " << call << ", internal error (null response ptr)");
LOG_PRINT_L4("Failed to invoke http request to " << call << ", internal error (null response ptr)");
return false;
}

if(pri->m_response_code != 200) {
LOG_PRINT_L5("Failed to invoke http request to " << call << ", wrong response code: " << pri->m_response_code);
LOG_PRINT_L4("Failed to invoke http request to " << call << ", wrong response code: " << pri->m_response_code);
return false;
}

Expand Down
28 changes: 4 additions & 24 deletions src/supernode/DAPI_RPC_Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ using namespace std;
bool supernode::DAPI_RPC_Server::handle_http_request(const epee::net_utils::http::http_request_info& query_info, epee::net_utils::http::http_response_info& response, connection_context& m_conn_context) {
//LOG_PRINT_L4("HTTP [" << m_conn_context.m_remote_address.host_str() << "] " << query_info.m_http_method_str << " " << query_info.m_URI);

//LOG_PRINT_L5("Got request");

//LOG_PRINT_L5("req in "<<Port()<<" =1");

response.m_response_code = 200;
response.m_response_comment = "Ok";

Expand All @@ -51,11 +47,6 @@ bool supernode::DAPI_RPC_Server::handle_http_request(const epee::net_utils::http
response.m_response_code = 500;
response.m_response_comment = "Internal server error";
}



//LOG_PRINT_L5("req in "<<Port()<<" =2");

return true;
}

Expand All @@ -71,7 +62,7 @@ bool supernode::DAPI_RPC_Server::HandleRequest(const epee::net_utils::http::http
epee::serialization::storage_entry id_ = epee::serialization::storage_entry(std::string());

if( !ps.load_from_json(query_info.m_body) ) {
LOG_PRINT_L5("!load_from_json");
LOG_PRINT_L0("!load_from_json");
response_info.m_response_code = 500;
response_info.m_response_comment = "Parse error";
} else if( !ps.get_value("dapi_version", version, nullptr) ) {
Expand All @@ -87,7 +78,7 @@ bool supernode::DAPI_RPC_Server::HandleRequest(const epee::net_utils::http::http

if( response_info.m_response_code!=200 ) {
//epee::serialization::store_t_to_json(static_cast<epee::json_rpc::error_response&>(rsp), response_info.m_body);
LOG_PRINT_L5( "Error: "<<response_info.m_response_comment );
LOG_PRINT_L0( "Error: "<<response_info.m_response_comment );
return true;
}

Expand All @@ -104,27 +95,20 @@ bool supernode::DAPI_RPC_Server::HandleRequest(const epee::net_utils::http::http
SCallHandler* handler = nullptr;

{
//LOG_PRINT_L5("\n\n\n");

boost::lock_guard<boost::recursive_mutex> lock(m_Handlers_Guard);
for(unsigned i=0;i<m_vHandlers.size();i++) {
SHandlerData& hh = m_vHandlers[i];

//LOG_PRINT_L5("Have: '"<<hh.Name<<"' : '"<<hh.PaymentID<<"' need: '"<<callback_name<<"' : '"<<payment_id<<"'");

if(hh.Name!=callback_name) continue;
if(hh.PaymentID.size() && hh.PaymentID!=payment_id) continue;

handler = hh.Handler;
break;
}
//LOG_PRINT_L5("\n\n\n");
}

if(!handler) { LOG_PRINT_L5("handler not found for: "<<callback_name); return false; }
//LOG_PRINT_L5("Befor process: "<<callback_name<<" in: "<<Port());
if( !handler->Process(ps, response_info.m_body) ) { LOG_PRINT_L5("Fail to process (ret false): "<<callback_name); return false; }
//LOG_PRINT_L5("After process: "<<callback_name<<" in: "<<Port());
if(!handler) { LOG_PRINT_L4("handler not found for: "<<callback_name); return false; }
if( !handler->Process(ps, response_info.m_body) ) { LOG_PRINT_L4("Fail to process (ret false): "<<callback_name); return false; }

response_info.m_mime_tipe = "application/json";
response_info.m_header_info.m_content_type = " application/json";
Expand All @@ -140,10 +124,6 @@ void supernode::DAPI_RPC_Server::Set(const string& ip, const string& port, int n
m_IP = ip;
init(port, ip);
m_NumThreads = numThreads;

//m_net_server.acceptor_.max_connections
//LOG_PRINT_L5("MAX_CON: "<<boost::asio::ip::tcp::acceptor::max_connections);

}

void supernode::DAPI_RPC_Server::Start() { run(m_NumThreads); }
Expand Down
6 changes: 0 additions & 6 deletions src/supernode/FSN_ActualList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,7 @@ void FSN_ActualList::CheckIfIamFSN(bool checkOnly) {
in.MinerAddr = data->Miner.Addr;
in.MinerViewKey = data->Miner.ViewKey;

//LOG_PRINT_L5("=1 Send AddFSN: "<<m_DAPIServer->Port());
m_P2P->Send(p2p_call::AddFSN, in);
//LOG_PRINT_L5("=2 Send AddFSN: "<<m_DAPIServer->Port());
}

boost::shared_ptr<FSN_Data> FSN_ActualList::_OnAddFSN(const rpc_command::BROADCACT_ADD_FULL_SUPER_NODE& in ) {
Expand All @@ -168,15 +166,12 @@ boost::shared_ptr<FSN_Data> FSN_ActualList::_OnAddFSN(const rpc_command::BROADCA
}

void FSN_ActualList::OnAddFSN(const rpc_command::BROADCACT_ADD_FULL_SUPER_NODE& in ) {
//LOG_PRINT_L5("=1 OnAddFSN: "<<m_DAPIServer->Port());
m_Work.Service.post( [this, in](){
OnAddFSNFromWorker(in);
} );
}

void FSN_ActualList::OnAddFSNFromWorker(const rpc_command::BROADCACT_ADD_FULL_SUPER_NODE& in ) {
//LOG_PRINT_L5("=1 OnAddFSNFromWorker: "<<m_DAPIServer->Port());

boost::shared_ptr<FSN_Data> data;
{
boost::lock_guard<boost::recursive_mutex> lock(m_All_FSN_Guard);
Expand Down Expand Up @@ -207,7 +202,6 @@ bool FSN_ActualList::CheckWalletOwner(boost::shared_ptr<FSN_Data> data, const st

DAPI_RPC_Client call;
call.Set(data->IP, data->Port);
//LOG_PRINT_L5("call to: "<<data->IP<<":"<<data->Port);
if( !call.Invoke(dapi_call::FSN_CheckWalletOwnership, in, out) ) return false;
return m_Servant->IsSignValid(in.Str, in.WalletAddr, out.Sign);

Expand Down
3 changes: 0 additions & 3 deletions src/supernode/PosProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ bool supernode::PosProxy::Sale(const rpc_command::POS_SALE::request& in, rpc_com
data->ContinueInit();
} );


// LOG_PRINT_L5( "ADD: "<<in.PaymentID<<" data: "<<data->TransactionRecord.PaymentID );

out.BlockNum = data->TransactionRecord.BlockNum;
out.PaymentID = data->TransactionRecord.PaymentID;
out.Result = STATUS_OK;
Expand Down
9 changes: 2 additions & 7 deletions src/supernode/PosSaleObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ bool supernode::PosSaleObject::Init(const RTA_TransactionRecordBase& src) {
TransactionRecord.PaymentID = GeneratePaymentID();
TransactionRecord.BlockNum = m_Servant->GetCurrentBlockHeight();
TransactionRecord.AuthNodes = m_Servant->GetAuthSample( TransactionRecord.BlockNum );
if( TransactionRecord.AuthNodes.empty() ) { LOG_PRINT_L5("SALE: AuthNodes.empty"); m_Status = NTransactionStatus::Fail; return false; }
if( TransactionRecord.AuthNodes.empty() ) { LOG_PRINT_L0("SALE: AuthNodes.empty"); m_Status = NTransactionStatus::Fail; return false; }

m_Status = NTransactionStatus::InProgress;

Expand All @@ -133,7 +133,7 @@ void supernode::PosSaleObject::ContinueInit() {
inbr.SenderIP = m_DAPIServer->IP();
inbr.SenderPort = m_DAPIServer->Port();
if( !m_SubNetBroadcast.Send(dapi_call::PosProxySale, inbr, outv) || outv.empty() ) {
LOG_PRINT_L5("!Send dapi_call::PosProxySale");
LOG_PRINT_L0("!Send dapi_call::PosProxySale");
m_Status = NTransactionStatus::Fail;

}
Expand Down Expand Up @@ -187,10 +187,6 @@ bool supernode::PosSaleObject::PoSTRSigned(const rpc_command::POS_TR_SIGNED::req
return false;
}


//LOG_PRINT_L5("graft_tx_extra.Signs: "<<graft_tx_extra.Signs.size()<<" TransactionRecord.AuthNodes: "<<TransactionRecord.AuthNodes.size());


for (unsigned i = 0; i < graft_tx_extra.Signs.size(); ++i) {
const string &sign = graft_tx_extra.Signs.at(i);

Expand All @@ -206,7 +202,6 @@ bool supernode::PosSaleObject::PoSTRSigned(const rpc_command::POS_TR_SIGNED::req
// by the same index
for (const auto & authNode : TransactionRecord.AuthNodes) {
check_result = CheckSign(authNode->Stake.Addr, sign);
LOG_PRINT_L5("Checking signature with wallet: " << authNode->Stake.Addr << " [" << sign << "] result: "<<check_result<<" messag: "<<TransactionRecord.MessageForSign());
if (check_result)
break;
}
Expand Down
3 changes: 0 additions & 3 deletions src/supernode/SubNetBroadcast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,11 @@ void supernode::SubNetBroadcast::Set( DAPI_RPC_Server* pa, string subnet_id, con
}

void supernode::SubNetBroadcast::IncNoConnectAndRemove(const string& ip, const string& port) {
// LOG_PRINT_L5("IncNoConnectAndRemove =1 : "<<m_DAPIServer->Port()<<" REM: "<<port);
boost::lock_guard<boost::recursive_mutex> lock(m_MembersGuard);
for(unsigned i=0;i<m_Members.size();i++) if( m_Members[i].IP==ip && m_Members[i].Port==port ) {
m_Members[i].NotAvailCount++;
// LOG_PRINT_L5("IncNoConnectAndRemove =2 : "<<m_DAPIServer->Port()<<" REM: "<<port);
if( m_Members[i].NotAvailCount>=s_MaxNotAvailCount ) {
m_Members.erase( m_Members.begin()+i );
// LOG_PRINT_L5("IncNoConnectAndRemove =3 : "<<m_DAPIServer->Port()<<" REM: "<<port);
}
break;
}
Expand Down
1 change: 0 additions & 1 deletion src/supernode/SubNetBroadcast.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ namespace supernode {
public:
template<class IN_t, class OUT_t>
void DoCallInThread(string method, const IN_t in, OUT_t* outo, int* ret, string ip, string port) {
//LOG_PRINT_L5("call to: "<<ip<<" : "<<port<<"/"<<method<<" from: "<<m_DAPIServer->Port());
bool localcOk = false;
bool wasNoConnect = false;
for(unsigned k=0;k<RetryCount;k++) {
Expand Down
5 changes: 0 additions & 5 deletions src/supernode/WalletPayObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ bool supernode::WalletPayObject::_Init(const rpc_command::WALLET_PAY::request& s
inbr.CustomerWalletAddr = cwa;
inbr.CustomerWalletSign = m_wallet->sign(data);

//LOG_PRINT_L5("CWA: "<<data);

if( !m_SubNetBroadcast.Send(dapi_call::WalletProxyPay, inbr, outv) || outv.empty() ) {
LOG_ERROR("Failed to send WalletProxyPay broadcast");
return false;
Expand Down Expand Up @@ -112,7 +110,6 @@ bool supernode::WalletPayObject::_Init(const rpc_command::WALLET_PAY::request& s
rpc_command::WALLET_PUT_TX_IN_POOL::request req;
req.PaymentID = TransactionRecord.PaymentID;
req.TransactionPoolID = m_TransactionPoolID;
//LOG_PRINT_L5("PaymentID: "<<TransactionRecord.PaymentID);

vector<rpc_command::WALLET_PUT_TX_IN_POOL::response> vv_out;

Expand Down Expand Up @@ -150,8 +147,6 @@ bool supernode::WalletPayObject::PutTXToPool() {
return false;
}

//for(auto& a : m_Signs) LOG_PRINT_L5("sign in m_Signs: "<<a);

GraftTxExtra tx_extra;
tx_extra.BlockNum = 123;
tx_extra.PaymentID = TransactionRecord.PaymentID;
Expand Down
2 changes: 1 addition & 1 deletion src/supernode/graft_wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5735,7 +5735,7 @@ bool GraftWallet::verifySignedMessage(const std::string &message, const std::str
crypto::hash8 payment_id;

if (!cryptonote::get_account_integrated_address_from_str(addr, has_payment_id, payment_id, isTestnet, address)) {
LOG_PRINT_L5("!get_account_integrated_address_from_str");
LOG_PRINT_L0("!get_account_integrated_address_from_str");
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/supernode/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ int main(int argc, const char** argv) {

string conf_file("conf.ini");
if(argc>1) conf_file = argv[1];
LOG_PRINT_L5("conf: "<<conf_file);
LOG_PRINT_L0("conf: "<<conf_file);

// load config
boost::property_tree::ptree config;
boost::property_tree::ini_parser::read_ini(conf_file, config);

const boost::property_tree::ptree& gen_conf = config.get_child("config");
LOG_PRINT_L0("Log level: " << gen_conf.get<int>("log_level", 0));
mlog_set_log_level(gen_conf.get<int>("log_level", 0));
LOG_PRINT_L1("Log level: " << gen_conf.get<int>("log_level", 0));

// TODO: Init all monero staff here
// TODO:
Expand Down
2 changes: 0 additions & 2 deletions src/supernode/supernode_common_struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
#include "crypto/hash.h"
using namespace std;

#define LOG_PRINT_L5(xx) { cout<<__FILE__<<" : "<<xx<<endl; }

namespace supernode {

enum class NTransactionStatus : int {
Expand Down

0 comments on commit 3aca8a0

Please sign in to comment.