laboon / CS1699_Fall2018

CS1699 - BLOCKCHAIN TECHNOLOGY AND CRYPTOCURRENCY
MIT License
37 stars 19 forks source link

Deliverable 2: Sorting transactions #31

Closed rubenhorn closed 5 years ago

rubenhorn commented 5 years ago

The output of the miner program should include

  1. concat root of sorted transaction list

What criteria should we sort the transactions by? Fees? Ascending or descending?

From the example I'd assume ascending by fees:

1E4BLSFNZo14q8ec7w3J3Wp6njNd7rWxbx>10;1J3ZQJ3ZBjig677KmjdJjhcQizrm4ek1Az>6,14cCzg1Xw5edM3viuTqtgeFX4tRjCXTx1H>3
1AY7sesEcVihM5LR8Bw9WXv6bWSt7vKak4>30,1AY7sesEcVihM5LR8Bw9WXv6bWSt7vKak4>20;1EinGRFVjNuTwzPT7dZ3K9JwhAJM3qpn3U>45

Should the transaction list be output in the same order?

laboon commented 5 years ago

Great question!

This definitely should be in the same order, otherwise the hash will be different. Example:

Message:
AAAABBBB
Hash:
7bf52afd1d2eb936aaa7e54e67ae18b8fb24efb51e7edea259e6571b85614c96

Message:
BBBBAAAA
Hash:
93816e878685f6632fafca33486ddce51e5afa59aee49c604418feda4f27ad50

I did sort by fees but:

1) This was not specified. 2) This has the obvious issue of what happens when we have duplicate fees? I suppose we could say that for equal fees, the secondary sorting should be done ASCII-betically of the whole transaction.

However, there is a workaround here: I will assume that whatever order you printed out the transactions is is your sorted order. Let me know if you have any other issues.

+1 EC