mastercoin-MSC / mastercore

mastercore info
mastercoin.org
MIT License
24 stars 11 forks source link

Add trade history levelDB, trade_MP call, clean up MetaDex populateRPCTransactionObject #194

Closed zathras-crypto closed 9 years ago

zathras-crypto commented 9 years ago

1) gettransaction_MP now works for any metadex order not just open ones 2) populateRPCTransactionObject now parses off the wire for metadex just like all other types 3) new levelDB MP_tradelist 4) every completed trade added to tradelistDB with txids, addresses, properties, and amounts 5) new gettrade_MP call added 6) gettrade_MP will iter metadex map to determine if offer still active 7) new getMatchedTrades function added using tradelistDB to return all trades matched with a supplied txid 8) gettrade_MP will call getMatchedTrades and supply to user over RPC 9) mscrpc 7 function to dump tradelistDB

example http://pastie.org/pastes/9698921/text?key=a5n5cqglbd80c7tfytwgxw

dexX7 commented 9 years ago

That's pretty awesome. Will start some tests in a few minutes.

Sidenote: git rebase -i HEAD~26 can be used to combine (stash) some commits for easier code review (e.g. grouped into persistence, rpc, ...). Overwriting already pushed stuff is possible with -f in git push remotename -f branchname. That's of course no demand to do so, but might be useful from time to time. :)

ghost commented 9 years ago

this looks good to me ... @m21 to expedite ? so we can have usable functionality for the rest of the RPCs

dexX7 commented 9 years ago

Tested a few transactions, works great! I posted some comments inline.

The only thing I'm really not sure about is mastercore_rpc.cpp#L2125-L2133:

for (md_PricesMap::iterator it = prices.begin(); it != prices.end(); ++it)
{
    md_Set & indexes = (it->second);
    for (md_Set::iterator it = indexes.begin(); it != indexes.end(); ++it)
    {
         CMPMetaDEx obj = *it;
         if( obj.getHash().GetHex() == hash.GetHex() ) orderOpen = true;
    }
}

Declaring variables multiple times seems to be legal, but how do you get away with it?

The iterator it is declared two times here and both loops modify it.

m21 commented 9 years ago

They are local to the for-loops Dexx: http://stackoverflow.com/questions/7959573/declaring-variables-inside-loops-good-practice-or-bad-practice-2-parter

dexX7 commented 9 years ago

@m21: the link doesn't really nail it, but it makes sense and works. Interesting realization for me.. :)

See this example: http://ideone.com/pc8h37