From cca5421aedf9c1c0ae4339a10d7ec2a5c072bb12 Mon Sep 17 00:00:00 2001 From: Tom Ritchford Date: Fri, 2 Jan 2015 14:54:35 -0500 Subject: [PATCH] Fix Subscribe RPC to correctly distinguish bids and asks. --- src/ripple/protocol/Book.h | 6 ++++++ src/ripple/rpc/handlers/Subscribe.cpp | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ripple/protocol/Book.h b/src/ripple/protocol/Book.h index 3a095c4f1..86ba29d5b 100644 --- a/src/ripple/protocol/Book.h +++ b/src/ripple/protocol/Book.h @@ -94,6 +94,12 @@ void hash_append (Hasher& h, BookType const& b) hash_append (h, b.in, b.out); } +template +BookType reversed (BookType const& book) +{ + return BookType (book.out, book.in); +} + /** Ordered comparison. */ template int compare (BookType const& lhs, diff --git a/src/ripple/rpc/handlers/Subscribe.cpp b/src/ripple/rpc/handlers/Subscribe.cpp index 549fcab70..3cf2aa5b4 100644 --- a/src/ripple/rpc/handlers/Subscribe.cpp +++ b/src/ripple/rpc/handlers/Subscribe.cpp @@ -322,7 +322,7 @@ Json::Value doSubscribe (RPC::Context& context) context.netOps.getBookPage ( context.role == Role::ADMIN, - lpLedger, book, raTakerID.getAccountID (), + lpLedger, reverse (book), raTakerID.getAccountID (), false, 0, jvMarker, jvAsks); if (jvAsks.isMember (jss::offers))