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); }
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(); }
bool operator==(const bithorde::AssetStatus& a, const bithorde::AssetStatus& b) { if (a.status() != b.status()) return false; if (a.size() != b.size()) return false; if (a.availability() != b.availability()) return false; if (a.ids() != b.ids()) { return false; } if (a.servers() != b.servers()) { return false; } return true; }
void bithorded::cache::CachingAsset::upstreamStatusChange(const bithorde::AssetStatus& newStatus) { if ((newStatus.status() == bithorde::Status::SUCCESS) && !_cached && _upstream->size() > 0) { _delayedCreation = true; } if (_cached && _cached->hasRootHash()) { status = *_cached->status; } else { status = newStatus; } }
void BHUpload::onStatusUpdate(const bithorde::AssetStatus& status) { switch (status.status()) { case bithorde::SUCCESS: if (status.ids_size()) { cout << MagnetURI(status) << endl; nextAsset(); } else if (!optLink) { cerr << "Uploading ..." << endl; _writeConnection = _client->writable.connect(boost::bind(&BHUpload::onWritable, this)); onWritable(); } break; default: cerr << "Failed ..." << endl; nextAsset(); break; } }