Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
woyoutlz committed Jun 20, 2019
0 parents commit 0af344e
Show file tree
Hide file tree
Showing 223 changed files with 9,806 additions and 0 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
coverage
20 changes: 20 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// http://eslint.org/docs/user-guide/configuring

module.exports = {
root: true,
parser: 'babel-eslint',
parserOptions: {
sourceType: 'module'
},
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
extends: 'standard',
// add your custom rules here
'rules': {
// allow paren-less arrow functions
'arrow-parens': 0,
// allow async-await
'generator-star-spacing': 0,
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
}
}
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules
.vscode
yarn.lock
package-lock.json
.idea
logs
leveldb
build
init.json
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# config and data server

用于提供简单的配置服务和数据服务

# 使用

## 环境
node 8.11

## 安装

根目录 npm install

## 配置

config.js中,目前只支持端口配置

sub 的 app中的config.js 也需要配置

## 使用

npm run start
test

4 changes: 4 additions & 0 deletions config/config.dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
cybex_node: "wss://shanghai.51nebula.com/",
mongo:"mongodb://localhost/appserver"
}
18 changes: 18 additions & 0 deletions config/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
let env = require('./env').env
let env_config
try {
let file = './config.' + env
env_config = require(file)
} catch (e) {
env_config = {}
}
let config = {
cybex_node: "wss://shenzhen.51nebula.com/",
port: 3039,
mongo: "mongodb://localhost/appserver",
coinmarketcapToken: [] // coinmarket cap 的 api token,用于获取行情
}
if (env_config) {
Object.assign(config, env_config)
}
module.exports = config
3 changes: 3 additions & 0 deletions config/env.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
env:"dev"
}
6 changes: 6 additions & 0 deletions doc/dev.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## 开发思路

### 18.6.7

重新整理一下结构,应该是最简单的部分拼凑起来。
首先是web服务器
19 changes: 19 additions & 0 deletions lab/geticon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
var http = require('http');
var fs = require('fs');
var { data } = require('./public/market_list.json')
var _ = require('lodash')
var request = require('request')
let x = _.uniq(_.flatten(data)).map(i => {
return i.replace(/\./gi, '_')
})
console.log(x)
for (let name of x) {
let filename = `public/icons/${name}_grey.png`
var stream = fs.createWriteStream(filename)
let url = `https://cybex.io/icons/${name}_grey.png`
request(url).pipe(stream)
}
// var file = fs.createWriteStream("file.jpg");
// var request = http.get("http://i3.ytimg.com/vi/J---aiyznGQ/mqdefault.jpg", function(response) {
// response.pipe(file);
// });
20 changes: 20 additions & 0 deletions lab/icon_convert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
var fs = require('fs')
var c = require('../sub/coin/c')
console.log(c.coin2id)

