mirror of
https://github.com/logos-storage/ethcc-demo.git
synced 2026-01-08 08:03:11 +00:00
change slotState and requestState to object to avoid typos
This commit is contained in:
parent
09c4ed7daf
commit
56da727773
@ -30,12 +30,12 @@ export function price(request) {
|
||||
}
|
||||
|
||||
export function getStateColour(state) {
|
||||
if (state === 'New') {
|
||||
if (state === RequestState.New) {
|
||||
return 'yellow'
|
||||
} else if (state === 'Fulfilled') {
|
||||
} else if (state === RequestState.Fulfilled) {
|
||||
return 'green'
|
||||
} else if (state === 'Finished') {
|
||||
return 'gray'
|
||||
} else if (state === RequestState.Finished) {
|
||||
return 'blue'
|
||||
} else {
|
||||
return 'red'
|
||||
}
|
||||
@ -47,13 +47,17 @@ export const moderatedState = {
|
||||
banned: { text: 'NSFW! 🫣', color: 'red' }
|
||||
}
|
||||
|
||||
export const requestState = [
|
||||
'New', // [default] waiting to fill slots
|
||||
'Fulfilled', // all slots filled, accepting regular proofs
|
||||
'Cancelled', // not enough slots filled before expiry
|
||||
'Finished', // successfully completed
|
||||
'Failed' // too many nodes have failed to provide proofs, data lost
|
||||
]
|
||||
export const RequestState = {
|
||||
New: 'New', // [default] waiting to fill slots
|
||||
Fulfilled: 'Fulfilled', // all slots filled, accepting regular proofs
|
||||
Cancelled: 'Cancelled', // not enough slots filled before expiry
|
||||
Finished: 'Finished', // successfully completed
|
||||
Failed: 'Failed' // too many nodes have failed to provide proofs, data lost
|
||||
}
|
||||
|
||||
export function toRequestState(idx) {
|
||||
return Object.values(RequestState).at(idx)
|
||||
}
|
||||
|
||||
// all parameters in seconds, return values also in seconds
|
||||
export function timestampsFor(ask, expiryBigInt, requestedAt) {
|
||||
|
||||
@ -1,20 +1,24 @@
|
||||
export const slotState = [
|
||||
'Free', // [default] not filled yet, or host has vacated the slot
|
||||
'Filled', // host has filled slot
|
||||
'Finished', // successfully completed
|
||||
'Failed', // the request has failed
|
||||
'Paid', // host has been paid
|
||||
'Cancelled' // when request was cancelled then slot is cancelled as well
|
||||
]
|
||||
export const SlotState = {
|
||||
Free: 'Free', // [default] not filled yet, or host has vacated the slot
|
||||
Filled: 'Filled', // host has filled slot
|
||||
Finished: 'Finished', // successfully completed
|
||||
Failed: 'Failed', // the request has failed
|
||||
Paid: 'Paid', // host has been paid
|
||||
Cancelled: 'Cancelled' // when request was cancelled then slot is cancelled as well
|
||||
}
|
||||
|
||||
export function toSlotState(idx) {
|
||||
return Object.values(SlotState).at(idx)
|
||||
}
|
||||
|
||||
export function getStateColour(state) {
|
||||
if (state === 'Free') {
|
||||
if (state === SlotState.Free) {
|
||||
return 'yellow'
|
||||
} else if (state === 'Filled') {
|
||||
} else if (state === SlotState.Filled) {
|
||||
return 'green'
|
||||
} else if (state === 'Finished') {
|
||||
} else if (state === SlotState.Finished) {
|
||||
return 'blue'
|
||||
} else if (state === 'Paid') {
|
||||
} else if (state === SlotState.Paid) {
|
||||
return 'gray'
|
||||
} else {
|
||||
return 'red'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user