Skip to content

Commit

Permalink
Merge branch 'omnicore-0.0.10' of github.com:OmniLayer/omnicore into …
Browse files Browse the repository at this point in the history
…0.0.10-Z-UI
  • Loading branch information
zathras-crypto committed Apr 28, 2015
2 parents 5f09ebd + 829eabe commit 543dcd1
Show file tree
Hide file tree
Showing 15 changed files with 483 additions and 397 deletions.
2 changes: 2 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ OMNICORE_H = \
mastercore_convert.h \
mastercore_dex.h \
mastercore_errors.h \
mastercore_log.h \
mastercore_parse_string.h \
mastercore_rpc.h \
mastercore_script.h \
Expand All @@ -169,6 +170,7 @@ OMNICORE_CPP = \
mastercore.cpp \
mastercore_convert.cpp \
mastercore_dex.cpp \
mastercore_log.cpp \
mastercore_parse_string.cpp \
mastercore_rpc.cpp \
mastercore_script.cpp \
Expand Down
11 changes: 7 additions & 4 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ enum BindFlags {
static const char* FEE_ESTIMATES_FILENAME="fee_estimates.dat";
CClientUIInterface uiInterface;

/** Omni Core initialization and shutdown handler */
int mastercore_init(void);
int mastercore_shutdown(void);
// Omni Core initialization and shutdown handlers
int mastercore_init();
int mastercore_shutdown();

//////////////////////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -217,6 +217,7 @@ void HandleSIGTERM(int)
void HandleSIGHUP(int)
{
fReopenDebugLog = true;
fReopenOmniCoreLog = true;
}

bool static InitError(const std::string &str)
Expand Down Expand Up @@ -1104,7 +1105,9 @@ bool AppInit2(boost::thread_group& threadGroup)

// ********************************************************* Step 7.5: load omni core

uiInterface.InitMessage(_("Performing out of order block detection..."));
#ifndef ENABLE_WALLET
bool fDisableWallet = true;
#endif

if (fDisableWallet) {
return InitError(_(
Expand Down
400 changes: 129 additions & 271 deletions src/mastercore.cpp

Large diffs are not rendered by default.

80 changes: 15 additions & 65 deletions src/mastercore.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
class CBlockIndex;
class CTransaction;

#include "mastercore_log.h"

#include "sync.h"
#include "tinyformat.h"
#include "uint256.h"
#include "util.h"

Expand All @@ -21,7 +22,6 @@ class CTransaction;
#include "json/json_spirit_value.h"

#include <stdint.h>
#include <stdio.h>

#include <map>
#include <string>
Expand All @@ -31,11 +31,6 @@ using json_spirit::Array;

using std::string;


#define LOG_FILENAME "mastercore.log"
#define INFO_FILENAME "mastercore_crowdsales.log"
#define OWNERS_FILENAME "mastercore_owners.log"

int const MAX_STATE_HISTORY = 50;

#define TEST_ECO_PROPERTY_1 (0x80000003UL)
Expand Down Expand Up @@ -149,50 +144,6 @@ enum FILETYPES {
#define OMNI_PROPERTY_MSC 1
#define OMNI_PROPERTY_TMSC 2

int mp_LogPrintStr(const std::string &str);

/* When we switch to C++11, this can be switched to variadic templates instead
* of this macro-based construction (see tinyformat.h).
*/
#define MP_MAKE_ERROR_AND_LOG_FUNC(n) \
/* Print to debug.log if -debug=category switch is given OR category is NULL. */ \
template<TINYFORMAT_ARGTYPES(n)> \
static inline int mp_category_log(const char* category, const char* format, TINYFORMAT_VARARGS(n)) \
{ \
if(!LogAcceptCategory(category)) return 0; \
return mp_LogPrintStr(tfm::format(format, TINYFORMAT_PASSARGS(n))); \
} \
template<TINYFORMAT_ARGTYPES(n)> \
static inline int mp_log(TINYFORMAT_VARARGS(n)) \
{ \
return mp_LogPrintStr(tfm::format("%s", TINYFORMAT_PASSARGS(n))); \
} \
template<TINYFORMAT_ARGTYPES(n)> \
static inline int mp_log(const char* format, TINYFORMAT_VARARGS(n)) \
{ \
return mp_LogPrintStr(tfm::format(format, TINYFORMAT_PASSARGS(n))); \
} \
template<TINYFORMAT_ARGTYPES(n)> \
static inline int file_log(const char* format, TINYFORMAT_VARARGS(n)) \
{ \
return mp_LogPrintStr(tfm::format(format, TINYFORMAT_PASSARGS(n))); \
} \
template<TINYFORMAT_ARGTYPES(n)> \
static inline int file_log(TINYFORMAT_VARARGS(n)) \
{ \
return mp_LogPrintStr(tfm::format("%s", TINYFORMAT_PASSARGS(n))); \
} \
/* Log error and return false */ \
template<TINYFORMAT_ARGTYPES(n)> \
static inline bool mp_error(const char* format, TINYFORMAT_VARARGS(n)) \
{ \
mp_LogPrintStr("ERROR: " + tfm::format(format, TINYFORMAT_PASSARGS(n)) + "\n"); \
return false; \
}

TINYFORMAT_FOREACH_ARGNUM(MP_MAKE_ERROR_AND_LOG_FUNC)
//--- CUT HERE ---

// forward declarations
std::string FormatPriceMP(double n);
std::string FormatDivisibleMP(int64_t n, bool fSign = false);
Expand All @@ -203,12 +154,8 @@ int64_t feeCheck(const string &address);

const std::string ExodusAddress();

extern int msc_debug_ui;

extern CCriticalSection cs_tally;

extern const int msc_debug_dex;

enum TallyType { BALANCE = 0, SELLOFFER_RESERVE = 1, ACCEPT_RESERVE = 2, PENDING = 3, METADEX_RESERVE = 4, TALLY_TYPE_COUNT };

class CMPTally
Expand Down Expand Up @@ -303,12 +250,12 @@ typedef struct

if (bDivisible)
{
printf("%22s [SO_RESERVE= %22s , ACCEPT_RESERVE= %22s ] %22s\n",
FormatDivisibleMP(money, true).c_str(), FormatDivisibleMP(so_r, true).c_str(), FormatDivisibleMP(a_r, true).c_str(), FormatDivisibleMP(pending, true).c_str());
PrintToConsole("%22s [SO_RESERVE= %22s , ACCEPT_RESERVE= %22s ] %22s\n",
FormatDivisibleMP(money, true), FormatDivisibleMP(so_r, true), FormatDivisibleMP(a_r, true), FormatDivisibleMP(pending, true));
}
else
{
printf("%14lu [SO_RESERVE= %14lu , ACCEPT_RESERVE= %14lu ] %14ld\n", money, so_r, a_r, pending);
PrintToConsole("%14lu [SO_RESERVE= %14lu , ACCEPT_RESERVE= %14lu ] %14ld\n", money, so_r, a_r, pending);
}

return (money + so_r + a_r);
Expand Down Expand Up @@ -353,7 +300,7 @@ class CMPSTOList
iteroptions.fill_cache = false;
syncoptions.sync = true;
leveldb::Status status = leveldb::DB::Open(options, path.string(), &sdb);
printf("%s(): %s, line %d, file: %s\n", __FUNCTION__, status.ToString().c_str(), __LINE__, __FILE__);
PrintToConsole("Loading send-to-owners database: %s\n", status.ToString());
}

~CMPSTOList()
Expand Down Expand Up @@ -396,7 +343,7 @@ class CMPTradeList
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__);
PrintToConsole("Loading trades database: %s\n", status.ToString());
}

~CMPTradeList()
Expand Down Expand Up @@ -452,8 +399,7 @@ class CMPTxList
syncoptions.sync = true;

leveldb::Status status = leveldb::DB::Open(options, path.string(), &pdb);

printf("%s(): %s, line %d, file: %s\n", __FUNCTION__, status.ToString().c_str(), __LINE__, __FILE__);
PrintToConsole("Loading transactions database: %s\n", status.ToString());
}

~CMPTxList()
Expand Down Expand Up @@ -496,7 +442,7 @@ class CMPPending

void print(uint256 txid) const
{
printf("%s : %s %d %ld %ld %s\n", txid.GetHex().c_str(), src.c_str(), prop, amount, type, desc.c_str());
PrintToConsole("%s : %s %d %ld %ld %s\n", txid.GetHex(), src, prop, amount, type, desc);
}

};
Expand All @@ -509,14 +455,18 @@ extern uint64_t global_balance_reserved_maineco[100000];
extern uint64_t global_balance_money_testeco[100000];
extern uint64_t global_balance_reserved_testeco[100000];

