Skip to content

Commit

Permalink
Remove killed chains
Browse files Browse the repository at this point in the history
  • Loading branch information
tombeynon committed Dec 6, 2024
1 parent 1d04531 commit b8d643d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion chainWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ async function queueChainCheck(client, registry, monitor) {
(async () => {
const client = await redisClient();

const chainRepo = Repository(client, chainUrl, chainBranch, { path: chainPath, exclude: ['_template'], require: 'chain.json' })
const chainRepo = Repository(client, chainUrl, chainBranch, { path: chainPath, exclude: ['_template'], require: 'chain.json', filter: (chain) => {
return chain.chain.status !== 'killed';
}})
const validatorRepo = Repository(client, validatorUrl, validatorBranch, { require: 'chains.json', storeMeta: async (name, allData) => {
await client.json.set([name, 'addresses'].join(':'), '$', allData.reduce((sum, validator) => {
for(const chain of validator.chains.chains){
Expand Down
9 changes: 7 additions & 2 deletions repository/repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ function Repository(client, url, branch, opts) {

const data = buildData(dir);

if(opts.filter && !opts.filter(data)){
await client.del([name, dir].join(':'))
return
}

await client.json.set([name, dir].join(':'), '$', data)

return data
Expand All @@ -96,7 +101,7 @@ function Repository(client, url, branch, opts) {

const commit = await latestCommit()
await client.json.set([name, 'commit'].join(':'), '$', commit)

await client.json.set([name, 'repository'].join(':'), '$', {
name,
url,
Expand All @@ -109,4 +114,4 @@ function Repository(client, url, branch, opts) {
}
}

export default Repository
export default Repository

0 comments on commit b8d643d

Please sign in to comment.