Browse Source

Attempt to enable Vercel for the project

master
Hampus Sjöberg 4 years ago
parent
commit
17f34dab65
  1. 5
      blocks/index.ts
  2. 41
      frontend/state/index.ts
  3. 7
      vercel.json

5
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);

41
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) => {

7
vercel.json

@ -0,0 +1,7 @@
{
"functions": {
"build-frontend.sh": {
"runtime": "vercel-deno@0.7.10"
}
}
}
Loading…
Cancel
Save