Skip to content

Commit

Permalink
Refine omnicore_pending includes
Browse files Browse the repository at this point in the history
 - add missing
 - pass uint256 as const reference, not copy
 - use tinyformat specifiers
  • Loading branch information
dexX7 committed May 18, 2015
1 parent bffaeb0 commit c0d7654
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
14 changes: 10 additions & 4 deletions src/omnicore_pending.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
#include "omnicore_pending.h"

#include "mastercore.h"
#include "mastercore_log.h"

#include "uint256.h"

#include "json/json_spirit_value.h"
#include "json/json_spirit_writer_template.h"

#include <string>

using json_spirit::Object;
using json_spirit::Pair;
using json_spirit::Value;
Expand All @@ -14,7 +20,7 @@ using namespace mastercore;
/**
* Adds a transaction to the pending map using supplied parameters
*/
void PendingAdd(const uint256 txid, const std::string& sendingAddress, const std::string& refAddress, uint16_t type, uint32_t propertyId, int64_t amount, uint32_t propertyIdDesired, int64_t amountDesired, int64_t action)
void PendingAdd(const uint256& txid, const std::string& sendingAddress, const std::string& refAddress, uint16_t type, uint32_t propertyId, int64_t amount, uint32_t propertyIdDesired, int64_t amountDesired, int64_t action)
{
Object txobj;
std::string amountStr, amountDStr;
Expand Down Expand Up @@ -64,7 +70,7 @@ void PendingAdd(const uint256 txid, const std::string& sendingAddress, const std
}
std::string txDesc = write_string(Value(txobj), false);
CMPPending pending;
if (msc_debug_pending) file_log("%s(%s,%s,%s,%d,%u,%ld,%u,%ld,%d,%s)\n", __FUNCTION__, txid.GetHex().c_str(), sendingAddress.c_str(), refAddress.c_str(),
if (msc_debug_pending) file_log("%s(%s,%s,%s,%d,%u,%ld,%u,%ld,%d,%s)\n", __FUNCTION__, txid.GetHex(), sendingAddress, refAddress,
type, propertyId, amount, propertyIdDesired, amountDesired, action, txDesc);
if (update_tally_map(sendingAddress, propertyId, -amount, PENDING)) {
pending.src = sendingAddress;
Expand All @@ -81,13 +87,13 @@ void PendingAdd(const uint256 txid, const std::string& sendingAddress, const std
*
* NOTE: this is currently called for every bitcoin transaction prior to running through the parser
*/
void PendingDelete(const uint256 txid)
void PendingDelete(const uint256& txid)
{
PendingMap::iterator it = my_pending.find(txid);
if (it != my_pending.end()) {
CMPPending *p_pending = &(it->second);
int64_t src_amount = getMPbalance(p_pending->src, p_pending->prop, PENDING);
if (msc_debug_pending) file_log("%s(%s): amount=%ld\n", __FUNCTION__, txid.GetHex().c_str(), src_amount);
if (msc_debug_pending) file_log("%s(%s): amount=%d\n", __FUNCTION__, txid.GetHex(), src_amount);
if (src_amount) update_tally_map(p_pending->src, p_pending->prop, p_pending->amount, PENDING);
my_pending.erase(it);
}
Expand Down
9 changes: 6 additions & 3 deletions src/omnicore_pending.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#ifndef OMNICORE_PENDING_H
#define OMNICORE_PENDING_H

#include "uint256.h"
class uint256;

#include <stdint.h>
#include <string>

/** Adds a transaction to the pending map using supplied parameters. */
void PendingAdd(const uint256 txid, const std::string& sendingAddress, const std::string& refAddress, uint16_t type, uint32_t propertyId, int64_t amount, uint32_t propertyIdDesired = 0, int64_t amountDesired = 0, int64_t action = 0);
void PendingAdd(const uint256& txid, const std::string& sendingAddress, const std::string& refAddress, uint16_t type, uint32_t propertyId, int64_t amount, uint32_t propertyIdDesired = 0, int64_t amountDesired = 0, int64_t action = 0);

/** Deletes a transaction from the pending map and credits the amount back to the pending tally for the address. */
void PendingDelete(const uint256 txid);
void PendingDelete(const uint256& txid);

#endif // OMNICORE_PENDING_H

Expand Down

0 comments on commit c0d7654

Please sign in to comment.