mirror of
https://github.com/GOSTSec/gostexplr
synced 2025-03-13 05:51:26 +00:00
asdf
This commit is contained in:
parent
2ba2704881
commit
37038a28e0
0
.gitignore
vendored
Normal file → Executable file
0
.gitignore
vendored
Normal file → Executable file
0
bin/createUserAndDb.js
Normal file → Executable file
0
bin/createUserAndDb.js
Normal file → Executable file
0
bin/initdb.js
Normal file → Executable file
0
bin/initdb.js
Normal file → Executable file
57
bin/syncBlockchain.js
Normal file → Executable file
57
bin/syncBlockchain.js
Normal file → Executable file
@ -41,40 +41,56 @@ async function saveTransaction(txid, blockHeight) {
|
||||
const tx = JSON.parse(res_tx)['result'];
|
||||
if (tx === null) {
|
||||
await models.Failure.create({
|
||||
msg: `${txid} fetching failed`,
|
||||
msg: `Transaction ${txid} fetching failed`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
const transaction = await models.Transaction.create({
|
||||
// const transaction = await models.Transaction.create({
|
||||
// txid: tx.txid,
|
||||
// BlockHeight: blockHeight,
|
||||
// });
|
||||
const transaction = {
|
||||
txid: tx.txid,
|
||||
BlockHeight: blockHeight,
|
||||
});
|
||||
vouts: [],
|
||||
};
|
||||
|
||||
// Loop over vouts
|
||||
for (var i = 0; i < tx.vout.length; i++) {
|
||||
const vout = tx.vout[i];
|
||||
|
||||
const m_vout = await models.Vout.create({
|
||||
// const m_vout = await models.Vout.create({
|
||||
// n: vout.n,
|
||||
// value: vout.value,
|
||||
// });
|
||||
const m_vout = {
|
||||
n: vout.n,
|
||||
value: vout.value,
|
||||
});
|
||||
addresses: []
|
||||
};
|
||||
|
||||
// Loop over addresses in vout
|
||||
for (var y = 0; y < vout.scriptPubKey.addresses.length; y++) {
|
||||
const address = vout.scriptPubKey.addresses[y];
|
||||
let m_address = await models.Address.findOne({
|
||||
where: {
|
||||
address,
|
||||
},
|
||||
});
|
||||
if (m_address === null) {
|
||||
m_address = await models.Address.create({
|
||||
address,
|
||||
});
|
||||
}
|
||||
await m_vout.addAddresses(m_address);
|
||||
// let m_address = await models.Address.findOne({
|
||||
// where: {
|
||||
// address,
|
||||
// },
|
||||
// });
|
||||
// if (m_address === null) {
|
||||
// m_address = await models.Address.create({ /// TODO create
|
||||
// address,
|
||||
// });
|
||||
// }
|
||||
// if (m_address === null) {
|
||||
// m_address = { address, };
|
||||
// }
|
||||
|
||||
// await m_vout.addAddresses(m_address);
|
||||
m_vout.push(m_address);
|
||||
}
|
||||
await transaction.addVouts(m_vout, {through: {direction: 1}});
|
||||
// await transaction.addVouts(m_vout, {through: {direction: 1}}); // TODO create
|
||||
transaction.addVouts(m_vout, {through: {direction: 1}}); // TODO create
|
||||
}
|
||||
for (var i = 0; i < tx.vin.length; i++) {
|
||||
const vin = tx.vin[i];
|
||||
@ -114,9 +130,9 @@ async function syncNextBlock(syncedHeight) {
|
||||
}));
|
||||
const block = JSON.parse(res_block)['result'];
|
||||
block.time = new Date(block.time * 1000);
|
||||
await models.Block.create(block);
|
||||
// await models.Block.create(block);
|
||||
for (var i = 0; i < block.tx.length; i++) {
|
||||
await saveTransaction(block.tx[i], block.height);
|
||||
// await saveTransaction(block.tx[i], block.height);
|
||||
}
|
||||
if (block.height > 1) {
|
||||
await models.Block.update({
|
||||
@ -159,12 +175,13 @@ async function syncBlockchain() {
|
||||
try {
|
||||
while (syncedHeight < currentHeight) {
|
||||
syncedHeight = await syncNextBlock(syncedHeight);
|
||||
console.log('\x1b[36m%s\x1b[0m', 'syncedHeight: ', syncedHeight)
|
||||
process.stdout.write(`Synced ${syncedHeight} out of ${currentHeight}\r`);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('=====', e);
|
||||
process.exit(0);
|
||||
}
|
||||
process.stdout.write('\nDone\n');
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
|
0
config/config.json.example
Normal file → Executable file
0
config/config.json.example
Normal file → Executable file
0
models/address.js
Normal file → Executable file
0
models/address.js
Normal file → Executable file
0
models/block.js
Normal file → Executable file
0
models/block.js
Normal file → Executable file
0
models/failure.js
Normal file → Executable file
0
models/failure.js
Normal file → Executable file
0
models/index.js
Normal file → Executable file
0
models/index.js
Normal file → Executable file
0
models/transaction.js
Normal file → Executable file
0
models/transaction.js
Normal file → Executable file
0
models/vout.js
Normal file → Executable file
0
models/vout.js
Normal file → Executable file
0
package.json
Normal file → Executable file
0
package.json
Normal file → Executable file
0
public/favicon.ico
Normal file → Executable file
0
public/favicon.ico
Normal file → Executable file
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
0
public/images/gostcoin-b.png
Normal file → Executable file
0
public/images/gostcoin-b.png
Normal file → Executable file
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
0
public/stylesheets/style.css
Normal file → Executable file
0
public/stylesheets/style.css
Normal file → Executable file
26
routes/address.js
Normal file → Executable file
26
routes/address.js
Normal file → Executable file
@ -6,36 +6,40 @@ var router = express.Router();
|
||||
router.get('/:address/:offset*?', async function(req, res, next) {
|
||||
|
||||
const safe_address = encodeURI(req.params.address);
|
||||
const limit = 30;
|
||||
|
||||
const address = await models.Address.findOne({
|
||||
where: {
|
||||
address: safe_address,
|
||||
},
|
||||
const transactions = await models.Transaction.findAll({
|
||||
include: {
|
||||
model: models.Vout,
|
||||
include: {
|
||||
model: models.Transaction,
|
||||
|
||||
model: models.Address,
|
||||
where: {
|
||||
address: safe_address,
|
||||
},
|
||||
},
|
||||
},
|
||||
raw: true,
|
||||
limit: 30,
|
||||
});
|
||||
|
||||
if (address === null) {
|
||||
console.log(transactions);
|
||||
|
||||
if (transactions === null) {
|
||||
res.status(404).render('404');
|
||||
return;
|
||||
}
|
||||
|
||||
const limit = 30;
|
||||
|
||||
const paramPage = parseInt(req.params.offset);
|
||||
const page = isNaN(paramPage) || paramPage < 1 ? 1 : paramPage;
|
||||
const offset = 30 * (page - 1);
|
||||
|
||||
const nextpage = address.Vouts.length === 30 ? page + 1 : null;
|
||||
const nextpage = transactions.length === 30 ? page + 1 : null;
|
||||
const prevpage = page > 1 ? page - 1 : null;
|
||||
console.log(address.toJSON());
|
||||
|
||||
res.render('address', {
|
||||
address: address.toJSON(),
|
||||
address: safe_address,
|
||||
transactions,
|
||||
nextpage,
|
||||
prevpage,
|
||||
});
|
||||
|
13
routes/asdf.sql
Executable file
13
routes/asdf.sql
Executable file
@ -0,0 +1,13 @@
|
||||
{ id: 35,
|
||||
txid: '6dbdd552bed6523a48de3d07dfbdb655cf8386582cb4e7b5e0a7090ebf80e9bc',
|
||||
BlockHeight: 68,
|
||||
'Vouts.id': null,
|
||||
'Vouts.n': null,
|
||||
'Vouts.value': null,
|
||||
'Vouts.TransactionVouts.direction': null,
|
||||
'Vouts.TransactionVouts.TransactionId': null,
|
||||
'Vouts.TransactionVouts.VoutId': null,
|
||||
'Vouts.Addresses.id': null,
|
||||
'Vouts.Addresses.address': null,
|
||||
'Vouts.Addresses.AddressVout.AddressId': null,
|
||||
'Vouts.Addresses.AddressVout.VoutId': null },
|
0
routes/block.js
Normal file → Executable file
0
routes/block.js
Normal file → Executable file
0
routes/index.js
Normal file → Executable file
0
routes/index.js
Normal file → Executable file
0
routes/search.js
Normal file → Executable file
0
routes/search.js
Normal file → Executable file
0
routes/transaction.js
Normal file → Executable file
0
routes/transaction.js
Normal file → Executable file
0
views/404.pug
Normal file → Executable file
0
views/404.pug
Normal file → Executable file
5
views/address.pug
Normal file → Executable file
5
views/address.pug
Normal file → Executable file
@ -6,10 +6,9 @@ block content
|
||||
|
||||
h3 Transactions
|
||||
table
|
||||
each vout in address.Vouts
|
||||
each transaction in vout.Transactions
|
||||
each transaction in transactions
|
||||
tr
|
||||
if transaction.TransactionVouts.direction == 1
|
||||
if transaction['Vouts.TransactionVouts.direction'] == 1
|
||||
td INCOME
|
||||
else
|
||||
td OUTCOME
|
||||
|
0
views/block.pug
Normal file → Executable file
0
views/block.pug
Normal file → Executable file
0
views/error.pug
Normal file → Executable file
0
views/error.pug
Normal file → Executable file
0
views/index.pug
Normal file → Executable file
0
views/index.pug
Normal file → Executable file
2
views/layout.pug
Normal file → Executable file
2
views/layout.pug
Normal file → Executable file
@ -1,7 +1,7 @@
|
||||
doctype html
|
||||
html
|
||||
head
|
||||
title GOSTcoin blockchain explorer
|
||||
title ANnYcoin blockchain explorer
|
||||
link(rel='stylesheet', href='/stylesheets/style.css')
|
||||
link(rel='shortcut icon', href='/favicon.ico')
|
||||
meta(name="viewport", content="width=device-width")
|
||||
|
0
views/transaction.pug
Normal file → Executable file
0
views/transaction.pug
Normal file → Executable file
Loading…
x
Reference in New Issue
Block a user