Commit c31719d0 authored by 1486327116's avatar 1486327116

format

parent e1d355f0
...@@ -129,7 +129,7 @@ export const pushToCoreSystem = async (id: any) => { ...@@ -129,7 +129,7 @@ export const pushToCoreSystem = async (id: any) => {
if (cfg) { if (cfg) {
let symbol = cfg.general_name; let symbol = cfg.general_name;
let optResult = await addCoin2Core(symbol); let optResult = await addCoin2Core(symbol,cfg.id);
if (optResult) { if (optResult) {
await coinType.prototype.update({ main_status: 1 }, { await coinType.prototype.update({ main_status: 1 }, {
where: where where: where
......
...@@ -75,8 +75,8 @@ export const pushToCoreSystem = async (id: any) => { ...@@ -75,8 +75,8 @@ export const pushToCoreSystem = async (id: any) => {
let quote = sps[1] let quote = sps[1]
let param = { let param = {
"base": base, "quote": quote, "symbol": symbol, "name": symbol, "base": base, "quote": quote, "symbol": symbol, "name": symbol,
"price-scale": cfg.price_scale, "quantity-scale": cfg.quantity_scale, "price_scale": cfg.price_scale, "quantity_scale": cfg.quantity_scale,
"maker-fee": cfg.maker_fee, "taker-fee": cfg.taker_fee "maker_fee": cfg.maker_fee, "taker_fee": cfg.taker_fee
} }
let optResult = await addPairToCore(param); let optResult = await addPairToCore(param);
if (optResult) { if (optResult) {
......
...@@ -89,12 +89,25 @@ export const getUserOrdersFromCore = async(params)=> { ...@@ -89,12 +89,25 @@ export const getUserOrdersFromCore = async(params)=> {
return data return data
} }
export const getUserOrderFromCore = async(orderId)=> {
// let params = new URLSearchParams();
const url = `${webadmin_endpoint}/order/list`
let { data } = await axios.get(url,{params});
if (data.error) {
logger.error("getPairFromCore",data);
return null
}
// console.log(data)
return data
}
// getUserOrdersFromCore({user_id:1}) // getUserOrdersFromCore({user_id:1})
export const addCoin2Core = async(symbol)=> { export const addCoin2Core = async(symbol,id)=> {
const url = `${webadmin_endpoint}/asset/add` const url = `${webadmin_endpoint}/asset/add`
let body = { let body = {
"symbol":symbol, "symbol":symbol,
"id":id,
} }
let { data } = await axios.post(url,body); let { data } = await axios.post(url,body);
if (data.error) { if (data.error) {
......
import WebSocket from 'ws';
const client = new WebSocket('ws://127.0.0.1:8443?sid=12312',[],{"headers":{"api-key":111}});
// 心跳
let heartbeatInterval: any;
const heartbeatConfig = {
interval: 30000, // 心跳间隔
};
function heartBeat (){
console.log(new Date() +" send ping...")
client.ping()
}
client.on('error', console.error);
client.on('open', function open() {
console.log("success open!")
if (heartbeatInterval) {
clearInterval(heartbeatInterval);
}
heartbeatInterval = setInterval(heartBeat, heartbeatConfig.interval); // 设置心跳
});
client.on('message', function message(data) {
console.log('received: %s', data);
});
client.on('onclose', function message(data) {
if (heartbeatInterval) {
clearInterval(heartbeatInterval); // 清除心跳定时器
}
console.log('Connection closed');
});
client.on('pong',function (){
console.log("rec pong")
})
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment