Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ddn
/
ddn-upgrade-server
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
8ab54868
...
8ab54868bce18f3c516606ac44cb589291664f59
authored
2022-05-24 21:15:01 +0800
by
wulianyou
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修改数据库为sqlite
1 parent
828fb271
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
96 additions
and
41 deletions
app/controller/transfer.js
app/schedule/transfer.js
app/service/sdk.js
config/config.default.js
config/config.local.js
config/config.prod.js
database/config.json
database/ddn-ui-dev.db
package.json
app/controller/transfer.js
View file @
8ab5486
...
...
@@ -40,11 +40,11 @@ class TransferController extends Controller {
// }
const
some
=
accountData
.
RECORDS
.
some
(
item
=>
{
if
(
item
.
address
===
body
.
senderAddress
)
{
return
body
.
amount
*
10
**
8
==
item
.
balance
;
return
(
body
.
amount
*
10
**
8
)
==
item
.
balance
;
}
});
// 加上手续费
body
.
amount
=
(
body
.
amount
+
0.1
)
*
10
**
8
;
body
.
amount
=
(
Number
(
body
.
amount
)
+
0.1
)
if
(
!
some
)
{
ctx
.
helper
.
err
({
ctx
,
...
...
@@ -112,8 +112,8 @@ class TransferController extends Controller {
ctx
.
helper
.
err
({
ctx
,
err
:
ctx
.
helper
.
errorReadable
(
error
)
});
return
;
}
const
transferCount
=
await
this
.
ctx
.
model
.
Transfer
.
count
({
address
:
query
.
address
});
if
(
transferCount
=
==
0
)
{
const
transferCount
=
await
this
.
ctx
.
model
.
Transfer
.
count
({
where
:
{
address
:
query
.
address
}
});
if
(
transferCount
!
==
0
)
{
balance
=
0
;
}
else
{
accountData
.
RECORDS
.
some
(
item
=>
{
...
...
app/schedule/transfer.js
View file @
8ab5486
...
...
@@ -20,8 +20,8 @@ class Transfer extends Subscription {
const
transaction
=
await
nodeSdk
.
transaction
.
createTransaction
(
item
.
toAddress
,
item
.
amount
,
item
.
remark
||
'网络升级转账'
,
config
.
naclSecret
);
const
trs
=
JSON
.
stringify
({
transaction
});
// 上链操作
const
data
=
await
this
.
service
.
sdk
.
pushTransaction
(
trs
);
console
.
log
(
'向新网地址转账结果'
,
data
)
const
data
=
await
this
.
service
.
sdk
.
pushTransaction
(
trs
,
config
.
naclUrl
);
console
.
log
(
'向新网地址转账结果'
,
data
)
if
(
data
.
success
)
{
ctx
.
model
.
Transfer
.
update
({
finish
:
true
},
{
where
:
{
id
:
item
.
id
}
});
}
else
{
...
...
app/service/sdk.js
View file @
8ab5486
...
...
@@ -175,7 +175,7 @@ class DdnService extends Service {
console
.
log
(
trs
)
const
{
config
}
=
this
;
const
peer_host
=
await
this
.
getPeerHost
();
const
url
=
peer_url
?
`
${
peer_url
}
/peer/transactions`
:
`
${
peer_host
}
/api/transactions`
;
const
url
=
`
${
peer_url
}
/api/transactions`
;
let
ddn_result
=
await
new
Promise
(
resolve
=>
{
request
({
url
,
...
...
config/config.default.js
View file @
8ab5486
...
...
@@ -36,27 +36,64 @@ module.exports = appInfo => {
allowMethods
:
'GET,HEAD,PUT,POST,DELETE,PATCH'
,
};
// config.sequelize = {
// host: 'localhost',
// port: '5432',
// username: 'postgres',
// password: 'wawjr1314',
// database: 'ddn',
// dialect: 'postgres',
// pool: {
// max: 5,
// min: 0,
// idle: 10000,
// },
// logging: false,
// };
config
.
sequelize
=
{
host
:
'localhost'
,
port
:
'5432'
,
username
:
'postgres'
,
password
:
'wawjr1314'
,
database
:
'ddn'
,
dialect
:
'postgres'
,
// In a real app, you should keep the database connection URL as an environment variable.
// But for this example, we will just use a local SQLite database.
// const sequelize = new Sequelize(process.env.DB_CONNECTION_URL);
dialect
:
'sqlite'
,
storage
:
'./database/ddn-ui-dev.db'
,
logQueryParameters
:
true
,
benchmark
:
true
,
logging
:
false
,
// Specify options, which are used when sequelize.define is called.
// The following example:
// define: { timestamps: false }
// is basically the same as:
// Model.init(attributes, { timestamps: false });
// sequelize.define(name, attributes, { timestamps: false });
// so defining the timestamps for each model will be not necessary
define
:
{
underscored
:
true
,
// 该选项在 egg-sequelize 里是默认选项
// freezeTableName: false,
// charset: 'utf8',
// dialectOptions: {
// collate: 'utf8_general_ci'
// },
timestamps
:
true
,
},
// similar for sync: you can define this to always force sync for models
// sync: { force: true },
// pool configuration used to pool database connections
pool
:
{
max
:
5
,
min
:
0
,
idle
:
1
0000
,
idle
:
3000
0
,
acquire
:
6
0000
,
},
logging
:
false
,
};
// config.ed25519Address = 'DFy6P2sN1KLDNtppnqLBPWcnH8GTJRouGj'; // 旧网接收钱包地址 弃用
config
.
naclSecret
=
'puzzle elite rescue gun blush top floor surge injury popular pole inquiry'
;
// 新网转账钱包秘钥
// config.ed25519Url = 'http://120.24.69.99:8001'; // 旧网节点地址 弃用
config
.
naclUrl
=
'http://8.142.20.158:8001'
;
// 新网节点地址
// config.naclUrl = 'http://localhost:8001'; // 测试地址
config
.
ed25519NetHash
=
'b11fa2f2'
;
// 旧网nethash
config
.
naclNetHash
=
'0ab796cd'
;
// 新网nethash
//
config.naclSecret = 'puzzle elite rescue gun blush top floor surge injury popular pole inquiry'; // 新网转账钱包秘钥
//
//
config.ed25519Url = 'http://120.24.69.99:8001'; // 旧网节点地址 弃用
//
config.naclUrl = 'http://8.142.20.158:8001'; // 新网节点地址
//
//
config.naclUrl = 'http://localhost:8001'; // 测试地址
//
config.ed25519NetHash = 'b11fa2f2';// 旧网nethash
//
config.naclNetHash = '0ab796cd'; // 新网nethash
// add your user config here
const
userConfig
=
{
// myAppName: 'egg',
...
...
config/config.local.js
View file @
8ab5486
...
...
@@ -7,7 +7,7 @@
*/
module
.
exports
=
appInfo
=>
{
const
config
=
exports
=
{};
//
config.ed25519Address = 'DFy6P2sN1KLDNtppnqLBPWcnH8GTJRouGj'; // 旧网接收钱包地址
config
.
ed25519Address
=
'DFy6P2sN1KLDNtppnqLBPWcnH8GTJRouGj'
;
// 旧网接收钱包地址
// config.naclAddress = 'D3EFYncByWwzsSQvRsVbufBfmVstuf11QW'; // 新网转账钱包地址
config
.
naclSecret
=
'puzzle elite rescue gun blush top floor surge injury popular pole inquiry'
;
// 新网转账钱包秘钥
// config.ed25519Url = 'http://120.24.69.99:8001'; // 旧网节点地址
...
...
config/config.prod.js
0 → 100644
View file @
8ab5486
/* eslint valid-jsdoc: "off" */
'use strict'
;
/**
* @param {Egg.EggAppInfo} appInfo app info
*/
module
.
exports
=
appInfo
=>
{
const
config
=
exports
=
{};
config
.
ed25519Address
=
'DFy6P2sN1KLDNtppnqLBPWcnH8GTJRouGj'
;
// 旧网接收钱包地址
// config.naclAddress = 'D3EFYncByWwzsSQvRsVbufBfmVstuf11QW'; // 新网转账钱包地址
config
.
naclSecret
=
'puzzle elite rescue gun blush top floor surge injury popular pole inquiry'
;
// 新网转账钱包秘钥
// config.ed25519Url = 'http://120.24.69.99:8001'; // 旧网节点地址
config
.
naclUrl
=
'http://8.142.20.158:8001'
;
// 新网节点地址
// config.naclUrl = 'http://localhost:8001'; // 测试地址
config
.
ed25519NetHash
=
'b11fa2f2'
;
// 旧网nethash
config
.
naclNetHash
=
'0ab796cd'
;
// 新网nethash
// add your user config here
const
userConfig
=
{
// myAppName: 'egg',
};
return
{
...
config
,
...
userConfig
,
};
};
database/config.json
View file @
8ab5486
{
"development"
:
{
"username"
:
"postgres"
,
"password"
:
"wawjr1314"
,
"database"
:
"ddn"
,
"host"
:
"localhost"
,
"dialect"
:
"postgres"
"storage"
:
"./database/ddn-ui-dev.db"
,
"dialect"
:
"sqlite"
},
"test"
:
{
"username"
:
"root"
,
"password"
:
null
,
"database"
:
"database_test"
,
"host"
:
"127.0.0.1"
,
"dialect"
:
"mysql"
"storage"
:
"./database/database_test.db"
,
"dialect"
:
"sqlite"
},
"production"
:
{
"username"
:
"root"
,
"password"
:
null
,
"database"
:
"database_production"
,
"host"
:
"127.0.0.1"
,
"dialect"
:
"mysql"
"storage"
:
"./database/ddn-ui-prod.db"
,
"dialect"
:
"sqlite"
}
}
...
...
database/ddn-ui-dev.db
0 → 100644
View file @
8ab5486
No preview for this file type
package.json
View file @
8ab5486
...
...
@@ -13,7 +13,8 @@
"egg-scripts"
:
"^2.11.0"
,
"egg-sequelize"
:
"^6.0.0"
,
"egg-validate"
:
"^2.0.2"
,
"pg"
:
"^8.7.3"
"pg"
:
"^8.7.3"
,
"sqlite3"
:
"^5.0.8"
},
"devDependencies"
:
{
"autod"
:
"^3.0.1"
,
...
...
@@ -39,7 +40,7 @@
"lint"
:
"eslint ."
,
"ci"
:
"npm run lint && npm run cov"
,
"autod"
:
"autod"
,
"init"
:
"npx sequelize db:migrate"
"init"
:
"npx sequelize db:migrate"
},
"ci"
:
{
"version"
:
"10"
...
...
Please
register
or
sign in
to post a comment