diff --git a/blocks/index.ts b/blocks/index.ts index 485d186..c4d0b21 100644 --- a/blocks/index.ts +++ b/blocks/index.ts @@ -82,8 +82,9 @@ async function setupPeriod(blockCount: number, startHeight: number, endHeight: n export async function bootstrapBlocks() { console.log(`Bootstrapping ${config.mode} block data...`); - const createBlock = config.mode === "fake" ? createFakeBlock : createRealBlock; - const callGetblockcount = config.mode === "fake" ? async () => await Promise.resolve(1000) : getblockcount; + const createBlock = config.mode === "fake" || config.mode === "fake-frontend" ? createFakeBlock : createRealBlock; + const callGetblockcount = + config.mode === "fake" || config.mode === "fake-frontend" ? async () => await Promise.resolve(1000) : getblockcount; let blockCount = await callGetblockcount(); const difficultyPeriodStartHeight = blockCount - (blockCount % 2016); diff --git a/frontend/state/index.ts b/frontend/state/index.ts index 979701c..a30f7b2 100644 --- a/frontend/state/index.ts +++ b/frontend/state/index.ts @@ -12,10 +12,43 @@ export interface IStoreModel { export const model: IStoreModel = { getBlocks: thunk(async (actions) => { - const result = await fetch(`/blocks`); - const json = (await result.json()) as IBlock[]; - console.log(json); - actions.setBlocks(json); + if (config.mode === "real" || config.mode === "fake") { + const result = await fetch(`/blocks`); + const json = (await result.json()) as IBlock[]; + console.log(json); + actions.setBlocks(json); + } else { + const start = 0; + const end = 1500; + const blocks: IBlock[] = []; + for (let i = start; i < 2016; i++) { + if (i < end) { + if (Math.floor(Math.random() * 100 + 1) > 20) { + blocks.push({ + height: i, + signals: true, + miner: "abc", + minerWebsite: undefined, + }); + } else { + blocks.push({ + height: i, + signals: false, + miner: "def", + minerWebsite: undefined, + }); + } + } else { + blocks.push({ + height: i, + signals: undefined, + miner: undefined, + minerWebsite: undefined, + }); + } + } + actions.setBlocks(blocks); + } }), autoRefresh: thunk((actions) => { diff --git a/vercel.json b/vercel.json new file mode 100644 index 0000000..813f277 --- /dev/null +++ b/vercel.json @@ -0,0 +1,7 @@ +{ + "functions": { + "build-frontend.sh": { + "runtime": "vercel-deno@0.7.10" + } + } +}