Directory Node
The DirectoryNode
object type provides a list of links to other objects in the ledger's state tree. A single conceptual Directory takes the form of a doubly linked list, with one or more DirectoryNode objects each containing up to 32 IDs of other objects. The first object is called the root of the directory, and all objects other than the root object can be added or deleted as necessary.
There are two kinds of Directories:
Owner directories list other objects owned by an account, such as
RippleState
(trust line) orOffer
objects.Offer directories list the offers available in the decentralized exchange. A single Offer directory contains all the offers that have the same exchange rate for the same token (currency code and issuer).
Example JSON
Offer Directory
Owner Directory
Fields
Directory ID Formats
There are three different formulas for creating the ID of a DirectoryNode, depending on which of the following the DirectoryNode represents:
The first page (also called the root) of an Owner Directory
The first page of an Offer Directory
Later pages of either type
The first page of an Owner Directory has an ID that is the [SHA-512Half][] of the following values, concatenated in order:
The Owner Directory space key (
0x004F
)The AccountID from the
Owner
field.
The first page of an Offer Directory has a special ID: the higher 192 bits define the order book, and the remaining 64 bits define the exchange rate of the offers in that directory. (The ID is big-endian, so the book is in the more significant bits, which come first, and the quality is in the less significant bits which come last.)
This provides a way to iterate through an order book from best offers to worst. Specifically: the first 192 bits are the first 192 bits of the [SHA-512Half][] of the following values, concatenated in order:
The Book Directory space key (
0x0042
)The 160-bit currency code from the
TakerPaysCurrency
The 160-bit currency code from the
TakerGetsCurrency
The AccountID from the
TakerPaysIssuer
The AccountID from the
TakerGetsIssuer
The lower 64 bits of an Offer Directory's ID represent the TakerPays
amount divided by TakerGets
amount from the offer(s) in that directory as a 64-bit number in Xahau's internal amount format.
If the DirectoryNode is not the first page in the Directory (regardless of whether it is an Owner Directory or an Offer Directory), then it has an ID that is the [SHA-512Half][] of the following values, concatenated in order:
The DirectoryNode space key (
0x0064
)The ID of the root DirectoryNode
The page number of this object. (Since 0 is the root DirectoryNode, this value is an integer 1 or higher.)
Last updated