let s = fs.readdirSync('icons')
for (let name of s){
path = 'icons/'+name
// fs.renameSync(path,'icons/'+"1"+name)
// let x1 = name.split("@")[0]
let x1 = name.split('.')[0]
let big = x1.toUpperCase()
console.log(big)
let coinname = 'JADE.'+big
let cid = c.coin2id[coinname]
if (cid){
let name_new = cid.replace(/\./gi, '_')+'_grey.png'
let path2 = '../public/icons/'+name_new
fs.renameSync(path,path2)
}
}
7 changes: 7 additions & 0 deletions lab/memo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
async function test(){
let x = require('../../memo.json')
let ids = _.uniq(x.map(i=>i.operation_msg.to))
let s = await model.op.find({operation_type:0,'operation_msg.to':'1.2.2091','operation_msg.from':{$in:ids},timestamp:{$gte:'2018-06-03',$lte:'2018-06-12'}}).sort({timestamp:-1})
fs.writeFileSync('memo2.json',JSON.stringify(s))
}
test()
1 change: 1 addition & 0 deletions lab/memo.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions lab/memo2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"_id":"5b1c09eeff03d6c17d57cd98","block":2955258,"blockaddsig":"2955258_1f4df7f4f21801dfbfbdf12ac8f37eecdaaad4e56d88dc65488e61ad7cdc370c3314c59a087da186dd5d32b3e8327cd42ade58773fe16dd422d7161bc465ccb620","blocktime":1528479162,"operation_msg":{"fee":{"asset_id":"1.3.0","amount":1093},"memo":{"message":"8266ae42858d821d486d7477fbbcc0b190cd9b45934863bf2bf6715a8e187873aa0af9cfe7f5705b401e79a9015fcee6e73f3a7a4d7dfd0caecede1966355bf34e9fc65649a65659a81a92f9912cf090f93da80902cae3ab63891943cdf81a91","to":"CYB8GAokoi9ihEAaEwzaFxaNVuFn3JmSEHnbCfZX3QNLm8Zvz9vo2","nonce":"391298036956617","from":"CYB8ARxkqBh4wXDnsEqXGwLYc6U1HENtQTuv9EWZEf2KbBkLkJjLH"},"amount":{"asset_id":"1.3.0","amount":10000},"from":"1.2.5213","to":"1.2.2091","extensions":[]},"operation_type":0,"sig":"1f4df7f4f21801dfbfbdf12ac8f37eecdaaad4e56d88dc65488e61ad7cdc370c3314c59a087da186dd5d32b3e8327cd42ade58773fe16dd422d7161bc465ccb620","timestamp":"2018-06-09T01:32:42"},{"_id":"5b1c027bff03d6c17d469492","block":2898300,"blockaddsig":"2898300_1f67e82771acd616e71daa04c86b08d5d7f1bfbee88c74afdc238b69c86437d69d066089e0695322e9ba6f864db665423668da2f1b00dc0f21bc0e958826d14134","blocktime":1528308267,"operation_msg":{"fee":{"asset_id":"1.3.0","amount":1111},"memo":{"message":"4555285e86af2e4718ee337f2d3c77b9ed8daa2d92646c4af827db8ffd8e398375b618bdcb461db9978d44a34c97ea680496899d8b5ace2f92772eec0dc43ce02ca225853023548a6f1ba8d6f95a56d0f4e4f72d6f32ba4ed466755b5fa302a2ed14f0d90dd2d86147737d55fbd94b7ee8aa9afccb46bb04952a2750be920e39","to":"CYB8GAokoi9ihEAaEwzaFxaNVuFn3JmSEHnbCfZX3QNLm8Zvz9vo2","nonce":"391254269028205","from":"CYB7EG2LG6oQSHhoc3KFXkTkmGm958vPGAwKcgTxnTtPDoBeSbxKV"},"amount":{"asset_id":"1.3.0","amount":100},"from":"1.2.513","to":"1.2.2091","extensions":[]},"operation_type":0,"sig":"1f67e82771acd616e71daa04c86b08d5d7f1bfbee88c74afdc238b69c86437d69d066089e0695322e9ba6f864db665423668da2f1b00dc0f21bc0e958826d14134","timestamp":"2018-06-07T02:04:27"},{"_id":"5b18ffcdff03d6c17d327160","block":2867146,"blockaddsig":"2867146_206e129b83f11d285b595d07fc49ac8858222513965f116ab8b23e963d9cef350d16fae6543357d177f2afef768f402912eb7fb6ac83100a30e96fa300a1509eb9","blocktime":1528214793,"operation_msg":{"fee":{"amount":1084,"asset_id":"1.3.0"},"amount":{"amount":10000,"asset_id":"1.3.0"},"extensions":[],"to":"1.2.2091","from":"1.2.5213","memo":{"message":"c3d1413cce91178dc074c72cb8b7179ad7a5214cb605eaff128cc357747dcaf01ca13baf07dfc611c9c9997006c6ce846a00821b75ab905dccd7a99dc4fec2ff803982c31a7e59a143857784477da781","from":"CYB8ARxkqBh4wXDnsEqXGwLYc6U1HENtQTuv9EWZEf2KbBkLkJjLH","nonce":"391230358233743","to":"CYB8GAokoi9ihEAaEwzaFxaNVuFn3JmSEHnbCfZX3QNLm8Zvz9vo2"}},"operation_type":0,"sig":"206e129b83f11d285b595d07fc49ac8858222513965f116ab8b23e963d9cef350d16fae6543357d177f2afef768f402912eb7fb6ac83100a30e96fa300a1509eb9","timestamp":"2018-06-06T00:06:33"},{"_id":"5b18ffa0ff03d6c17d31de06","block":2866302,"blockaddsig":"2866302_20686235e0bf059ee3c5276c464e72b7f7798156090cdc0a9dab2d53ecbc089bc424a80ecd13c446323b56490c7a93da7b157822725246f4adac401459802194c7","blocktime":1528212258,"operation_msg":{"fee":{"amount":1084,"asset_id":"1.3.0"},"amount":{"amount":1000,"asset_id":"1.3.0"},"extensions":[],"to":"1.2.2091","from":"1.2.3087","memo":{"message":"27b7a3e28be2578ec91addb287efd8cee84192571c459e1ae20e71ef48c6f0216f8c126bc29fe0a31efd4b1f9902da204e6b1b2ba93f39ae5e6644eda79738550137ed7997a77218ec570153a2628144","from":"CYB8CcRi8bgEjwWcMY7X1zAr3A7j63xUeUv9e44YDw7Gv9dydtTLC","nonce":"391229706258410","to":"CYB8GAokoi9ihEAaEwzaFxaNVuFn3JmSEHnbCfZX3QNLm8Zvz9vo2"}},"operation_type":0,"sig":"20686235e0bf059ee3c5276c464e72b7f7798156090cdc0a9dab2d53ecbc089bc424a80ecd13c446323b56490c7a93da7b157822725246f4adac401459802194c7","timestamp":"2018-06-05T23:24:18"},{"_id":"5b18faa2ff03d6c17d236cc4","block":2845385,"blockaddsig":"2845385_205e4b339e125b7003cb9f29ce58777782206310582d394f4b5898d1ca11102a5335bee25ee86ccc239f7ea4fb09e5ebcf54c0fecdff086ab8485f9dad4199935a","blocktime":1528149498,"operation_msg":{"fee":{"amount":1093,"asset_id":"1.3.0"},"amount":{"amount":10000,"asset_id":"1.3.0"},"extensions":[],"to":"1.2.2091","from":"1.2.1792","memo":{"message":"a977ff3b9a26fd18e16c10ab511f1360016f9f7845b7a9034d7de7bfb6ca4f763183e00c6e9b8ef80c86a8173b62ed9254fad8ebe166ecd5566dd2ddc696c7c020e2c996c92c111a05fb4dd2d8968f5aa02666d9f1716c52f419b2a85dc57228","from":"CYB5tiDd93RbkxmUL4bA1Yrz2nCNh6v2ik3coEudnNPJV94ScqtCr","nonce":"391213639207759","to":"CYB8GAokoi9ihEAaEwzaFxaNVuFn3JmSEHnbCfZX3QNLm8Zvz9vo2"}},"operation_type":0,"sig":"205e4b339e125b7003cb9f29ce58777782206310582d394f4b5898d1ca11102a5335bee25ee86ccc239f7ea4fb09e5ebcf54c0fecdff086ab8485f9dad4199935a","timestamp":"2018-06-05T05:58:18"},{"_id":"5b18faa2ff03d6c17d236b28","block":2845376,"blockaddsig":"2845376_207ccc2e063373e4627ee29e5d5ee688c54ca9ff762b19b7e4b8cffda920690fb030ba6920534a24c6f0ec76bfd3a8f54cc27d11139aa24e36ddc78806a1423ba1","blocktime":1528149471,"operation_msg":{"fee":{"amount":1093,"asset_id":"1.3.0"},"amount":{"amount":10000,"asset_id":"1.3.0"},"extensions":[],"to":"1.2.2091","from":"1.2.9755","memo":{"message":"771958aa2be92b5d452a3f48d98ab7c8b84159ce2c53a66eda3c825f571fb768805704a7f207f4d325ed16a62a0993d7a64af5f7533c8200ab32bc9bc6446c41fd46e0412fbd7706960070459d7e50b190565439c955fcc649b29c316f113cb8","from":"CYB5uJpERPUjVTRHwSDCgLuHGnFAoj3dVqjhWCcgJmYiqhZi2FjbZ","nonce":"391213635858806","to":"CYB8GAokoi9ihEAaEwzaFxaNVuFn3JmSEHnbCfZX3QNLm8Zvz9vo2"}},"operation_type":0,"sig":"207ccc2e063373e4627ee29e5d5ee688c54ca9ff762b19b7e4b8cffda920690fb030ba6920534a24c6f0ec76bfd3a8f54cc27d11139aa24e36ddc78806a1423ba1","timestamp":"2018-06-05T05:57:51"},{"_id":"5b18fa6bff03d6c17d22ddfd","block":2844623,"blockaddsig":"2844623_20696c6bc67ac47a9c7f553bd2f372be612f0423e9996a9fed51373696951ac7c31368e36d6b4d3c7513176269bde0f0a37d3906210c13052e1044a63653acb11d","blocktime":1528147212,"operation_msg":{"fee":{"amount":1093,"asset_id":"1.3.0"},"amount":{"amount":10000,"asset_id":"1.3.0"},"extensions":[],"to":"1.2.2091","from":"1.2.9755","memo":{"message":"74e739beb843c9beeaedae269b4bbcee7e704b32ceae2c3965a7ed9587bd78bdae9901b39f8b41e0bb59d49a7ac58981bf06caf0a43deaaefcb30c24b726712243421137cffd7c0b13dfaa73a015efc5cc44a9cf1d23c6ea319c1a04c30a88d5","from":"CYB5uJpERPUjVTRHwSDCgLuHGnFAoj3dVqjhWCcgJmYiqhZi2FjbZ","nonce":"391213058249655","to":"CYB8GAokoi9ihEAaEwzaFxaNVuFn3JmSEHnbCfZX3QNLm8Zvz9vo2"}},"operation_type":0,"sig":"20696c6bc67ac47a9c7f553bd2f372be612f0423e9996a9fed51373696951ac7c31368e36d6b4d3c7513176269bde0f0a37d3906210c13052e1044a63653acb11d","timestamp":"2018-06-05T05:20:12"},{"_id":"5b18f864ff03d6c17d1e9a10","block":2838759,"blockaddsig":"2838759_1f5fa91d11762ee3e74d27282e80a61ddb58eca16849ac5e9b2d453ba1e4cda4f65f92ef73608f69cd119b4190e372f68c43d4af213f85e854ef18b0dc26ecd082","blocktime":1528129620,"operation_msg":{"fee":{"amount":1093,"asset_id":"1.3.0"},"amount":{"amount":10000,"asset_id":"1.3.0"},"extensions":[],"to":"1.2.2091","from":"1.2.637","memo":{"message":"82a9fd441844b970eee195873656053b2217eabb91eea5f9c84898918ab0ef036b4ec9d7ffd9fa9063f10726d213c5fcb83b7b700e88a2528499bb0fe60e8976a7007bb1a8bf41a09cb5ef5a67215e67e0d15fc7bc7420b1afc6d37f30c7f78c","from":"CYB7yaqWfxTLZWCXY4N9xE8NL5WKRTCsL6rLajRtLLYMAYswaRXGM","nonce":"391208554012807","to":"CYB8GAokoi9ihEAaEwzaFxaNVuFn3JmSEHnbCfZX3QNLm8Zvz9vo2"}},"operation_type":0,"sig":"1f5fa91d11762ee3e74d27282e80a61ddb58eca16849ac5e9b2d453ba1e4cda4f65f92ef73608f69cd119b4190e372f68c43d4af213f85e854ef18b0dc26ecd082","timestamp":"2018-06-05T00:27:00"},{"_id":"5b18f6c7ff03d6c17d19ab79","block":2831347,"blockaddsig":"2831347_1f0d675aabfd802fc7f6e00e52be378b2b49d3f4c291c21d0fd0195b773cd0341f66aa6cdd586df9caf733a87e2e3906fcef6455eb2db03389a07393eef45770b4","blocktime":1528107372,"operation_msg":{"fee":{"amount":1111,"asset_id":"1.3.0"},"amount":{"amount":9000,"asset_id":"1.3.0"},"extensions":[],"to":"1.2.2091","from":"1.2.4697","memo":{"message":"9aeb06a7682798794a552335bcd65fa1773be171b4654c18c4f048d27b6a2454ab6d9db463853626e926bf973f381c1f6d6c8c0e034457529ecf887018a3d2c16f9bff3f2a26f5f06470a839460299f44ad95887d979f7a7702c1efe8b5735381f4f1cd02dbf9995371e1c3955d3ec5acfc6e29416354968d826571f5fe931bf","from":"CYB8iT84z5WRgwjmQ1huABxSEAvYZzv9QFwJTmnW39FbvffAKjZDh","nonce":"391202855312757","to":"CYB8GAokoi9ihEAaEwzaFxaNVuFn3JmSEHnbCfZX3QNLm8Zvz9vo2"}},"operation_type":0,"sig":"1f0d675aabfd802fc7f6e00e52be378b2b49d3f4c291c21d0fd0195b773cd0341f66aa6cdd586df9caf733a87e2e3906fcef6455eb2db03389a07393eef45770b4","timestamp":"2018-06-04T18:16:12"},{"_id":"5b18f58eff03d6c17d16b102","block":2826933,"blockaddsig":"2826933_2068eedd10fd09e114efc5b54593d84fa5631fb9559c26e7cb8918f09f712d73b9591be495d41acc2e5b0010e0251c8242ae751026ad320f63cb3611e46bb95e01","blocktime":1528094124,"operation_msg":{"fee":{"amount":1101,"asset_id":"1.3.0"},"amount":{"amount":10000,"asset_id":"1.3.0"},"extensions":[],"to":"1.2.2091","from":"1.2.3320","memo":{"message":"cfa1f4649c629eaee21e30f0284d5c59ff1964aaf89121f82cc5e4b21e4cfd8f398edd9ad292f4bef69121b284abcc4b8f084ce59d5f004c5ee42c62d275e990c2cce54f996846a55681e30c54430497b84e58dbd462e4563882d5bb7181fe1acf2ad5db45daf2ad19c6549ded01bb0c","from":"CYB52vkN9Lx6CeLzKYyNmzCyqZk3VM9dx7GDnohhXPdynXiNfuCcv","nonce":"391199467124828","to":"CYB8GAokoi9ihEAaEwzaFxaNVuFn3JmSEHnbCfZX3QNLm8Zvz9vo2"}},"operation_type":0,"sig":"2068eedd10fd09e114efc5b54593d84fa5631fb9559c26e7cb8918f09f712d73b9591be495d41acc2e5b0010e0251c8242ae751026ad320f63cb3611e46bb95e01","timestamp":"2018-06-04T14:35:24"},{"_id":"5b18f581ff03d6c17d167cd4","block":2826633,"blockaddsig":"2826633_205dc9084e1acc07caa9a70c929304452c2246f9959305b3810162935e4924611718418cf5e55a57bb8dbe1a446b70e0e347971a971389f672b6c04e68f8541cbe","blocktime":1528093224,"operation_msg":{"fee":{"amount":1145,"asset_id":"1.3.0"},"amount":{"amount":1000,"asset_id":"1.3.0"},"extensions":[],"to":"1.2.2091","from":"1.2.938","memo":{"message":"b7a48f246994042ed2e53c2d091af81fa36188658a4c5817c21b5c428ba0d130ec941510264b6ae40f62932852491fd1825246c10e4e27e0c9ac6b28d26b7280cef5fed921728826231f86047ac509850d29df74c249389e00f2b6828e724a00d420a1c1d3819253cd70ab05392c33dbeacee945c1d48ddbac717feeb914c20de281614930a067c43c1c0ec88aa2cb2458eb88baefeb5a63b31533ca568386f677506157d84d14c6c8a7c52051de54a78e1eaee7e47219612f19d6d8f44a365c","from":"CYB5yCoVd1kcprETpFuV7okpsGTCM2aUYVu6nLJHyQSGMWbwMUTuJ","nonce":"391199235000830","to":"CYB8GAokoi9ihEAaEwzaFxaNVuFn3JmSEHnbCfZX3QNLm8Zvz9vo2"}},"operation_type":0,"sig":"205dc9084e1acc07caa9a70c929304452c2246f9959305b3810162935e4924611718418cf5e55a57bb8dbe1a446b70e0e347971a971389f672b6c04e68f8541cbe","timestamp":"2018-06-04T14:20:24"},{"_id":"5b18f479ff03d6c17d136d0f","block":2822211,"blockaddsig":"2822211_204f3d4a62cf13053d8fd299fa8cede837ae04de1ac1f912bbdd72723e3cfef37f6bf3c04b2e01c9284ab2e8eacd9177e5e60f1de90f8b1e740d13558a3ab65ce1","blocktime":1528079958,"operation_msg":{"fee":{"amount":1084,"asset_id":"1.3.0"},"amount":{"amount":10000,"asset_id":"1.3.0"},"extensions":[],"to":"1.2.2091","from":"1.2.2897","memo":{"message":"1715e33271295715d65baf353598234852ab8449aee2e619a542bef25c9f44a0c72cffd1cb7c508b02fa1915641ced15fea9ca5e540b8010d590522c64cddd58b18d630ee73fcddb141891b02550c456","from":"CYB5o2EKq9MKTMiaPHvBoWasDXivr4k7fLwCgcaYQQWVR4dmTpkYP","nonce":"391195839822612","to":"CYB8GAokoi9ihEAaEwzaFxaNVuFn3JmSEHnbCfZX3QNLm8Zvz9vo2"}},"operation_type":0,"sig":"204f3d4a62cf13053d8fd299fa8cede837ae04de1ac1f912bbdd72723e3cfef37f6bf3c04b2e01c9284ab2e8eacd9177e5e60f1de90f8b1e740d13558a3ab65ce1","timestamp":"2018-06-04T10:39:18"},{"_id":"5b18f418ff03d6c17d124f64","block":2820598,"blockaddsig":"2820598_1f7c0811cbdf6ab47020473cc30f8de13a99e43ca8c98c0e15f806080ce4e631522997e958418c0a69297b660e52d75f78a274def7735b7585758e7c3224ff59ed","blocktime":1528075119,"operation_msg":{"fee":{"amount":1101,"asset_id":"1.3.0"},"amount":{"amount":10000,"asset_id":"1.3.0"},"extensions":[],"to":"1.2.2091","from":"1.2.370","memo":{"message":"acbbd4ec3b81c4e396b119b9e7e8fec2a30e3e8a5d174cb2f4a8b5189996f8847d782ac48830ac91ca373bcc850bc81a13bb96aa61181a50b8b9d5b63d6d4bb0aafbd66334c8416a43c2e16f7a272cf78bb61cddb3360e42473218e572402376789a524d9ae1d4e459bce2a94bc8a231","from":"CYB8bricZjZiwG7BomP6gceGHD5vbHStrCKCo4Wp7UzbgtMq7za1K","nonce":"391194602131248","to":"CYB8GAokoi9ihEAaEwzaFxaNVuFn3JmSEHnbCfZX3QNLm8Zvz9vo2"}},"operation_type":0,"sig":"1f7c0811cbdf6ab47020473cc30f8de13a99e43ca8c98c0e15f806080ce4e631522997e958418c0a69297b660e52d75f78a274def7735b7585758e7c3224ff59ed","timestamp":"2018-06-04T09:18:39"},{"_id":"5b18f3ebff03d6c17d11c381","block":2819809,"blockaddsig":"2819809_1f655961d241d1661a7b0a616bd062d486412c28cd68bec4a62230876e84bf167525fb196eb11bdda67e788777c6a7f8b926cf29eeda393d871b956966b7267b95","blocktime":1528072752,"operation_msg":{"fee":{"amount":1111,"asset_id":"1.3.0"},"amount":{"amount":10000,"asset_id":"1.3.0"},"extensions":[],"to":"1.2.2091","from":"1.2.1833","memo":{"message":"b14a9cfe87e870f396eb1101ffc765eac2b1ba75d11736619a84c3aec8cbe91a6a2ef8feb06a1bedd922a74e10a708eea4936f8afa299d0290518bf4ba53c3fae33f8e6c487da042b69464799e632b5838a74c3d1a539305d65d58e9b7475f6ecc4f759bcae8bc9d2c1235412be8b404fdb4936f50c936313ceae453a22e81e9","from":"CYB5eCYo4VwmoVRu4pJLDG7ySWUHsVt4rJAKBPBNQXgASkSyUt5Wv","nonce":"391193995560311","to":"CYB8GAokoi9ihEAaEwzaFxaNVuFn3JmSEHnbCfZX3QNLm8Zvz9vo2"}},"operation_type":0,"sig":"1f655961d241d1661a7b0a616bd062d486412c28cd68bec4a62230876e84bf167525fb196eb11bdda67e788777c6a7f8b926cf29eeda393d871b956966b7267b95","timestamp":"2018-06-04T08:39:12"},{"_id":"5b18f3c2ff03d6c17d11343f","block":2819000,"blockaddsig":"2819000_20601f1eb44859fbb74df2f47ddfd8c6a91201c7f48428120f3c36f4068a0b19c95029796d73810567ef9d4bb7517abbea5c4455646198578b4530e1af5c046792","blocktime":1528070325,"operation_msg":{"fee":{"amount":1093,"asset_id":"1.3.0"},"amount":{"amount":10000,"asset_id":"1.3.0"},"extensions":[],"to":"1.2.2091","from":"1.2.396","memo":{"message":"137b20fdb1bd7ddf9f31c2dd548008f136d9f24243a70f685cbcb5a73f9e34e7e593619a1c24f7f7a37ca00cfe27d7e2bf1954db3a36fb82df5acc8541769af7f0c1c4b7038d3c7243625ea7a4940b449337244a08dbdfbb7ae23e4c4e3f844f","from":"CYB6xb1ENXhiqYiH9mBvRwe5TkBjhK5B4s72DLDCmRZ7Hw6Vv9qy8","nonce":"391193373065164","to":"CYB8GAokoi9ihEAaEwzaFxaNVuFn3JmSEHnbCfZX3QNLm8Zvz9vo2"}},"operation_type":0,"sig":"20601f1eb44859fbb74df2f47ddfd8c6a91201c7f48428120f3c36f4068a0b19c95029796d73810567ef9d4bb7517abbea5c4455646198578b4530e1af5c046792","timestamp":"2018-06-04T07:58:45"}]
47 changes: 47 additions & 0 deletions lib/agenda_helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
let Agenda = require('agenda')
let config = require('../config/config')
let agenda = null

let g = {
logger:console
}
function init(mongoURL) {
if (!agenda){
g.logger.log(`mongo aganda >>> ${mongoURL}`)
agenda = new Agenda({ db: { address: mongoURL } ,defaultLockLifetime: 10000})
}
}
let agenda_tasks = []
function addTask(every, name, func) {
init()
agenda.define(name, async function (job, done) {
g.logger.log(`start task >>> ${name}`)
try {
await func()
}catch(e){
g.logger.error(`error task >>> ${name}`,e)
}
g.logger.log(`end task >>> ${name}`)
done()
})
agenda_tasks.push({ every, name })
// agenda.every(every, name)
}
function startAgenda() {
init()
g.logger.log(`agenda tasks ${JSON.stringify(agenda_tasks)}`)
agenda.on('ready', function () {
for (let task of agenda_tasks) {
agenda.every(task.every, task.name);
}
agenda.start();
});
}

module.exports = {
g,
init,
agenda,
startAgenda,
addTask
}
Loading

0 comments on commit 0af344e

Please sign in to comment.