-
Notifications
You must be signed in to change notification settings - Fork 22
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
Alan Shaw
committed
Oct 10, 2023
1 parent
4562f13
commit 8142de1
Showing
3 changed files
with
50 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { StoreOperationFailed } from '../errors.js' | ||
|
||
/** | ||
* @param {import('./api').ServiceContext} context | ||
* @param {import('./api').FilecoinSubmitMessage} message | ||
*/ | ||
export const handleFilecoinSubmitMessage = async (context, message) => { | ||
// TODO: verify piece | ||
|
||
const putRes = await context.pieceStore.put({ | ||
piece: message.piece, | ||
content: message.content, | ||
group: message.group, | ||
status: 'submitted', | ||
insertedAt: Date.now(), | ||
updatedAt: Date.now() | ||
}) | ||
if (putRes.error) { | ||
return { error: new StoreOperationFailed(putRes.error.message) } | ||
} | ||
return { ok: {} } | ||
} | ||
|
||
/** | ||
* @param {import('./api').ServiceContext} context | ||
* @param {import('./api').PieceRecord} record | ||
*/ | ||
export const handlePieceInsert = async (context, record) => { | ||
// TODO: invoke filecoin/submit | ||
return { ok: {} } | ||
} | ||
|
||
/** | ||
* @param {import('./api').ServiceContext} context | ||
*/ | ||
export const handleCronTick = async (context) => { | ||
// TODO: get pieces where status === submitted | ||
// read receipts to determine if an aggregate accepted for each piece | ||
// update piece status to accepted if yes | ||
} | ||
|
||
/** | ||
* @param {import('./api').ServiceContext} context | ||
* @param {import('./api').PieceRecord} record | ||
*/ | ||
export const handlePieceStatusAccepted = async (context, record) => { | ||
// TODO: invoke filecoin/accept /w content & piece | ||
return { ok: {} } | ||
} |
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