mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Add a function to check if a currency/issuer/currency/issuer set
defines a valid order book.
This commit is contained in:
@@ -1302,6 +1302,28 @@ std::vector< std::pair<uint32, uint256> > Ledger::getLedgerHashes()
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool Ledger::isValidBook(const uint160& uTakerPaysCurrency, const uint160& uTakerPaysIssuerID,
|
||||
const uint160& uTakerGetsCurrency, const uint160& uTakerGetsIssuerID)
|
||||
{
|
||||
if (uTakerPaysCurrency.isZero())
|
||||
{ // XRP in
|
||||
if (uTakerPaysIssuerID.isNonZero()) // XRP cannot have an issuer
|
||||
return false;
|
||||
if (uTakerGetsCurrency.isZero()) // XRP to XRP not allowed
|
||||
return false;
|
||||
if (uTakerGetsIssuerID.isZero()) // non-XRP must have issuer
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// non-XRP in
|
||||
if (uTakerPaysIssuerID.isZero()) // non-XRP must have issuer
|
||||
return false;
|
||||
if (uTakerGetsCurrency.isZero() != uTakerGetsIssuerID.isZero())
|
||||
return false; // XRP must have issuer, non-XRP must not
|
||||
return true;
|
||||
}
|
||||
|
||||
uint256 Ledger::getBookBase(const uint160& uTakerPaysCurrency, const uint160& uTakerPaysIssuerID,
|
||||
const uint160& uTakerGetsCurrency, const uint160& uTakerGetsIssuerID)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user