Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions conan_package/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

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

def source(self):
Expand Down
13 changes: 13 additions & 0 deletions sources/include/extension/Alert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,19 @@ namespace alert {
const Coin::KeyPair contractKeyPair;
const Coin::PubKeyHash finalPkHash;
};

struct AllSellersGone : public libtorrent::torrent_alert {

AllSellersGone(libtorrent::aux::stack_allocator& alloc,
const libtorrent::torrent_handle & h)
: libtorrent::torrent_alert(alloc, h) {}

TORRENT_DEFINE_ALERT(DownloadStarted, libtorrent::user_alert_id + 32)
static const int static_category = alert::status_notification;
virtual std::string message() const override {
return torrent_alert::message() + " all sellers gone";
}
};
}
}
}
Expand Down
11 changes: 4 additions & 7 deletions sources/include/extension/TorrentPlugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <libtorrent/torrent.hpp>
#include <libtorrent/alert_types.hpp>
#include <map>
#include <chrono>

namespace joystream {
namespace extension {
Expand Down Expand Up @@ -215,6 +216,7 @@ class TorrentPlugin : public libtorrent::torrent_plugin {
protocol_session::AnchorAnnounced<libtorrent::peer_id> anchorAnnounced();
protocol_session::ReceivedValidPayment<libtorrent::peer_id> receivedValidPayment();
protocol_session::SentPayment<libtorrent::peer_id> sentPayment();
protocol_session::AllSellersGone allSellersGone();

/// Members

Expand Down Expand Up @@ -297,16 +299,11 @@ class TorrentPlugin : public libtorrent::torrent_plugin {

/// Sell mode spesific state

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

/// Buy mode spesific state

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

/// Utilities

Expand Down
14 changes: 14 additions & 0 deletions sources/src/PeerPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,20 @@ namespace extension {
return true;
}

// Only communicate with peers with same protocol major version number
if(_protocolVersionOfPeer.major() != protocol_statemachine::CBStateMachine::protocolVersion.major()) {
// Mark peer as not supporting this extension
_peerPaymentBEPSupportStatus = BEPSupportStatus::not_supported;

// Remove peer
std::clog << "Dropping Peer: (incompatible protocol vesrion)" << std::endl;
libtorrent::error_code ec;
drop(ec);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a bit strict, its not clear that we cannot hold a connection open for normal bittorrent/DHT traffic. It could also be useful for the extension user to understand how often and what peers are using incompatible protocol version. To this end, one could introduce a new enum value in BEPSupportStatus which reflects an incompatible version explicitly. For now though, this is good enough I think, so at best making an issue out of this could be interesting, and perhaps marking it with "good first issue" or help wanted.


// Keep us around
return true;
}

// Try to extract m key, if its not present, then we are done
libtorrent::bdecode_node m = handshake.dict_find_dict("m");

Expand Down
Loading