2a13da1a6c
* chore: gitignore for lib directory * build: packageing for webpack lib build * build: webpack config * feat: expose App component with beeApiUrl parameter * build: tsconfig for library build * build: main property of package json for tsc build * refactor: rename beeUrl option to beeApiUrl * refactor: manange config class instead of process.env calls * build: babelrc config * build: babel plugins and presets for webpack build * chore: serve.js chmod * build(refactor): webpack build * refactor: number notation * chore: webpack and package config change * build: add babel preset-env * chore: prepare script also builds component lib * feat: typegen * revert: set back prepare command * build: assets loader config * feat: beeDebugApiUrl * refactor: move test files to the test folder because of typegen * feat: locked api settings * chore: depcheck ignores * chore: types check script * ci: check types * ci: publish with library * chore: add webpack as devDep * chore: locked semver * chore: remove debug logging * style: webpack config * chore: react and react-dom as dependency * chore: package-lock * fix: clean package-lock init * refactor: fix versions in package.json
106 lines
2.8 KiB
TypeScript
106 lines
2.8 KiB
TypeScript
const OPTIMAL_CONNECTED_PEERS = 200
|
|
const OPTIMAL_POPULATION = 100000
|
|
const OPTIMAL_DEPTH = 12
|
|
|
|
interface Threshold {
|
|
minimumValue: number
|
|
explanation: string
|
|
score: number
|
|
}
|
|
|
|
type Thresholds = {
|
|
connectedPeers: Threshold[]
|
|
population: Threshold[]
|
|
depth: Threshold[]
|
|
}
|
|
|
|
type ThresholdValue = {
|
|
score: number
|
|
maximumScore: number
|
|
explanation: string
|
|
}
|
|
|
|
export type ThresholdValues = {
|
|
connectedPeers: ThresholdValue
|
|
population: ThresholdValue
|
|
depth: ThresholdValue
|
|
}
|
|
|
|
const GENERIC_ERROR = 'There may be issues with your Bee node or connection.'
|
|
|
|
const THRESHOLDS: Thresholds = {
|
|
connectedPeers: [
|
|
{
|
|
minimumValue: OPTIMAL_CONNECTED_PEERS,
|
|
explanation: `Perfect! ${OPTIMAL_CONNECTED_PEERS} or more connected peers indicate a healthy topology.`,
|
|
score: 2,
|
|
},
|
|
{
|
|
minimumValue: 1,
|
|
explanation: `Your Bee node is connected to peers, but this number should ideally be above ${OPTIMAL_CONNECTED_PEERS}. If you have only started your Bee node, this number may increase quickly.`,
|
|
score: 1,
|
|
},
|
|
{
|
|
minimumValue: 0,
|
|
explanation: 'Your Bee node has not connected to any peers. ' + GENERIC_ERROR,
|
|
score: 0,
|
|
},
|
|
],
|
|
population: [
|
|
{
|
|
minimumValue: OPTIMAL_POPULATION,
|
|
explanation:
|
|
'Perfect! Your Bee node seems to have a realistic value for the network size, which means everything is working well on your end.',
|
|
score: 2,
|
|
},
|
|
{
|
|
minimumValue: 1,
|
|
explanation: `Population is usually above ${OPTIMAL_POPULATION.toLocaleString()}. If the number does not increase within a few hours, there may be issues with your Bee node.`,
|
|
score: 1,
|
|
},
|
|
{
|
|
minimumValue: 0,
|
|
explanation: 'Your Bee node has no information on the network population. ' + GENERIC_ERROR,
|
|
score: 0,
|
|
},
|
|
],
|
|
depth: [
|
|
{
|
|
minimumValue: OPTIMAL_DEPTH,
|
|
explanation: 'Perfect! Your Bee node has the highest available depth.',
|
|
score: 2,
|
|
},
|
|
{
|
|
minimumValue: 1,
|
|
explanation: `Your Bee node is supposed to reach a depth of ${OPTIMAL_DEPTH} eventually. Stagnation or decrease in this number may indicate problems with your Bee node.`,
|
|
score: 1,
|
|
},
|
|
{
|
|
minimumValue: 0,
|
|
explanation: 'Your Bee node has not started building its topology yet. ' + GENERIC_ERROR,
|
|
score: 0,
|
|
},
|
|
],
|
|
}
|
|
|
|
export function pickThreshold(key: keyof Thresholds, value: number): ThresholdValue {
|
|
const thresholds = THRESHOLDS[key]
|
|
const maximumScore = thresholds[0].score
|
|
for (const item of thresholds) {
|
|
if (value >= item.minimumValue) {
|
|
return {
|
|
score: item.score,
|
|
maximumScore,
|
|
explanation: item.explanation,
|
|
}
|
|
}
|
|
}
|
|
const last = thresholds[thresholds.length - 1]
|
|
|
|
return {
|
|
score: last.score,
|
|
maximumScore,
|
|
explanation: last.explanation,
|
|
}
|
|
}
|