int mastercore_init(void);

int64_t getMPbalance(const string &Address, unsigned int property, TallyType ttype);
int64_t getUserAvailableMPbalance(const string &Address, unsigned int property);
bool IsMyAddress(const std::string &address);

string getLabel(const string &address);

/** Global handler to initialize Omni Core. */
int mastercore_init();

/** Global handler to shut down Omni Core. */
int mastercore_shutdown();

int mastercore_handler_disc_begin(int nBlockNow, CBlockIndex const * pBlockIndex);
int mastercore_handler_disc_end(int nBlockNow, CBlockIndex const * pBlockIndex);
int mastercore_handler_block_begin(int nBlockNow, CBlockIndex const * pBlockIndex);
Expand Down
5 changes: 2 additions & 3 deletions src/mastercore_dex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "mastercore.h"
#include "mastercore_convert.h"
#include "mastercore_errors.h"
#include "mastercore_log.h"
#include "mastercore_tx.h"

#include "main.h"
Expand Down Expand Up @@ -32,8 +33,6 @@ using std::string;
using namespace mastercore;


extern int msc_debug_metadex1, msc_debug_metadex2, msc_debug_metadex3;

md_PropertiesMap mastercore::metadex;

md_PricesMap* mastercore::get_Prices(unsigned int prop)
Expand Down Expand Up @@ -320,7 +319,7 @@ void mastercore::MetaDEx_debug_print(bool bShowPriceLevel, bool bDisplay)
{
CMPMetaDEx obj = *it;

if (bDisplay) printf("%s= %s\n", price.str(DISPLAY_PRECISION_LEN, std::ios_base::fixed).c_str() , obj.ToString().c_str());
if (bDisplay) PrintToConsole("%s= %s\n", price.str(DISPLAY_PRECISION_LEN, std::ios_base::fixed) , obj.ToString());
else file_log("%s= %s\n", price.str(DISPLAY_PRECISION_LEN, std::ios_base::fixed) , obj.ToString());

// extra checks: price or either of the amounts is 0
Expand Down
1 change: 1 addition & 0 deletions src/mastercore_dex.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define _MASTERCOIN_DEX 1

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

#include "main.h"
#include "tinyformat.h"
Expand Down
Loading

0 comments on commit 543dcd1

Please sign in to comment.