summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2011-10-13 21:57:33 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2011-10-13 21:57:33 +0900
commit2f59ce0048a85f45b25e65a41aa4e445fbc7e1b0 (patch)
treef71746db41b50e31ef371fc82a334c5c8708a1ba /src
parent6404f119e1eebf10154e112892720c541a94739e (diff)
Renamed DownloadResult::bitfieldStr to bitfield and changed its
content from hex string to raw byte string.
Diffstat (limited to 'src')
-rw-r--r--src/DownloadResult.h2
-rw-r--r--src/RequestGroup.cc5
-rw-r--r--src/RequestGroupMan.cc6
-rw-r--r--src/RpcMethodImpl.cc11
4 files changed, 12 insertions, 12 deletions
diff --git a/src/DownloadResult.h b/src/DownloadResult.h
index 30136f53..6c80ad29 100644
--- a/src/DownloadResult.h
+++ b/src/DownloadResult.h
@@ -85,7 +85,7 @@ struct DownloadResult
uint64_t uploadLength;
- std::string bitfieldStr;
+ std::string bitfield;
std::string infoHash;
diff --git a/src/RequestGroup.cc b/src/RequestGroup.cc
index cfeebb01..b0f52e1c 100644
--- a/src/RequestGroup.cc
+++ b/src/RequestGroup.cc
@@ -1182,8 +1182,9 @@ DownloadResultHandle RequestGroup::createDownloadResult() const
res->uploadLength = st.getAllTimeUploadLength();
if(pieceStorage_) {
if(pieceStorage_->getBitfieldLength() > 0) {
- res->bitfieldStr = util::toHex(pieceStorage_->getBitfield(),
- pieceStorage_->getBitfieldLength());
+ res->bitfield = std::string(pieceStorage_->getBitfield(),
+ pieceStorage_->getBitfield()+
+ pieceStorage_->getBitfieldLength());
}
}
#ifdef ENABLE_BITTORRENT
diff --git a/src/RequestGroupMan.cc b/src/RequestGroupMan.cc
index 72d40be4..227c4c8c 100644
--- a/src/RequestGroupMan.cc
+++ b/src/RequestGroupMan.cc
@@ -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 =
diff --git a/src/RpcMethodImpl.cc b/src/RpcMethodImpl.cc
index 34347538..2ddb7133 100644
--- a/src/RpcMethodImpl.cc
+++ b/src/RpcMethodImpl.cc
@@ -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();