This repository has been archived by the owner on Nov 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
366f6c9
commit 0aef784
Showing
7 changed files
with
82 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import {exists, write} from 'fs-jetpack'; | ||
import {DataItemJson} from 'arweave-bundles'; | ||
import {b64UrlToBuffer} from '../utility/encoding.utility'; | ||
|
||
export async function cacheANSEntries(entries: Array<DataItemJson>) { | ||
for (let i = 0; i < entries.length; i++) { | ||
const entry = entries[i]; | ||
const id = entry.id; | ||
const data = entry.data; | ||
|
||
const bufferData = Buffer.from(b64UrlToBuffer(data)); | ||
|
||
if (exists(`${process.cwd()}/cache/tx/${id}`) === false) { | ||
write(`${process.cwd()}/cache/tx/${id}`, bufferData.toString('utf-8')); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import 'colors'; | ||
import {connection} from '../database/connection.database'; | ||
import {toB64url} from '../query/transaction.query'; | ||
import {cacheAnsFile} from './file.caching'; | ||
|
||
const name = toB64url('Bundle-Type'); | ||
const value = toB64url('ANS-102'); | ||
|
||
export async function ansVerify(offset: number = 0) { | ||
const query = await connection | ||
.queryBuilder() | ||
.select('*') | ||
.from('tags') | ||
.where('name', name) | ||
.where('value', value) | ||
.orderByRaw('created_at ASC') | ||
.limit(10) | ||
.offset(offset); | ||
|
||
for (let i = 0; i < query.length; i++) { | ||
const item = query[i]; | ||
|
||
try { | ||
await cacheAnsFile(item.tx_id); | ||
} catch (error) { | ||
console.log(`Could not cache ${item.tx_id}`.red); | ||
} | ||
} | ||
|
||
console.log(`Successfully cached ANS bundles at offset ${offset}`.green); | ||
|
||
if (query.length === 0) { | ||
console.log(`Successfully cached all ANS bundles. Good work!`.green.bold); | ||
process.exit(); | ||
} else { | ||
ansVerify(offset + 10); | ||
} | ||
} | ||
|
||
(async () => await ansVerify())(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters