@@ -33,6 +33,8 @@ namespace protocol_wire {
3333 class BuyerTerms ;
3434 class Ready ;
3535 class PieceData ;
36+ class SpeedTestRequest ;
37+ class SpeedTestPayload ;
3638}
3739
3840namespace protocol_statemachine {
@@ -55,6 +57,8 @@ namespace protocol_statemachine {
5557 typedef std::function<void (const protocol_wire::RequestFullPiece&)> SendRequestFullPieceMessage;
5658 typedef std::function<void (const protocol_wire::FullPiece&)> SendFullPieceMessage;
5759 typedef std::function<void (const protocol_wire::Payment&)> SendPaymentMessage;
60+ typedef std::function<void (const protocol_wire::SpeedTestRequest&)> SendSpeedTestRequestMessage;
61+ typedef std::function<void (const protocol_wire::SpeedTestPayload&)> SendSpeedTestPayloadMessage;
5862
5963 struct Send {
6064 SendObserveMessage observe;
@@ -66,6 +70,8 @@ namespace protocol_statemachine {
6670 SendRequestFullPieceMessage request_full_piece;
6771 SendFullPieceMessage full_piece;
6872 SendPaymentMessage payment;
73+ SendSpeedTestRequestMessage speedTestRequest;
74+ SendSpeedTestPayloadMessage speedTestPayload;
6975 };
7076
7177 // // Selling Notifications
@@ -94,8 +100,14 @@ namespace protocol_statemachine {
94100 // Peer sent an invalid payment signature
95101 typedef std::function<void (const Coin::Signature &)> InvalidPayment;
96102
103+ // Peer requested speed test
104+ typedef std::function<void (uint32_t )> BuyerRequestedSpeedTest;
105+
97106 // // Buying Notifications
98107
108+ // Peer sent the speedtest payload
109+ typedef std::function<void (bool )> SellerCompletedSpeedTest;
110+
99111 // Peer, in seller mode, joined the most recent invitation
100112 typedef NoPayloadNotification SellerJoined;
101113
@@ -140,6 +152,8 @@ namespace protocol_statemachine {
140152 const ReceivedFullPiece &,
141153 const MessageOverflow &,
142154 const MessageOverflow &,
155+ const SellerCompletedSpeedTest &,
156+ const BuyerRequestedSpeedTest &,
143157 int ,
144158 Coin::Network network);
145159
@@ -190,10 +204,12 @@ namespace protocol_statemachine {
190204 friend class WaitingToStart ;
191205 friend class StartedSelling ;
192206 friend class ServicingPieceRequests ;
207+ friend class ReadyToSendTestPayload ;
193208
194209 // Buying states
195210 friend class Buying ;
196211 friend class ReadyToInviteSeller ;
212+ friend class TestingSellerSpeed ;
197213 friend class WaitingForSellerToJoin ;
198214 friend class PreparingContract ;
199215 friend class SellerHasJoined ;
@@ -211,6 +227,11 @@ namespace protocol_statemachine {
211227 void clientToSellMode (const protocol_wire::SellerTerms &, uint32_t = 0 );
212228 void clientToBuyMode (const protocol_wire::BuyerTerms &);
213229
230+ // Speed testing
231+ void sentSpeedTestRequest (uint32_t );
232+ void receivedTestPayload (uint32_t );
233+ void buyerRequestedSpeedTest (uint32_t );
234+
214235 // // Callbacks
215236
216237 // All callbacks are initiated when state machine has finished all processing.
@@ -263,6 +284,8 @@ namespace protocol_statemachine {
263284 CallbackQueuer<const protocol_wire::RequestFullPiece&> _sendRequestFullPieceMessage;
264285 CallbackQueuer<const protocol_wire::FullPiece&> _sendFullPieceMessage;
265286 CallbackQueuer<const protocol_wire::Payment&> _sendPaymentMessage;
287+ CallbackQueuer<const protocol_wire::SpeedTestRequest&> _sendSpeedTestRequestMessage;
288+ CallbackQueuer<const protocol_wire::SpeedTestPayload&> _sendSpeedTestPayloadMessage;
266289
267290 CallbackQueuer<uint64_t , const Coin::typesafeOutPoint &, const Coin::PublicKey &, const Coin::PubKeyHash &> _contractIsReady;
268291 CallbackQueuer<int > _pieceRequested;
@@ -275,6 +298,8 @@ namespace protocol_statemachine {
275298 CallbackQueuer<const protocol_wire::PieceData &> _receivedFullPiece;
276299 CallbackQueuer<> _remoteMessageOverflow;
277300 CallbackQueuer<> _localMessageOverflow;
301+ CallbackQueuer<bool > _sellerCompletedSpeedTest;
302+ CallbackQueuer<uint32_t > _buyerRequestedSpeedTest;
278303
279304 void peerAnnouncedMode ();
280305
@@ -300,6 +325,8 @@ namespace protocol_statemachine {
300325
301326 // Index of last piece requested
302327 int _lastRequestedPiece;
328+
329+ uint32_t _requestedTestPayloadSize;
303330 };
304331
305332 template <typename T>
0 commit comments