If I want to send a message and handle the response somewhere in the code, what is the API? What components do I need? How do I construct them or get handles to them? What methods do I call? How do I add new message types?
How does a component within rippled send and receive messages from peers?
39 Views Asked by John Freeman At
1
There are 1 best solutions below
Related Questions in RIPPLED
- rippled SSL-Certificate
- Ripple XRP Ledger - How do I create an asset or a token? What is the transaction type that accomplishes that?
- Ripple XRP Ledger - How much data can i put in the memo field
- How can we take all ripple aka XRP accounts snapshot?
- How to run ripple v2 on local
- boost_chrono_FOUND to FALSE so package "boost_chrono" is considered to be NOT FOUND
- Generate digest/ binary blob for XRP raw transaction using rippled c++ library
- How does a component within rippled send and receive messages from peers?
- How can I debug a deadlocked rippled?
- Why is a ledger hashed with the close time of its parent ledger?
- How can I apply a transaction to a ledger?
- How can I sign a JSON transaction?
- How to get information from xrp rippled like data api v2 in localhost
- Since ripple-lib-java is unmaintained, how do you manually sign a transaction?
- xrp {"result":{"error":"noNetwork","error_code":17,"error_message":"Not synced to Ripple network.","request":{"command":"fee"},"status":"error"}}
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Here is a sequence diagram I made for the messages exchanged as part of downloading candidate transaction sets referenced by proposals:
To send a message, a component needs a
PeerImpobject (generally held viashared_ptr<Peer>) on which it calls thesend(shared_ptr<Message>)method. There is only one generic implementation ofsend, and it handles every protocol buffer message type. This call returnsvoid(i.e. no request object).When a message is received from a peer, the
onMessage(MessageType)method for that message type is called. There is a different overload ofonMessagefor each message type.Consider when you write code for HTTP. A popular idiom in JavaScript looks like this:
There are some important differences between this pattern and the one for RTXP (the official name of our message protocol):
HTTP has an association between request and response. RTXP generally does not have this association, but in one notable example it does.
TMGetLedgeris a request message type, andTMLedgerDatais its response message type. They both have arequestCookiefield to associate a response with its request. The request generates a (random?) identifier for its “request cookie”, and the response copies that cookie.With HTTP, the code that sends the request passes a handler expecting the response. Generally, the response handler is different for each place in the code that sends a request. Not so with RTXP. Instead, each request message type typically corresponds to exactly one response message type, and each message of a given type has the same exact handler. That means each place in the code that sends a request of the same message type uses the same response handler. I suspect that:
most message types are sent from exactly one place in the code
when one message type is sent from multiple places, then that message has an enumeration field to distinguish them (with “type” in its name)
each message type was designed for exactly the place in the code that needed to send it, which makes them hard to reuse
Most request message types are different from their response message types. The one notable exception is
TMGetObjectByHashwhich has a Booleanqueryfield that distinguishes a request (true) from a response (false).There is some room for uniform handling of each message type:
A message is generally expected to be independently verifiable. If a response says it has the header for ledger
ABCD, then the handler expects it can hash the header to get the digestABCD.A response is generally expected to correspond to a request.
If these expectations are violated, the peer that sent the message is penalized. Our server tracks a “fee” for each peer that measures its reliability. Bad messages are “charged” various fees based on the kind of violation. These fees only exist on the server. They have no bearing on the ledger.
PeerImpobjects are obtained from theOverlayobject. There is exactly oneOverlayperApplication, obtained by calling itsoverlay()method.