paths - cleanup

This commit is contained in:
mDuo13
2015-10-20 13:56:48 -07:00
parent 48fee21c90
commit 9d650dcf79

View File

@@ -1,6 +1,6 @@
# Paths # # Paths #
In the Ripple Consensus Ledger, paths define a way for payments to flow through intermediary steps on their way from sender to receiver. Paths enable cross-currency payments and exchanges. A single Payment transaction in the Ripple Consensus Ledger can use multiple paths, combining liquidity from different sources to deliver the desired amount. Thus, a transaction includes a _path set_ of possible paths to take. The paths in a path set must start and end with the same currency, although they could use different issuers. In the Ripple Consensus Ledger, paths define a way for payments to flow through intermediary steps on their way from sender to receiver. Paths enable cross-currency payments and exchanges. A single Payment transaction in the Ripple Consensus Ledger can use multiple paths, combining liquidity from different sources to deliver the desired amount. Thus, a transaction includes a _path set_ of possible paths to take. The paths in a path set must start and end with the same currency.
Since XRP can be sent directly to any address, an XRP-to-XRP transaction does not use any paths. Since XRP can be sent directly to any address, an XRP-to-XRP transaction does not use any paths.
@@ -13,7 +13,7 @@ A path is made of steps that connect the sender to the receiver of the payment.
In the case of a currency exchange step, the path step specifies which currency to change to, but does not record the state of the orders in the order book. Since the order of transactions is not finalized until a ledger is validated, it is impossible to determine for certain which offers a transaction will execute, until after the transaction has been validated. Consequently, you cannot know in advance which offers a transaction will take: only which order books the transaction will use. (You can make an educated guess, since each transaction takes the best available offers at the time it executes in the final ledger.) In the case of a currency exchange step, the path step specifies which currency to change to, but does not record the state of the orders in the order book. Since the order of transactions is not finalized until a ledger is validated, it is impossible to determine for certain which offers a transaction will execute, until after the transaction has been validated. Consequently, you cannot know in advance which offers a transaction will take: only which order books the transaction will use. (You can make an educated guess, since each transaction takes the best available offers at the time it executes in the final ledger.)
Each intermediate account gains and loses approximately equal value: either a balance ripples from a trust line to another trust line in the same currency, or they exchange currencies according to a previously-placed order. In some cases, the amounts gained and lost may not be exact, due either to [transfer fees](https://ripple.com/knowledge_center/transfer-fees/) or rounding. In both types of steps, each intermediate account gains and loses approximately equal value: either a balance ripples from a trust line to another trust line in the same currency, or they exchange currencies according to a previously-placed order. In some cases, the amounts gained and lost may not be exactly equivalent, due either to [transfer fees](https://ripple.com/knowledge_center/transfer-fees/) or rounding.
[![Diagram of three example paths](img/paths.png)](img/paths.png) [![Diagram of three example paths](img/paths.png)](img/paths.png)
@@ -47,11 +47,12 @@ In addition to any paths that are specified in the transaction, a transaction ca
The default path could be any of the following: The default path could be any of the following:
* If the transaction is uses one currency (regardless of issuer), then the default path connects the accounts of the implied steps directly. This path will only work if there is a trust line connecting those accounts. * If the transaction is uses only one currency (regardless of issuer), then the default path assumes the payment will ripple through the accounts involved. This path will only work if there are trust lines connecting those accounts.
* If `SendMax` is omitted, or the `issuer` of the `SendMax` is the sender, the default path needs a trust line from the sending `Account` to the `issuer` of the destination `Amount` in order to work. * If `SendMax` is omitted, or the `issuer` of the `SendMax` is the sender, the default path needs a trust line from the sending `Account` to the `issuer` of the destination `Amount` in order to work.
* If the `SendMax` and `Amount` have different `issuer` values, and neither are the sender or receiver, the default path is probably not useful because it would need to ripple through a trust line between the two issuers. Ripple, Inc. typically discourages issuers from trusting one another directly. * If the `SendMax` and `Amount` have different `issuer` values, and neither are the sender or receiver, the default path is probably not useful because it would need to ripple across a trust line between the two issuers. Ripple, Inc. typically discourages issuers from trusting one another directly.
* For cross-currency transactions, the default path automatically appends the order book between the source currency (as specified in the `SendMax` field) and the destination currency (as specified in the `Amount` field). * For cross-currency transactions, the default path uses the order book between the source currency (as specified in the `SendMax` field) and the destination currency (as specified in the `Amount` field).
The following diagram enumerates all possible default paths:
[![Diagram of default paths](img/default-paths.png)](img/default-paths.png) [![Diagram of default paths](img/default-paths.png)](img/default-paths.png)
You can use the [`tfNoDirectRipple` flag](transactions.html#payment-flags) to disable the default path. In this case, the transaction can only execute using the paths explicitly included in the transaction. Traders can use this option to take arbitrage opportunities. You can use the [`tfNoDirectRipple` flag](transactions.html#payment-flags) to disable the default path. In this case, the transaction can only execute using the paths explicitly included in the transaction. Traders can use this option to take arbitrage opportunities.
@@ -64,9 +65,9 @@ A path set is an array. Each member of the path set is another array that repres
| Field | Value | Description | | Field | Value | Description |
|-------|-------|-------------| |-------|-------|-------------|
| account | String - Address | (Optional) If present, this path step represents rippling through the specified account. | | account | String - Address | (Optional) If present, this path step represents rippling through the specified account. |
| currency | String - currency code | (Optional) If present, this path step represents changing currencies through an order book. | | currency | String - currency code | (Optional) If present, this path step represents changing currencies through an order book. The currency specified indicates the new currency. |
| issuer | String - Address | (Optional) If the path step represents changing currencies through an order book, this field indicates the issuer of the new currency. This field is not present when changing to XRP. | | issuer | String - Address | (Optional) If the path step represents changing currencies through an order book, this field indicates the issuer of the new currency. This field is not present when changing to XRP. |
| type | Integer | **DEPRECATED**: An indicator of which other fields are present. The value `1` indicates rippling to another account. The values `16` indicates a currency change to XRP through an order book. The value `48` indicates a currency change, with a new issuer, through an order book. | | type | Integer | **DEPRECATED**: An indicator of which other fields are present. |
| type_hex | String | **DEPRECATED**: A hexadecimal representation of the `type` field. | | type_hex | String | **DEPRECATED**: A hexadecimal representation of the `type` field. |
The `type` field, used for the binary serialization of a path set, is actually constructed through bitwise operations on a single integer. The bits are defined as follows: The `type` field, used for the binary serialization of a path set, is actually constructed through bitwise operations on a single integer. The bits are defined as follows: