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

SQLite. Closes #5 #83

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 6 additions & 1 deletion bin/spark-evaluate.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { newDelegatedEthAddress } from '@glif/filecoin-address'
import { recordTelemetry } from '../lib/telemetry.js'
import fs from 'node:fs/promises'
import { fetchMeasurements } from '../lib/preprocess.js'
import createDb from 'better-sqlite3'
import { migrate } from '../lib/migrate.js'

const {
SENTRY_ENVIRONMENT = 'development',
Expand Down Expand Up @@ -42,12 +44,15 @@ const ieContract = new ethers.Contract(
provider
)
const ieContractWithSigner = ieContract.connect(signer)
const db = createDb('/tmp/db.sqlite')
await migrate(db)

startEvaluate({
ieContract,
ieContractWithSigner,
fetchMeasurements,
fetchRoundDetails,
recordTelemetry,
logger: console
logger: console,
db
})
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export const startEvaluate = ({
fetchMeasurements,
fetchRoundDetails,
recordTelemetry,
logger
logger,
db
}) => {
const rounds = {}
const cidsSeen = []
const roundsSeen = []

Expand All @@ -24,7 +24,7 @@ export const startEvaluate = ({
console.log('Event: MeasurementsAdded', { roundIndex })
// Preprocess
preprocess({
rounds,
db,
cid,
roundIndex,
fetchMeasurements,
Expand Down Expand Up @@ -57,7 +57,7 @@ export const startEvaluate = ({
console.log('Event: RoundStart', { roundIndex })
// Evaluate previous round
evaluate({
rounds,
db,
roundIndex: roundIndex - 1,
ieContractWithSigner,
fetchRoundDetails,
Expand Down
Loading