Renamed DownloadResult::bitfieldStr to bitfield and changed its

content from hex string to raw byte string.
pull/2/head
Tatsuhiro Tsujikawa 2011-10-13 21:57:33 +09:00
parent 6404f119e1
commit 2f59ce0048
4 changed files with 12 additions and 12 deletions

View File

@ -85,7 +85,7 @@ struct DownloadResult
uint64_t uploadLength;
std::string bitfieldStr;
std::string bitfield;
std::string infoHash;

View File

@ -1182,7 +1182,8 @@ DownloadResultHandle RequestGroup::createDownloadResult() const
res->uploadLength = st.getAllTimeUploadLength();
if(pieceStorage_) {
if(pieceStorage_->getBitfieldLength() > 0) {
res->bitfieldStr = util::toHex(pieceStorage_->getBitfield(),
res->bitfield = std::string(pieceStorage_->getBitfield(),
pieceStorage_->getBitfield()+
pieceStorage_->getBitfieldLength());
}
}

View File

@ -692,8 +692,8 @@ void RequestGroupMan::formatDownloadResultFull
{
BitfieldMan bt(downloadResult->pieceLength, downloadResult->totalLength);
bt.setBitfield(reinterpret_cast<const unsigned char*>
(util::fromHex(downloadResult->bitfieldStr).data()),
downloadResult->bitfieldStr.size()/2);
(downloadResult->bitfield.data()),
downloadResult->bitfield.size());
bool head = true;
const std::vector<SharedHandle<FileEntry> >& fileEntries =
downloadResult->fileEntries;
@ -709,7 +709,7 @@ void RequestGroupMan::formatDownloadResultFull
} else {
o << " | | |";
}
if((*i)->getLength() == 0 || downloadResult->bitfieldStr.empty()) {
if((*i)->getLength() == 0 || downloadResult->bitfield.empty()) {
o << " -|";
} else {
uint64_t completedLength =

View File

@ -607,9 +607,8 @@ void createFileEntry
InputIterator first, InputIterator last,
uint64_t totalLength,
size_t pieceLength,
const std::string& bitfieldStr)
const std::string& bitfield)
{
std::string bitfield = util::fromHex(bitfieldStr);
BitfieldMan bf(pieceLength, totalLength);
bf.setBitfield(reinterpret_cast<const unsigned char*>(bitfield.data()),
bitfield.size());
@ -868,7 +867,7 @@ void gatherStoppedDownload
if(requested_key(keys, KEY_FILES)) {
SharedHandle<List> files = List::g();
createFileEntry(files, ds->fileEntries.begin(), ds->fileEntries.end(),
ds->totalLength, ds->pieceLength, ds->bitfieldStr);
ds->totalLength, ds->pieceLength, ds->bitfield);
entryDict->put(KEY_FILES, files);
}
if(requested_key(keys, KEY_TOTAL_LENGTH)) {
@ -881,8 +880,8 @@ void gatherStoppedDownload
entryDict->put(KEY_UPLOAD_LENGTH, util::uitos(ds->uploadLength));
}
if(requested_key(keys, KEY_BITFIELD)) {
if(!ds->bitfieldStr.empty()) {
entryDict->put(KEY_BITFIELD, ds->bitfieldStr);
if(!ds->bitfield.empty()) {
entryDict->put(KEY_BITFIELD, util::toHex(ds->bitfield));
}
}
if(requested_key(keys, KEY_DOWNLOAD_SPEED)) {
@ -931,7 +930,7 @@ SharedHandle<ValueBase> GetFilesRpcMethod::process
util::itos(gid).c_str()));
} else {
createFileEntry(files, dr->fileEntries.begin(), dr->fileEntries.end(),
dr->totalLength, dr->pieceLength, dr->bitfieldStr);
dr->totalLength, dr->pieceLength, dr->bitfield);
}
} else {
const SharedHandle<PieceStorage>& ps = group->getPieceStorage();