-
Notifications
You must be signed in to change notification settings - Fork 8
Add trade history levelDB, trade_MP call, clean up MetaDex populateRPCTransactionObject #194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6fe1604
e319740
4cd8cee
04e531f
d52af25
9be4e4d
9818067
a1d0e0e
2b885cc
f88696b
301e728
9b45f2b
1aed41f
1e5ee2f
7ef27ea
dec1a1c
92fce2e
e0b54a4
ef56f88
bb7e4c5
fc2b334
c31699f
cf37df5
af21274
64c1192
951e687
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -290,6 +290,48 @@ typedef struct | |
| } | ||
| }; | ||
|
|
||
| /* leveldb-based storage for trade history - trades will be listed here atomically with key txid1:txid2 */ | ||
| class CMPTradeList | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably goes beyond the scope of this PR: I suggest to move those stuff into |
||
| { | ||
| protected: | ||
| // datebase options reused from MPTxList | ||
| leveldb::Options options; | ||
| leveldb::ReadOptions readoptions; | ||
| leveldb::ReadOptions iteroptions; | ||
| leveldb::WriteOptions writeoptions; | ||
| leveldb::WriteOptions syncoptions; | ||
| leveldb::DB *tdb; | ||
| // statistics | ||
| unsigned int tWritten; | ||
| unsigned int tRead; | ||
|
|
||
| public: | ||
| CMPTradeList(const boost::filesystem::path &path, size_t nCacheSize, bool fMemory, bool fWipe):tWritten(0),tRead(0) | ||
| { | ||
| options.paranoid_checks = true; | ||
| options.create_if_missing = true; | ||
| readoptions.verify_checksums = true; | ||
| iteroptions.verify_checksums = true; | ||
| iteroptions.fill_cache = false; | ||
| syncoptions.sync = true; | ||
| leveldb::Status status = leveldb::DB::Open(options, path.string(), &tdb); | ||
| printf("%s(): %s, line %d, file: %s\n", __FUNCTION__, status.ToString().c_str(), __LINE__, __FILE__); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was printf used intentionally or should this line end up in the log? |
||
| } | ||
|
|
||
| ~CMPTradeList() | ||
| { | ||
| delete tdb; | ||
| tdb = NULL; | ||
| } | ||
|
|
||
| void recordTrade(const uint256 txid1, const uint256 txid2, string address1, string address2, unsigned int prop1, unsigned int prop2, uint64_t amount1, uint64_t amount2, int blockNum); | ||
| int deleteAboveBlock(int blockNum); | ||
| bool exists(const uint256 &txid); | ||
| void printStats(); | ||
| void printAll(); | ||
| bool getMatchingTrades(const uint256 txid, unsigned int propertyId, Array *tradeArray, uint64_t *totalBought); | ||
| }; | ||
|
|
||
| /* leveldb-based storage for the list of ALL Master Protocol TXIDs (key) with validity bit & other misc data as value */ | ||
| class CMPTxList | ||
| { | ||
|
|
@@ -402,6 +444,7 @@ namespace mastercore | |
| { | ||
| extern std::map<string, CMPTally> mp_tally_map; | ||
| extern CMPTxList *p_txlistdb; | ||
| extern CMPTradeList *t_tradelistdb; | ||
|
|
||
| typedef std::map<uint256, CMPPending> PendingMap; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imho it's more readable, if declaration and initialization are combined in this case (and the others), because you're using them just a few lines later anyway.