@CfB:
Just to sure how it should be:
Since the bid order is coming at a later time than the ask orders, it should eat the ask orders at the price of the ask orders, right?
If not, how should the algorithm be?
U r right. But bid orders could come earlier also.
Then why, when determining the price at which orders match, is the code comparing some random hash value?
long price = askOrder.getHeight() < bidOrder.getHeight() || (askOrder.getHeight() == bidOrder.getHeight() && askOrder.getId() < bidOrder.getId()) ? askOrder.getPrice() : bidOrder.getPrice();
If all orders we are looking at are in the same block, the height of the orders are all the same.
The id of an order is the id of the transaction which is part of the hash value of the transaction. Seems like rolling a dice when determining the price.