ripple / ripple-lib-extensions

[Deprecated] A collection of extensions to ripple-lib. Instead, see https://github.com/XRPLF/xrpl.js
https://github.com/XRPLF/xrpl.js
22 stars 31 forks source link

[Orderbook] - 'transaction' and 'trade' event - unexpected behavior #28

Open flxh opened 7 years ago

flxh commented 7 years ago

The orderbook subscribes to the transaction stream of the rippled server. So all the transactions that are validated on the RCL are received by the the orderbook. I double checked everything but I cannot find any line of code that separates the transactions and trades that belong to the book from the ones that don't.

I don't think this is intended because the callback for the trade event only has to numbers as parameter (TakerGets, and TakerPays amount). If the listener receives random trades and you can't even tell which asset pair it belongs to that would be pretty useless.

Also I used the code that parses the exchanges for the historical-database and passed all the transactions from the transaction stream (without the orderbook api). Then I added a little filter to remove all the transactions that don't belong to my pair (USD-XRP e.g) and still the orderbook trade event gave me more events than I got from the parser with the filter. That was another point that seems suspicious

shekenahglory commented 7 years ago

The transaction metadata gets filtered according to the orderbook's key pair by OrderBookUtils.getAffectedNodes here: https://github.com/ripple/ripple-lib-extensions/blob/master/orderbook/src/orderbook.js#L505

If you can find a specific transaction + that is being included in the trade event but not from exchanges parsing, please provide a transaction hash and any other details that well help me investigate further.

flxh commented 7 years ago

https://gist.github.com/flxh/24048fd73be2847e466013b4a9574947

I used this little script. You can see all the messages that are logged as JSON (the parsed exchanges) align perfectly with the transactions from the ripplecharts feed. Some of the exchanges from the trade event however seem to be missing while others seem to be too much.