void bithorded::router::ForwardedAsset::onUpstreamStatus(const string& peername, const bithorde::AssetStatus& status) { if (status.status() == bithorde::Status::SUCCESS) { if (status.size() > (static_cast<uint64_t>(1)<<60)) { BOOST_LOG_SEV(assetLogger, bithorded::warning) << idsToString(_requestedIds) << ':' << peername << ": new state with suspiciously large size" << status.size() << ", " << status.has_size() ; } if ( overlaps(_reqParameters->requesters, status.servers().begin(), status.servers().end()) ) { BOOST_LOG_SEV(assetLogger, bithorded::debug) << idsToString(_requestedIds) << " Loop detected " << peername; dropUpstream(peername); } else { BOOST_LOG_SEV(assetLogger, bithorded::debug) << idsToString(_requestedIds) << " Found upstream " << peername; if (status.has_size()) { if (_size == -1) { _size = status.size(); } else if (_size != (int64_t)status.size()) { BOOST_LOG_SEV(assetLogger, bithorded::warning) << peername << " " << idsToString(_requestedIds) << " responded with mismatching size, ignoring..."; dropUpstream(peername); } } else if (status.ids().size()) { BOOST_LOG_SEV(assetLogger, bithorded::warning) << peername << " " << idsToString(_requestedIds) << " SUCCESS response not accompanied with asset-size."; } } } else { BOOST_LOG_SEV(assetLogger, bithorded::debug) << idsToString(_requestedIds) << " Failed upstream " << peername; dropUpstream(peername); } updateStatus(); }
void Client::informAssetStatusUpdate(bithorde::Asset::Handle h, const IAsset::Ptr& asset, const bithorde::AssetStatus& status) { if (status.status() == bithorde::NONE) return; size_t asset_idx = h; if ((asset_idx >= _assets.size()) || (_assets[asset_idx] != asset)) return; _assets[asset_idx].clearDeadline(); bithorde::AssetStatus resp(status); resp.set_handle(h); if ((resp.status() == bithorde::SUCCESS) && _assets[asset_idx].assetIds().size() && !idsOverlap(_assets[asset_idx].assetIds(), status.ids()) ) { BOOST_LOG_SEV(clientLogger, bithorded::warning) << peerName() << ':' << h << " new state with mismatching asset ids (" << idsToString(resp.ids()) << ")"; resp.set_status(bithorde::NOTFOUND); } if (status.size() > (static_cast<uint64_t>(1)<<60)) { BOOST_LOG_SEV(clientLogger, bithorded::warning) << peerName() << ':' << h << " new state with suspiciously large size" << resp.size() << ", " << status.has_size(); } BOOST_LOG_SEV(clientLogger, bithorded::debug) << peerName() << ':' << h << " new state " << bithorde::Status_Name(resp.status()) << " (" << idsToString(resp.ids()) << ") availability: " << resp.availability(); sendMessage(bithorde::Connection::AssetStatus, resp, bithorde::Message::NEVER, true); }