BuildOnViction / tomochain-v1

The efficient blockchain for the token economy
https://tomochain.com
GNU Lesser General Public License v3.0
51 stars 22 forks source link

Improve orderlist key & slot #600

Closed ngtuna closed 5 years ago

ngtuna commented 5 years ago

https://github.com/tomochain/tomochain/blob/tomoX/tomox/orderlist.go#L68

Current

Key (in RBT & DB) = big.Int(OT.slot + price) -> to BigToHash.Bytes() Slot:

if orderTree.orderBook != nil {
        orderList.slot = orderTree.orderBook.Slot
} else {
    orderList.slot = new(big.Int).SetBytes(crypto.Keccak256(key))
}

Expect Key (in RBT) = price Key (in DB) = []byte(pairName) + key (in RBT) Slot = key.ToBigInt

ngtuna commented 5 years ago

After carefully investigating, we decided to keep Key in both RBT and DB are the same that is []byte(pairName) + key (in RBT) as []byte(pairName) converted to bigInt added same amount to all nodes so that it doesn't affect the comparator function of RBT

ngtuna commented 5 years ago

Fixed at #602