rippled
TransactionAcquire.h
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2012, 2013 Ripple Labs Inc.
5 
6  Permission to use, copy, modify, and/or distribute this software for any
7  purpose with or without fee is hereby granted, provided that the above
8  copyright notice and this permission notice appear in all copies.
9 
10  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18 //==============================================================================
19 
20 #ifndef RIPPLE_APP_LEDGER_TRANSACTIONACQUIRE_H_INCLUDED
21 #define RIPPLE_APP_LEDGER_TRANSACTIONACQUIRE_H_INCLUDED
22 
23 #include <ripple/app/main/Application.h>
24 #include <ripple/overlay/PeerSet.h>
25 #include <ripple/shamap/SHAMap.h>
26 
27 namespace ripple {
28 
29 // VFALCO TODO rename to PeerTxRequest
30 // A transaction set we are trying to acquire
31 class TransactionAcquire final
32  : public TimeoutCounter,
33  public std::enable_shared_from_this<TransactionAcquire>,
34  public CountedObject<TransactionAcquire>
35 {
36 public:
38 
40  Application& app,
41  uint256 const& hash,
42  std::unique_ptr<PeerSet> peerSet);
43  ~TransactionAcquire() = default;
44 
46  takeNodes(
47  const std::list<SHAMapNodeID>& IDs,
48  const std::list<Blob>& data,
49  std::shared_ptr<Peer> const&);
50 
51  void
52  init(int startPeers);
53 
54  void
55  stillNeed();
56 
57 private:
59  bool mHaveRoot;
61 
62  void
63  onTimer(bool progress, ScopedLockType& peerSetLock) override;
64 
65  void
66  done();
67 
68  void
69  addPeers(std::size_t limit);
70 
71  void
74  pmDowncast() override;
75 };
76 
77 } // namespace ripple
78 
79 #endif
ripple::TransactionAcquire::mHaveRoot
bool mHaveRoot
Definition: TransactionAcquire.h:59
ripple::Application
Definition: Application.h:115
ripple::SHAMapAddNode
Definition: SHAMapAddNode.h:28
ripple::CountedObject
Tracks the number of instances of an object.
Definition: CountedObject.h:124
std::shared_ptr< TransactionAcquire >
std::list
STL class.
ripple::TransactionAcquire::trigger
void trigger(std::shared_ptr< Peer > const &)
Definition: TransactionAcquire.cpp:113
ripple::TransactionAcquire::pmDowncast
std::weak_ptr< TimeoutCounter > pmDowncast() override
Return a weak pointer to this.
Definition: TransactionAcquire.cpp:107
ripple::TransactionAcquire::addPeers
void addPeers(std::size_t limit)
Definition: TransactionAcquire.cpp:247
ripple::TransactionAcquire
Definition: TransactionAcquire.h:31
ripple::startPeers
@ startPeers
Definition: InboundTransactions.cpp:36
ripple::TimeoutCounter
This class is an "active" object.
Definition: TimeoutCounter.h:66
ripple::TransactionAcquire::mMap
std::shared_ptr< SHAMap > mMap
Definition: TransactionAcquire.h:58
ripple::base_uint< 256 >
ripple::TransactionAcquire::onTimer
void onTimer(bool progress, ScopedLockType &peerSetLock) override
Hook called from invokeOnTimer().
Definition: TransactionAcquire.cpp:91
std::unique_lock< std::recursive_mutex >
std::enable_shared_from_this
ripple::TransactionAcquire::TransactionAcquire
TransactionAcquire(Application &app, uint256 const &hash, std::unique_ptr< PeerSet > peerSet)
Definition: TransactionAcquire.cpp:43
ripple::TransactionAcquire::init
void init(int startPeers)
Definition: TransactionAcquire.cpp:256
std::weak_ptr
STL class.
ripple::TransactionAcquire::~TransactionAcquire
~TransactionAcquire()=default
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::TransactionAcquire::takeNodes
SHAMapAddNode takeNodes(const std::list< SHAMapNodeID > &IDs, const std::list< Blob > &data, std::shared_ptr< Peer > const &)
Definition: TransactionAcquire.cpp:178
ripple::TransactionAcquire::stillNeed
void stillNeed()
Definition: TransactionAcquire.cpp:266
std::size_t
std::unique_ptr
STL class.
ripple::TransactionAcquire::mPeerSet
std::unique_ptr< PeerSet > mPeerSet
Definition: TransactionAcquire.h:60
ripple::TransactionAcquire::done
void done()
Definition: TransactionAcquire.cpp:62