Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autobridging Pt. 1 #359

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ if not OSX:
'-pthread',
])

DEBUGFLAGS = ['-g', '-DDEBUG', '-D_DEBUG']
DEBUGFLAGS = ['-g', '-ggdb', '-DDEBUG', '-D_DEBUG']

env.Append(CCFLAGS = ['-pthread', '-Wall', '-Wno-sign-compare', '-Wno-char-subscripts']+DEBUGFLAGS)
if not USING_CLANG:
Expand All @@ -342,7 +342,7 @@ else:
env.Append(CCFLAGS = more_warnings)

# add '-Wconversion' some day
env.Append(CXXFLAGS = ['-O3', '-fno-strict-aliasing', '-pthread', '-Wno-invalid-offsetof', '-Wformat']+more_warnings+DEBUGFLAGS)
env.Append(CXXFLAGS = ['-O0', '-fno-strict-aliasing', '-pthread', '-Wno-invalid-offsetof', '-Wformat']+more_warnings+DEBUGFLAGS)

# RTTI is required for Beast and CountedObject.
#
Expand Down
2 changes: 1 addition & 1 deletion src/BeastConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ This determines whether to add any features to the proposed transaction set.
This determines whether ripple uses the legacy OfferCreate transactor.
*/
#ifndef RIPPLE_USE_OLD_CREATE_TRANSACTOR
#define RIPPLE_USE_OLD_CREATE_TRANSACTOR 1
#define RIPPLE_USE_OLD_CREATE_TRANSACTOR 0
#endif

#endif
11 changes: 11 additions & 0 deletions src/ripple_app/book/Offer.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@ class Offer
m_entry->getFieldAmount (sfTakerGets));
}

/** Returns true if either the in or out amounts of this offer are 0. */
bool
fully_consumed() const noexcept
{
if (m_entry->getFieldAmount (sfTakerPays) == zero)
return true;
if (m_entry->getFieldAmount (sfTakerGets) == zero)
return true;
return false;
}

/** Returns the ledger entry underlying the offer. */
// AVOID USING THIS
SLE::pointer
Expand Down
108 changes: 32 additions & 76 deletions src/ripple_app/book/OfferStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,25 +118,25 @@ class OfferStream
}

LedgerView&
view() noexcept
view () noexcept
{
return m_view;
}

LedgerView&
view_cancel() noexcept
view_cancel () noexcept
{
return m_view_cancel;
}

Book const&
book() const noexcept
book () const noexcept
{
return m_book;
}

uint256 const&
dir() const noexcept
dir () const noexcept
{
return m_tip.dir();
}
Expand All @@ -146,7 +146,7 @@ dir() const noexcept
Only valid if step() returned `true`.
*/
Offer const&
tip() const
tip () const
{
return m_offer;
}
Expand All @@ -159,7 +159,7 @@ dir() const noexcept
@return `true` if there is a valid offer.
*/
bool
step()
step ()
{
// Modifying the order or logic of these
// operations causes a protocol breaking change.
Expand Down Expand Up @@ -233,92 +233,48 @@ dir() const noexcept
continue;
}

#if 0
// Remove if its our own offer
//
// VFALCO NOTE We might not want this for payments
//
if (m_account == owner)
{
view_cancel().offerDelete (entry->getIndex());
if (m_journal.trace) m_journal.trace <<
"Removing self offer " << entry->getIndex();
continue;
}
#endif

break;
}

return true;
}

/** Updates the offer to reflect remaining funds.
The caller is responsible for following all the rounding rules.
The offer will be considered fully consumed if either the in
or the out amount is zero.
@return `true` If the offer had no funds remaining.
/** Advance to the next valid offer that is not from the specified account.
This automatically removes:
- Offers with missing ledger entries
- Offers found unfunded
- expired offers
@return `true` if there is a valid offer.
*/
bool
fill (Amounts const& remaining_funds)
step_account (Account const& account)
{
// Erase the offer if it is fully consumed (in==0 || out==0)
// This is the same as becoming unfunded
while (step ())
{
if (tip ().account () != account)
return true;
}

return false;
}
};

//------------------------------------------------------------------------------

/**
Does everything an OfferStream does, and:
- remove offers that became unfunded (if path is used)
*/
#if 0
class PaymentOfferStream : public OfferStream
{
public:
PaymentOfferStream (LedgerView& view_base, BookRef book,
Clock::time_point when, beast::Journal journal)
: m_journal (journal)
, m_view (view_base.duplicate())
, m_view_apply (view_base.duplicate())
, m_book (book)
, m_when (when)
{
}
/** Updates the offer to reflect remaining funds.
The caller is responsible for following all the rounding rules.
The offer will be considered fully consumed if either the in
or the out amount is zero.
@return `true` If the offer had no funds remaining.
*/
// bool
// fill (Amounts const& remaining_funds)
// {
// // Erase the offer if it is fully consumed (in==0 || out==0)
// // This is the same as becoming unfunded
// return false;
// }
};
#endif

//------------------------------------------------------------------------------

/*
TakerOfferStream
Does everything a PaymentOfferStream does, and:
- remove offers owned by the taker (if tx succeeds?)
*/

//------------------------------------------------------------------------------

//------------------------------------------------------------------------------

}
}

/*
OfferStream
- remove offers with missing ledger entries (always)
- remove expired offers (always)
- remove offers found unfunded (always)

PaymentOfferStream
Does everything an OfferStream does, and:
- remove offers that became unfunded (if path is used)

TakerOfferStream
Does everything a PaymentOfferStream does, and:
- remove offers owned by the taker (if tx succeeds?)
*/

#endif

2 changes: 1 addition & 1 deletion src/ripple_app/book/Quality.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class Quality

/** Returns the quality as Amount. */
Amount
rate() const
rate () const
{
return Amount::setRate (m_value);
}
Expand Down
Loading