本文整理汇总了C++中code类的典型用法代码示例。如果您正苦于以下问题:C++ code类的具体用法?C++ code怎么用?C++ code使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了code类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: inbound_channel_stopped
void protocol::inbound_channel_stopped(const code& ec,
channel::ptr node, const std::string& address)
{
log_debug(LOG_PROTOCOL)
<< "Channel stopped (inbound) [" << address << "] "
<< ec.message();
// We never attempt to reconnect inbound connections.
remove_connection(inbound_connections_, node);
}
示例2: size
// new blocks come in - remove txs in new
// old blocks taken out - resubmit txs in old
bool transaction_pool::handle_reorganized(const code& ec, size_t fork_point,
const block::ptr_list& new_blocks, const block::ptr_list& replaced_blocks)
{
if (ec == error::service_stopped)
{
log::debug(LOG_BLOCKCHAIN)
<< "Stopping transaction pool: " << ec.message();
return false;
}
if (ec)
{
log::debug(LOG_BLOCKCHAIN)
<< "Failure in tx pool reorganize handler: " << ec.message();
return false;
}
log::debug(LOG_BLOCKCHAIN)
<< "Reorganize: tx pool size (" << buffer_.size()
<< ") forked at (" << fork_point
<< ") new blocks (" << new_blocks.size()
<< ") replace blocks (" << replaced_blocks.size() << ")";
if (replaced_blocks.empty())
{
// Remove memory pool transactions that also exist in new blocks.
dispatch_.ordered(
std::bind(&transaction_pool::remove,
this, new_blocks));
}
else
{
// See http://www.jwz.org/doc/worse-is-better.html
// for why we take this approach. We return with an error_code.
// An alternative would be resubmit all tx from the cleared blocks.
dispatch_.ordered(
std::bind(&transaction_pool::clear,
this, error::blockchain_reorganized));
}
return true;
}
示例3: handle_channel_stop
void session_manual::handle_channel_stop(const code& ec,
const std::string& hostname, uint16_t port)
{
LOG_DEBUG(LOG_NETWORK)
<< "Manual channel stopped: " << ec.message();
// Special case for already connected, do not keep trying.
// After a stop we don't use the caller's start handler, but keep connecting.
if (ec != error::address_in_use)
connect(hostname, port);
}
示例4: handle_timer
void protocol_base_base::handle_timer(const code& ec)
{
if (stopped() || deadline::canceled(ec))
return;
log_debug(LOG_PROTOCOL)
<< "Fired " << name_ << " protocol timer on [" << authority() << "] "
<< ec.message();
callback(error::channel_timeout);
}
示例5: succeeded
bool callback_state::succeeded(const code& ec, const std::string& format)
{
if (ec)
{
// May want to change the behavior to decrement vs. zeroizing refs.
error(boost::format(format) % ec.message());
stop(console_result::failure);
return false;
}
return true;
}
示例6: handle_store_addresses
void protocol_address::handle_store_addresses(const code& ec)
{
if (stopped())
return;
if (ec)
{
log_error(LOG_PROTOCOL)
<< "Failure storing addresses from [" << authority() << "] "
<< ec.message();
stop(ec);
}
}
示例7: handle_send_get_address
void protocol_address::handle_send_get_address(const code& ec)
{
if (stopped())
return;
if (ec)
{
log_debug(LOG_PROTOCOL)
<< "Failure sending get_address [" << authority() << "] "
<< ec.message();
stop(ec);
}
}
示例8: checkIncorrect
// input:
// code guess - a code object containing the user's guess
// output:
// int incorrect - the number of digits in the guess that exist in the secret, but are not correctly placed
//
// Check how many digits are part of the secret code, but were guessed at wrong positions. If an index is set to 6
// we know that the index has been covered and will skip it. If an element in the same spot in secretDigits is set to 6,
// this also means that the value has been covered.
// ASSUMPTION: This is called AFTER checkIncorrect so that it will only check indices that haven't been confirmed
int code::checkIncorrect(code guess) {
vector<int> userGuess = guess.getGuess();
vector<int> secretCode = guess.getSecret();
vector<int> secretDigits = getDigits();
int incorrect = 0;
for (int i=0; i < userGuess.size(); i++) {
//Index has already been confirmed, move on
if (userGuess[i] == 6) {
continue;
}
//Digit IS part of solution, HAS NOT been verified by checkCorrect, but in wrong place
if (find(secretDigits.begin(), secretDigits.end(), userGuess[i]) != secretDigits.end() && userGuess[i] != secretDigits[i] && secretDigits[i] != 6) {
incorrect += 1;
userGuess[i] = 6;
secretDigits[distance( secretDigits.begin(), find(secretDigits.begin(), secretDigits.end(), userGuess[i]))] = 6;
}
}
setDigits(secretDigits);
return incorrect;
}
示例9: handle_channel_start
void session_inbound::handle_channel_start(const code& ec,
channel::ptr channel)
{
if (ec)
{
LOG_INFO(LOG_NETWORK)
<< "Inbound channel failed to start [" << channel->authority()
<< "] " << ec.message();
return;
}
attach_protocols(channel);
};
示例10: outbound_channel_stopped
void protocol::outbound_channel_stopped(const code& ec,
channel::ptr node, const std::string& address)
{
log_debug(LOG_PROTOCOL)
<< "Channel stopped (outbound) [" << address << "] "
<< ec.message();
remove_connection(outbound_connections_, node);
// If not shutdown we always create a replacement oubound connection.
if (ec != error::service_stopped)
new_connection();
}
示例11: handler
void p2p::handle_running(const code& ec, result_handler handler)
{
if (ec)
{
LOG_ERROR(LOG_NETWORK)
<< "Error starting outbound session: " << ec.message();
handler(ec);
return;
}
// This is the end of the run sequence.
handler(error::success);
}
示例12: manual_channel_stopped
void protocol::manual_channel_stopped(const code& ec,
channel::ptr node, const std::string& address, bool relay, size_t retries)
{
log_debug(LOG_PROTOCOL)
<< "Channel stopped (manual) [" << address << "] "
<< ec.message();
remove_connection(manual_connections_, node);
// If not shutdown we always attempt to reconnect manual connections.
if (ec != error::service_stopped)
retry_manual_connection(address, relay, retries);
}
示例13: handle_send_pong
void protocol_ping::handle_send_pong(const code& ec)
{
if (stopped())
return;
if (ec)
{
log::debug(LOG_NETWORK)
<< "Failure sending pong to [" << authority() << "] "
<< ec.message();
stop(ec);
}
}
示例14: handle_send
void protocol_header_sync::handle_send(const code& ec, event_handler complete)
{
if (stopped())
return;
if (ec)
{
log::debug(LOG_PROTOCOL)
<< "Failure sending get headers to sync [" << authority() << "] "
<< ec.message();
complete(ec);
}
}
示例15: authority
void protocol_version_31402::handle_verack_sent(const code& ec)
{
if (stopped())
return;
if (ec)
{
LOG_DEBUG(LOG_NETWORK)
<< "Failure sending verack to [" << authority() << "] "
<< ec.message();
set_event(ec);
return;
}
}