-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -493,10 +493,7 @@ int mastercore::MetaDEx_CANCEL_AT_PRICE(const uint256& txid, unsigned int block, | |
|
||
if (msc_debug_metadex2) MetaDEx_debug_print(); | ||
|
||
if (!prices) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
zathras-crypto
Author
Owner
|
||
PrintToLog("%s() NOTHING FOUND for %s\n", __FUNCTION__, mdex.ToString()); | ||
return rc -1; | ||
} | ||
int numCancelled = 0; | ||
|
||
// within the desired property map (given one property) iterate over the items | ||
for (md_PricesMap::iterator my_it = prices->begin(); my_it != prices->end(); ++my_it) { | ||
|
@@ -516,7 +513,6 @@ int mastercore::MetaDEx_CANCEL_AT_PRICE(const uint256& txid, unsigned int block, | |
continue; | ||
} | ||
|
||
rc = 0; | ||
PrintToLog("%s(): REMOVING %s\n", __FUNCTION__, p_mdex->ToString()); | ||
|
||
// move from reserve to main | ||
|
@@ -528,10 +524,16 @@ int mastercore::MetaDEx_CANCEL_AT_PRICE(const uint256& txid, unsigned int block, | |
p_txlistdb->recordMetaDExCancelTX(txid, p_mdex->getHash(), bValid, block, p_mdex->getProperty(), p_mdex->getAmountRemaining()); | ||
|
||
indexes->erase(iitt++); | ||
numCancelled++; | ||
} | ||
} | ||
|
||
if (msc_debug_metadex2) MetaDEx_debug_print(); | ||
PrintToLog("%s(): FOUND %d MATCHING TRADES.\n", __FUNCTION__, numCancelled); | ||
rc = 0; // cancels do not require matching trades to be valid | ||
|
||
if (numCancelled) { | ||
if (msc_debug_metadex2) MetaDEx_debug_print(); | ||
} | ||
|
||
return rc; | ||
} | ||
|
@@ -546,10 +548,7 @@ int mastercore::MetaDEx_CANCEL_ALL_FOR_PAIR(const uint256& txid, unsigned int bl | |
|
||
if (msc_debug_metadex3) MetaDEx_debug_print(); | ||
|
||
if (!prices) { | ||
This comment has been minimized.
Sorry, something went wrong. |
||
PrintToLog("%s() NOTHING FOUND\n", __FUNCTION__); | ||
return rc -1; | ||
} | ||
int numCancelled = 0; | ||
|
||
// within the desired property map (given one property) iterate over the items | ||
for (md_PricesMap::iterator my_it = prices->begin(); my_it != prices->end(); ++my_it) { | ||
|
@@ -565,7 +564,6 @@ int mastercore::MetaDEx_CANCEL_ALL_FOR_PAIR(const uint256& txid, unsigned int bl | |
continue; | ||
} | ||
|
||
rc = 0; | ||
PrintToLog("%s(): REMOVING %s\n", __FUNCTION__, p_mdex->ToString()); | ||
|
||
// move from reserve to main | ||
|
@@ -577,10 +575,16 @@ int mastercore::MetaDEx_CANCEL_ALL_FOR_PAIR(const uint256& txid, unsigned int bl | |
p_txlistdb->recordMetaDExCancelTX(txid, p_mdex->getHash(), bValid, block, p_mdex->getProperty(), p_mdex->getAmountRemaining()); | ||
|
||
indexes->erase(iitt++); | ||
numCancelled++; | ||
} | ||
} | ||
|
||
if (msc_debug_metadex3) MetaDEx_debug_print(); | ||
PrintToLog("%s(): FOUND %d MATCHING TRADES.\n", __FUNCTION__, numCancelled); | ||
rc = 0; // cancels do not require matching trades to be valid | ||
|
||
if (numCancelled) { | ||
if (msc_debug_metadex3) MetaDEx_debug_print(); | ||
} | ||
|
||
return rc; | ||
} | ||
|
@@ -596,6 +600,8 @@ int mastercore::MetaDEx_CANCEL_EVERYTHING(const uint256& txid, unsigned int bloc | |
|
||
if (msc_debug_metadex2) MetaDEx_debug_print(); | ||
|
||
int numCancelled = 0; | ||
|
||
PrintToLog("<<<<<<\n"); | ||
|
||
for (md_PropertiesMap::iterator my_it = metadex.begin(); my_it != metadex.end(); ++my_it) { | ||
|
@@ -622,7 +628,6 @@ int mastercore::MetaDEx_CANCEL_EVERYTHING(const uint256& txid, unsigned int bloc | |
continue; | ||
} | ||
|
||
rc = 0; | ||
PrintToLog("%s(): REMOVING %s\n", __FUNCTION__, it->ToString()); | ||
|
||
// move from reserve to balance | ||
|
@@ -634,12 +639,18 @@ int mastercore::MetaDEx_CANCEL_EVERYTHING(const uint256& txid, unsigned int bloc | |
p_txlistdb->recordMetaDExCancelTX(txid, it->getHash(), bValid, block, it->getProperty(), it->getAmountRemaining()); | ||
|
||
indexes.erase(it++); | ||
numCancelled++; | ||
} | ||
} | ||
} | ||
PrintToLog(">>>>>>\n"); | ||
|
||
if (msc_debug_metadex2) MetaDEx_debug_print(); | ||
PrintToLog("%s(): FOUND %d MATCHING TRADES.\n", __FUNCTION__, numCancelled); | ||
rc = 0; // cancels do not require matching trades to be valid | ||
|
||
if (numCancelled) { | ||
if (msc_debug_metadex2) MetaDEx_debug_print(); | ||
} | ||
|
||
return rc; | ||
} | ||
|
1 comment
on commit a751bef
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.
The NULL
checks should be added back, but otherwise ACK. Looks good. Can you create a PR? I'll run the old mastercore-rpc-tests
later, which have a bit more tests for the cancel operations (though they only verify the effect on balances, and don't test validity, but more tests are more tests nevertheless).
If I'm not mistaken, then this check also serves as
is not NULL
protection, and if there are no offers for the given property, thenprices
would beNULL
, as far as I can see:omnicore/src/omnicore/mdex.cpp
Line 39 in a751bef
omnicore/src/omnicore/mdex.cpp
Line 489 in a751bef