Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy testnet #53

Merged
merged 37 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
db5f51e
Merge pull request #18 from codelight-co/feat/api-marketplace
mison201 Mar 21, 2024
a2275aa
chore: separation connection
mison201 Apr 22, 2024
1ca329f
chore: update marketplace connection
mison201 Apr 22, 2024
676a0fd
chore: add txrune index
mison201 Apr 22, 2024
ec152e6
chore: get block index
mison201 Apr 22, 2024
9ef323a
chore: update get block indexer url
mison201 Apr 23, 2024
14983b8
hotfix: search rune by name
mison201 Apr 23, 2024
58f05d1
hotfix: update rune-js version
mison201 Apr 23, 2024
cdd3582
feat(deploy-k8s): deploy testnet
leductoan3082004 Apr 23, 2024
8d2b043
Merge branch 'deploy-testnet' of https://github.com/codelight-co/rune…
leductoan3082004 Apr 23, 2024
4bd3de3
test deploy
leductoan3082004 Apr 23, 2024
485b676
fix(deploy): change branch deploy
leductoan3082004 Apr 23, 2024
fc2df8f
fix(deploy): seperate mainnet testnet file
leductoan3082004 Apr 23, 2024
3b205a1
chore; update deployment dev
mison201 Apr 23, 2024
8634bab
Merge pull request #49 from codelight-co/deploy-testnet
mison201 Apr 23, 2024
56542cd
chore: update dev env
mison201 Apr 23, 2024
b74cb94
chore: update rune entry schema
mison201 Apr 23, 2024
6d5fac8
fix: replace multi symbol
mison201 Apr 23, 2024
564cdb4
fix: replace multi symbol
mison201 Apr 23, 2024
f5e40a7
chore: update rune query
mison201 Apr 23, 2024
da40e01
chore: improve calculate network stat
mison201 Apr 23, 2024
7ed23a9
fix: mint transaction hash
mison201 Apr 23, 2024
15574b7
fix: get transaction out value
mison201 Apr 23, 2024
86368dc
Merge pull request #50 from codelight-co/develop
mison201 Apr 23, 2024
3f8c8f7
chore: update daily transaction count
mison201 Apr 24, 2024
52802ff
chore: add cache runinfo
mison201 Apr 24, 2024
99036e3
chore: add rune divisibility
mison201 Apr 24, 2024
a1af8ac
chore: add more data for stat
mison201 Apr 24, 2024
dec2a45
chore: update get utxo rune
mison201 Apr 24, 2024
5a55095
chore: add rune divisibility
mison201 Apr 24, 2024
603af30
fix: bigint divide zero
mison201 Apr 24, 2024
4f4b2f8
Merge pull request #51 from codelight-co/develop
mison201 Apr 24, 2024
ab484ce
fix: remove debug
mison201 Apr 24, 2024
5a4d294
debug: pending etching rune
mison201 Apr 24, 2024
a1352dd
fix: send transaction with op_return
mison201 Apr 24, 2024
4f14389
Merge pull request #52 from codelight-co/develop
mison201 Apr 24, 2024
e26499c
Merge branch 'deploy' into deploy-testnet
mison201 Apr 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: improve calculate network stat
  • Loading branch information
mison201 committed Apr 23, 2024
commit da40e014c032bcbe30af648c1fa3fa0a73c36b7f
83 changes: 50 additions & 33 deletions service/src/modules/stats/stats.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,23 +185,48 @@ export class StatsService {
this.logger.log(`Calculating network stats on block ${blockHeight} ...`);

try {
const runes = await this.runeEntryRepository.find();
for (let index = 0; index < runes.length; index++) {
const rune = runes[index];
await this.statQueue.add(
PROCESS.STAT_QUEUE.CALCULATE_RUNE_STAT,
{
blockHeight,
rune,
},
{
jobId: `${rune.rune_id}`,
attempts: 0,
backoff: 0,
removeOnComplete: true,
removeOnFail: true,
},
);
let runeIds = [];

if (!currentBlockHeight) {
console.log('here ==============');
const runes = await this.runeEntryRepository.find();
if (runes?.length) {
runeIds = runes.map((rune) => rune.rune_id);
}
} else {
// Get changes in rune stats
const runeChanges = await this.transactionRepository.query(`
select jsonb_agg(rune_id) as ids
from (
select rune_id
from outpoint_rune_balances orb
where rune_id is not null and block_height = ${blockHeight}
group by rune_id
) as rb
`);
if (runeChanges?.length && runeChanges[0]?.ids?.length) {
runeIds = runeChanges[0]?.ids;
}
}

if (runeIds?.length) {
for (let index = 0; index < runeIds.length; index++) {
const id = runeIds[index];
await this.statQueue.add(
PROCESS.STAT_QUEUE.CALCULATE_RUNE_STAT,
{
blockHeight,
rune: { rune_id: id },
},
{
jobId: `${id}`,
attempts: 0,
backoff: 0,
removeOnComplete: true,
removeOnFail: true,
},
);
}
}
} catch (error) {
this.logger.error('Error calculating network stats', error);
Expand All @@ -213,9 +238,6 @@ export class StatsService {
rune: TransactionRuneEntry,
): Promise<void> {
try {
const runeStats = await this.runeStatRepository.findOne({
where: { rune_id: rune.rune_id },
});
const query = `select 'total_transactions' as name, count(*) as total
from (
select orb.tx_hash
Expand All @@ -233,26 +255,21 @@ from (
where tre.rune_id = '${rune.rune_id}' and CAST(orb.balance_value AS DECIMAL) > 0
group by orb.address
) as rp2`;
const stats = (await this.transactionRepository.query(query)) as Array<{
name: string;
total: number;
}>;
this.logger.log(`Calculating rune stat ${rune.rune_id} ...`);
const [runeStats, stats, runeIndex] = await Promise.all([
this.runeStatRepository.findOne({
where: { rune_id: rune.rune_id },
}),
this.transactionRepository.query(query),
this.indexersService.getRuneDetails(rune.rune_id),
]);

const payload = {} as any;
for (let index = 0; index < stats.length; index++) {
const stat = stats[index];
payload[stat.name] = stat.total;
}

let runeIndex = null;
try {
runeIndex = await this.indexersService.getRuneDetails(rune.rune_id);
} catch (error) {
this.logger.error('Error getting rune details', error);
}
if (!runeIndex) {
return;
}
const rune_name = runeIndex?.entry?.spaced_rune
? String(runeIndex?.entry?.spaced_rune).replace(/•/g, '')
: '';
Expand Down
13 changes: 1 addition & 12 deletions service/src/modules/transactions/transactions.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,18 +531,7 @@ export class TransactionsService {

return runeData.map((rune) => {
if (rune?.length) {
return rune.map((r) => ({
...r,
rune: {
...r.rune,
mints: r.rune?.mints,
premine: r.rune?.premine,
burned: r.rune?.burned,
supply: r.rune?.supply,
minable: r.rune?.mintable,
terms: r.rune?.terms,
},
}));
return rune;
}

return null;
Expand Down