feat: [FEATURE] Safe Block Fetch #464

This commit is contained in:
ppedziwiatr
2023-10-20 11:23:26 +02:00
committed by Tadeuchi
parent 249e3707c3
commit 98e3df415a
6 changed files with 83 additions and 3 deletions

View File

@@ -37,6 +37,24 @@ export async function handle(state, action) {
return {state};
}
if (input.function === 'loadBlockData') {
const height = input.height;
const throwError = input.throwError;
const blockData = await SmartWeave.safeArweaveGet(
throwError
? `/blockkkk/height/${height}`
: `/block/height/${height}`
);
if (!state.blocks) {
state.blocks = {};
}
state.blocks["" + height] = blockData.indep_hash;
return { state };
}
if (input.function === 'dispatchEvent') {
return {
state,