Skip to content

Commit 47062ac

Browse files
authored
Merge pull request #52 from JoyStream/development
dev to master - v0.2.0
2 parents af38f67 + a0cd159 commit 47062ac

5 files changed

Lines changed: 143 additions & 159 deletions

File tree

conan_package/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
class ExtensionBase(ConanFile):
55
name = "Extension"
6-
version = "0.1.6"
6+
version = "0.2.0"
77
license = "(c) JoyStream Inc. 2016-2017"
88
url = "https://github.com/JoyStream/extension-cpp.git"
99
repo_ssh_url = "git@github.com:JoyStream/extension-cpp.git"
1010
repo_https_url = "https://github.com/JoyStream/extension-cpp.git"
1111
settings = "os", "compiler", "build_type", "arch"
1212
generators = "cmake"
13-
requires = "ProtocolSession/0.1.4@joystream/stable", "Libtorrent/1.1.1@joystream/stable"
13+
requires = "ProtocolSession/0.2.1@joystream/stable", "Libtorrent/1.1.1@joystream/stable", "Common/0.1.3@joystream/stable"
1414
build_policy = "missing"
1515

1616
def source(self):

sources/include/extension/Alert.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,19 @@ namespace alert {
548548
const Coin::KeyPair contractKeyPair;
549549
const Coin::PubKeyHash finalPkHash;
550550
};
551+
552+
struct AllSellersGone : public libtorrent::torrent_alert {
553+
554+
AllSellersGone(libtorrent::aux::stack_allocator& alloc,
555+
const libtorrent::torrent_handle & h)
556+
: libtorrent::torrent_alert(alloc, h) {}
557+
558+
TORRENT_DEFINE_ALERT(DownloadStarted, libtorrent::user_alert_id + 32)
559+
static const int static_category = alert::status_notification;
560+
virtual std::string message() const override {
561+
return torrent_alert::message() + " all sellers gone";
562+
}
563+
};
551564
}
552565
}
553566
}

sources/include/extension/TorrentPlugin.hpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <libtorrent/torrent.hpp>
1515
#include <libtorrent/alert_types.hpp>
1616
#include <map>
17+
#include <chrono>
1718

1819
namespace joystream {
1920
namespace extension {
@@ -215,6 +216,7 @@ class TorrentPlugin : public libtorrent::torrent_plugin {
215216
protocol_session::AnchorAnnounced<libtorrent::peer_id> anchorAnnounced();
216217
protocol_session::ReceivedValidPayment<libtorrent::peer_id> receivedValidPayment();
217218
protocol_session::SentPayment<libtorrent::peer_id> sentPayment();
219+
protocol_session::AllSellersGone allSellersGone();
218220

219221
/// Members
220222

@@ -297,16 +299,11 @@ class TorrentPlugin : public libtorrent::torrent_plugin {
297299

298300
/// Sell mode spesific state
299301

300-
// While selling, this maintains mapping between piece index and peers that are
301-
// waiting for this piece to be read from disk.
302-
// Will typically just be one, but may be multiple - hence set is used
303-
std::map<int, std::set<libtorrent::peer_id> > _outstandingLoadPieceForBuyerCalls;
302+
// While selling, this maintains set of pieces peers are waiting for to be read from disk.
303+
std::set<int> _outstandingLoadPieceForBuyers;
304304

305305
/// Buy mode spesific state
306306

307-
// While buying, this maintains mapping between piece index and the single
308-
// peer waiting for it to be validated and stored.
309-
std::map<int, libtorrent::peer_id> _outstandingFullPieceArrivedCalls;
310307

311308
/// Utilities
312309

sources/src/PeerPlugin.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,20 @@ namespace extension {
241241
return true;
242242
}
243243

244+
// Only communicate with peers with same protocol major version number
245+
if(_protocolVersionOfPeer.major() != protocol_statemachine::CBStateMachine::protocolVersion.major()) {
246+
// Mark peer as not supporting this extension
247+
_peerPaymentBEPSupportStatus = BEPSupportStatus::not_supported;
248+
249+
// Remove peer
250+
std::clog << "Dropping Peer: (incompatible protocol vesrion)" << std::endl;
251+
libtorrent::error_code ec;
252+
drop(ec);
253+
254+
// Keep us around
255+
return true;
256+
}
257+
244258
// Try to extract m key, if its not present, then we are done
245259
libtorrent::bdecode_node m = handshake.dict_find_dict("m");
246260

0 commit comments

Comments
 (0)