Skip to content

Commit

Permalink
add ut_define
Browse files Browse the repository at this point in the history
  • Loading branch information
haipome committed Sep 13, 2017
1 parent 8b9e603 commit d00c09a
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 29 deletions.
1 change: 1 addition & 0 deletions marketprice/mp_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
# include "ut_kafka.h"
# include "ut_signal.h"
# include "ut_config.h"
# include "ut_define.h"
# include "ut_decimal.h"
# include "ut_rpc_clt.h"
# include "ut_rpc_svr.h"
Expand Down
4 changes: 2 additions & 2 deletions marketprice/mp_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ static int market_update(const char *market, double timestamp, mpd_t *price, mpd
json_object_set_new(deal, "time", json_real(timestamp));
json_object_set_new_mpd(deal, "price", price);
json_object_set_new_mpd(deal, "amount", amount);
if (side == MARKET_SIDE_SELL) {
if (side == MARKET_ORDER_SIDE_ASK) {
json_object_set_new(deal, "type", json_string("sell"));
} else {
json_object_set_new(deal, "type", json_string("buy"));
Expand Down Expand Up @@ -503,7 +503,7 @@ static void on_deals_message(sds message, int64_t offset)
goto cleanup;
}
int side = json_integer_value(json_array_get(obj, 10));
if (side != MARKET_SIDE_SELL && side != MARKET_SIDE_BUY) {
if (side != MARKET_ORDER_SIDE_ASK && side != MARKET_ORDER_SIDE_BID) {
goto cleanup;
}
uint64_t id = json_integer_value(json_array_get(obj, 11));
Expand Down
6 changes: 2 additions & 4 deletions marketprice/mp_message.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
# ifndef _MP_MESSAGE_H_
# define _MP_MESSAGE_H_

# define MARKET_SIDE_SELL 1
# define MARKET_SIDE_BUY 2
# include "mp_config.h"

# define MARKET_DEALS_MAX 10000
# define MARKET_NAME_MAX 12

# include "mp_config.h"

int init_message(void);
bool market_exist(const char *market);

Expand Down
28 changes: 16 additions & 12 deletions matchengine/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,41 +76,43 @@
"money": {
"name": "CNY",
"prec": 2
}
},
"min_amount": "0.001"
}, {
"name": "ETHCNY",
"name": "BCCCNY",
"stock": {
"name": "ETH",
"name": "BCC",
"prec": 4
},
"money": {
"name": "CNY",
"prec": 2
}
},
"min_amount": "0.001"
}, {
"name": "ZECCNY",
"name": "ETHCNY",
"stock": {
"name": "ZEC",
"name": "ETH",
"prec": 4
},
"money": {
"name": "CNY",
"prec": 2
}
}, {
"name": "LTCCNY",
"name": "ZECCNY",
"stock": {
"name": "LTC",
"name": "ZEC",
"prec": 4
},
"money": {
"name": "CNY",
"prec": 2
}
}, {
"name": "BCCCNY",
"name": "LTCCNY",
"stock": {
"name": "BCC",
"name": "LTC",
"prec": 4
},
"money": {
Expand All @@ -136,7 +138,8 @@
"money": {
"name": "BTC",
"prec": 8
}
},
"min_amount": "0.001"
}, {
"name": "LTCBTC",
"stock": {
Expand Down Expand Up @@ -176,7 +179,8 @@
"money": {
"name": "BCC",
"prec": 8
}
},
"min_amount": "0.001"
}, {
"name": "LTCBCC",
"stock": {
Expand Down
1 change: 1 addition & 0 deletions matchengine/me_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
# include "ut_list.h"
# include "ut_mysql.h"
# include "ut_signal.h"
# include "ut_define.h"
# include "ut_config.h"
# include "ut_decimal.h"
# include "ut_rpc_clt.h"
Expand Down
2 changes: 0 additions & 2 deletions matchengine/me_history.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

# include "me_market.h"

# define HISTORY_HASH_NUM 100

int init_history(void);
int fini_history(void);

Expand Down
9 changes: 0 additions & 9 deletions matchengine/me_market.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@
extern uint64_t order_id_start;
extern uint64_t deals_id_start;

# define MARKET_ORDER_TYPE_LIMIT 1
# define MARKET_ORDER_TYPE_MARKET 2

# define MARKET_ORDER_SIDE_ASK 1
# define MARKET_ORDER_SIDE_BID 2

# define MARKET_ROLE_MAKER 1
# define MARKET_ROLE_TAKER 2

typedef struct order_t {
uint64_t id;
uint32_t type;
Expand Down
22 changes: 22 additions & 0 deletions utils/ut_define.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Description:
* History: yang@haipo.me, 2017/09/13, create
*/


# ifndef _UT_DEFINE_H_
# define _UT_DEFINE_H_

# define MARKET_ORDER_TYPE_LIMIT 1
# define MARKET_ORDER_TYPE_MARKET 2

# define MARKET_ORDER_SIDE_ASK 1
# define MARKET_ORDER_SIDE_BID 2

# define MARKET_ROLE_MAKER 1
# define MARKET_ROLE_TAKER 2

# define HISTORY_HASH_NUM 100

# endif

0 comments on commit d00c09a

Please sign in to comment.