check.js
1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const file = require('fs')
const request = require('request')
async function getBlance(address) {
return new Promise((resolve, reject) => {
request({
url: `http://localhost:8001/api/accounts?address=${address}`,
method: 'GET',
}, (err, response, body) => {
if (err) {
reject(err)
} else {
body = JSON.parse(body)
resolve(body)
}
})
})
// const respose=await nodeFetch('http://localhost:8001/api/transaction', {
// method: 'post',
// body: JSON.stringify(data),
// headers: {'Content-Type': 'application/json'}
// })
// return await respose.json()
}
async function main() {
let result = await file.readFileSync('./log/success.text','utf-8')
const array = JSON.parse(result).list
let unSuccessAccount = [], total = 0, unSuccesstotal = 0;
for (let index = 0; index < array.length; index++) {
const item = array[index];
const result = await getBlance(item.address)
if (result.success && Number(result.account.balance) !== Number(item.balance)) {
console.log(result.account.balance, item.balance, Number(result.account.balance) !== Number(item.balance))
unSuccesstotal += Number(item.balance)
unSuccessAccount.push({ address: item.address, balance: item.balance, index: index })
} else {
total += Number(result.account.balance)
}
}
console.log(`成功转账:${total},失败转账:${unSuccesstotal}`)
file.writeFile('./log/unSuccess.text', `{"success":${total},"unSucccess":${unSuccesstotal},"list":${JSON.stringify(unSuccessAccount)}}`, { flag: 'a' }, err => { })
// file.writeFile('./log/unSuccess.text', `${JSON.stringify(unSuccessAccount)}`, { flag: 'a' }, err => { })
}
main()