Order Collision

Adrien-VAdrien-V Member Posts: 11
Following the code below.
Let's define A and B two users of the contract on two different nodes.
Just A and B are using the contract.

At the instant t, A and B see the same orderbook (OB):

[ Ask ]
(1)1k @ 30
(2)[email protected]

[ Bid ]
(11)[email protected]
(22)[email protected]

(Tx1) At t+1s, B wants some apples and puts the following order BID[[email protected]] to match (1), this order is matched by a routine, B get some apples and the issuer of the Ask get some Ether, the Ask and the Bid are removed from the OB.

---Assuming the block with the tx Tx1 is not yet mined--

(Tx2) At t+7s A still have the same OB and wants to match (1) .He puts the following BID[[email protected]] .
??? This order is also matched by the routine, A gets some apples and the issuer of the Ask get some Ether, the Ask and the Bid are removed from the OB ???

At t+15s a block is mined with the txs Tx1 Tx2.


Q1: Does the descriptions above is correct ?

Q2: What's happen for the execution of Tx2 ?

Q3:Did I miss something obvious ?


contract AppleMarket
event OrderPlaced(/*......*/);
event OrderCancelled(/*.....*/);
event OrderMatched(/*.... */);

function PlaceOrder(uint price, uint amount,uint way)

function CancelOrder(uint id)

function MatchOrder()

/* [****] */

mapping(uint => Order) orderBook;

struct Order
uint id;
uint price;//1K
uint amount;//Kilo
uint way; //0-> sell 1->buy
address issuer; // seller || buyer


  • Adrien-VAdrien-V Member Posts: 11

    So the only issues here are around the refreshment of the order book and potentially if a miner start to choose which transaction to execute first (huge issue actually ) ?
  • ppohjappohja Member Posts: 10
    edited September 2015
    So there's a need for 'what has be seen, cannot be unseen' consensus? A distributed consensus for which are the legitimate basis for leaving tx's out. E.g. its perfectly fine to leave those transactions out which do not specify high enough gascost. Although in this case the high-speed trader can underbid the original tx in apples' price and overbid him in gascost.

    Will it be a tick-tock model, where tick distributes tx's and tock presents solutions? Or more sophisticated way for peers rejecting blocks that do not include transactions that the miner has provably seen. Or something else?

    Post edited by ppohja on
  • Adrien-VAdrien-V Member Posts: 11
    I came up with a similar idea of a 'fair' market. I wondering if people are ok to give up on the rules first-come first served ?
Sign In or Register to comment.