mirror of
https://github.com/stronk-dev/LivepeerEvents.git
synced 2025-07-05 10:45:10 +02:00
Moved orchestrator info to global state, smarter caching when getting it
This commit is contained in:
parent
6572385906
commit
362660d690
@ -1251,6 +1251,25 @@ apiRouter.get("/getAllOrchScores", async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Returns entire orch info cache
|
||||||
|
apiRouter.get("/getAllOrchInfo", async (req, res) => {
|
||||||
|
try {
|
||||||
|
res.send(orchestratorCache);
|
||||||
|
} catch (err) {
|
||||||
|
res.status(400).send(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Returns entire delegator info cache
|
||||||
|
apiRouter.get("/getAllDelInfo", async (req, res) => {
|
||||||
|
try {
|
||||||
|
res.send(delegatorCache);
|
||||||
|
} catch (err) {
|
||||||
|
res.status(400).send(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export default apiRouter;
|
export default apiRouter;
|
@ -21,6 +21,7 @@ export const RECEIVE_QUOTES = "RECEIVE_QUOTES";
|
|||||||
export const RECEIVE_BLOCKCHAIN_DATA = "RECEIVE_BLOCKCHAIN_DATA";
|
export const RECEIVE_BLOCKCHAIN_DATA = "RECEIVE_BLOCKCHAIN_DATA";
|
||||||
export const RECEIVE_EVENTS = "RECEIVE_EVENTS";
|
export const RECEIVE_EVENTS = "RECEIVE_EVENTS";
|
||||||
export const RECEIVE_CURRENT_ORCHESTRATOR = "RECEIVE_CURRENT_ORCHESTRATOR";
|
export const RECEIVE_CURRENT_ORCHESTRATOR = "RECEIVE_CURRENT_ORCHESTRATOR";
|
||||||
|
export const CACHE_ORCHESTRATOR = "CACHE_ORCHESTRATOR";
|
||||||
export const RECEIVE_ORCHESTRATOR = "RECEIVE_ORCHESTRATOR";
|
export const RECEIVE_ORCHESTRATOR = "RECEIVE_ORCHESTRATOR";
|
||||||
export const CLEAR_ORCHESTRATOR = "CLEAR_ORCHESTRATOR";
|
export const CLEAR_ORCHESTRATOR = "CLEAR_ORCHESTRATOR";
|
||||||
export const RECEIVE_TICKETS = "RECEIVE_TICKETS";
|
export const RECEIVE_TICKETS = "RECEIVE_TICKETS";
|
||||||
@ -29,6 +30,8 @@ export const SET_ALL_ENS_INFO = "SET_ALL_ENS_INFO";
|
|||||||
export const SET_ALL_ENS_DOMAINS = "SET_ALL_ENS_DOMAINS";
|
export const SET_ALL_ENS_DOMAINS = "SET_ALL_ENS_DOMAINS";
|
||||||
export const SET_ALL_THREEBOX_INFO = "SET_ALL_THREEBOX_INFO";
|
export const SET_ALL_THREEBOX_INFO = "SET_ALL_THREEBOX_INFO";
|
||||||
export const SET_ALL_ORCH_SCORES = "SET_ALL_ORCH_SCORES";
|
export const SET_ALL_ORCH_SCORES = "SET_ALL_ORCH_SCORES";
|
||||||
|
export const SET_ALL_ORCH_INFO = "SET_ALL_ORCH_INFO";
|
||||||
|
export const SET_ALL_DEL_INFO = "SET_ALL_DEL_INFO";
|
||||||
|
|
||||||
const setQuotes = message => ({
|
const setQuotes = message => ({
|
||||||
type: RECEIVE_QUOTES, message
|
type: RECEIVE_QUOTES, message
|
||||||
@ -42,6 +45,9 @@ const setEvents = message => ({
|
|||||||
const setCurrentOrchestratorInfo = message => ({
|
const setCurrentOrchestratorInfo = message => ({
|
||||||
type: RECEIVE_CURRENT_ORCHESTRATOR, message
|
type: RECEIVE_CURRENT_ORCHESTRATOR, message
|
||||||
});
|
});
|
||||||
|
const cacheNewOrch = message => ({
|
||||||
|
type: CACHE_ORCHESTRATOR, message
|
||||||
|
});
|
||||||
const setOrchestratorInfo = message => ({
|
const setOrchestratorInfo = message => ({
|
||||||
type: RECEIVE_ORCHESTRATOR, message
|
type: RECEIVE_ORCHESTRATOR, message
|
||||||
});
|
});
|
||||||
@ -66,6 +72,14 @@ const setAllThreeBoxInfo = message => ({
|
|||||||
const setAllOrchScores = message => ({
|
const setAllOrchScores = message => ({
|
||||||
type: SET_ALL_ORCH_SCORES, message
|
type: SET_ALL_ORCH_SCORES, message
|
||||||
});
|
});
|
||||||
|
const setAllOrchInfo = message => ({
|
||||||
|
type: SET_ALL_ORCH_INFO, message
|
||||||
|
});
|
||||||
|
|
||||||
|
const setAllDelInfo = message => ({
|
||||||
|
type: SET_ALL_DEL_INFO, message
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export const getQuotes = () => async dispatch => {
|
export const getQuotes = () => async dispatch => {
|
||||||
@ -145,13 +159,13 @@ export const getEvents = () => async dispatch => {
|
|||||||
tmpAmount.toFixed(2) + " LPT stake",
|
tmpAmount.toFixed(2) + " LPT stake",
|
||||||
"round " + tmpWhen
|
"round " + tmpWhen
|
||||||
]
|
]
|
||||||
eventDescription = <Ticket icon={"🚀"} subtext={subtext} descriptions={descriptions} />
|
eventDescription = <Ticket seed={currentTx+descriptions} icon={"🚀"} subtext={subtext} descriptions={descriptions} />
|
||||||
} else {
|
} else {
|
||||||
const subtext = "reactivated";
|
const subtext = "reactivated";
|
||||||
const descriptions = [
|
const descriptions = [
|
||||||
"round " + tmpWhen
|
"round " + tmpWhen
|
||||||
]
|
]
|
||||||
eventDescription = <Ticket icon={"🚀"} subtext={subtext} descriptions={descriptions} />
|
eventDescription = <Ticket seed={currentTx+descriptions} icon={"🚀"} subtext={subtext} descriptions={descriptions} />
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Lone Unbond => Unbond Event
|
// Lone Unbond => Unbond Event
|
||||||
@ -164,7 +178,7 @@ export const getEvents = () => async dispatch => {
|
|||||||
"round " + tmpWhen
|
"round " + tmpWhen
|
||||||
]
|
]
|
||||||
eventDescription =
|
eventDescription =
|
||||||
<Ticket icon={"❌"} subtext={subtext} descriptions={descriptions} />
|
<Ticket seed={currentTx+descriptions} icon={"❌"} subtext={subtext} descriptions={descriptions} />
|
||||||
}
|
}
|
||||||
// Lone Bond => Stake Event
|
// Lone Bond => Stake Event
|
||||||
else if (eventContainsBond) {
|
else if (eventContainsBond) {
|
||||||
@ -180,7 +194,7 @@ export const getEvents = () => async dispatch => {
|
|||||||
tmpAmount.toFixed(2) + " LPT"
|
tmpAmount.toFixed(2) + " LPT"
|
||||||
]
|
]
|
||||||
eventDescription =
|
eventDescription =
|
||||||
<Ticket icon={"⌛"} subtext={subtext} descriptions={descriptions} />
|
<Ticket seed={currentTx+descriptions} icon={"⌛"} subtext={subtext} descriptions={descriptions} />
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill description of Stake Event if it wasn't set yet
|
// Fill description of Stake Event if it wasn't set yet
|
||||||
@ -191,7 +205,7 @@ export const getEvents = () => async dispatch => {
|
|||||||
tmpAmount.toFixed(2) + " LPT"
|
tmpAmount.toFixed(2) + " LPT"
|
||||||
]
|
]
|
||||||
eventDescription =
|
eventDescription =
|
||||||
<Ticket icon={"⌛"} subtext={subtext} descriptions={descriptions} />
|
<Ticket seed={currentTx+descriptions} icon={"⌛"} subtext={subtext} descriptions={descriptions} />
|
||||||
} else if (eventFrom === eventTo) {
|
} else if (eventFrom === eventTo) {
|
||||||
eventFrom = "";
|
eventFrom = "";
|
||||||
const subtext = "changed stake";
|
const subtext = "changed stake";
|
||||||
@ -199,14 +213,14 @@ export const getEvents = () => async dispatch => {
|
|||||||
tmpAmount.toFixed(2) + " LPT"
|
tmpAmount.toFixed(2) + " LPT"
|
||||||
]
|
]
|
||||||
eventDescription =
|
eventDescription =
|
||||||
<Ticket icon={"⌛"} subtext={subtext} descriptions={descriptions} />
|
<Ticket seed={currentTx+descriptions} icon={"⌛"} subtext={subtext} descriptions={descriptions} />
|
||||||
} else {
|
} else {
|
||||||
const subtext = "moved stake";
|
const subtext = "moved stake";
|
||||||
const descriptions = [
|
const descriptions = [
|
||||||
tmpAmount.toFixed(2) + " LPT"
|
tmpAmount.toFixed(2) + " LPT"
|
||||||
]
|
]
|
||||||
eventDescription =
|
eventDescription =
|
||||||
<Ticket icon={"⌛"} subtext={subtext} descriptions={descriptions} />
|
<Ticket seed={currentTx+descriptions} icon={"⌛"} subtext={subtext} descriptions={descriptions} />
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -263,7 +277,7 @@ export const getEvents = () => async dispatch => {
|
|||||||
"round " + eventObj.data.withdrawRound
|
"round " + eventObj.data.withdrawRound
|
||||||
]
|
]
|
||||||
const txt =
|
const txt =
|
||||||
<Ticket icon={"🏦"} subtext={subtext} descriptions={descriptions} />
|
<Ticket seed={currentTx+descriptions} icon={"🏦"} subtext={subtext} descriptions={descriptions} />
|
||||||
finalEventList.push({
|
finalEventList.push({
|
||||||
eventType: "Withdraw",
|
eventType: "Withdraw",
|
||||||
eventDescription: txt,
|
eventDescription: txt,
|
||||||
@ -287,7 +301,7 @@ export const getEvents = () => async dispatch => {
|
|||||||
amount.toFixed(4) + " Eth"
|
amount.toFixed(4) + " Eth"
|
||||||
]
|
]
|
||||||
const txt =
|
const txt =
|
||||||
<Ticket icon={"🏦"} subtext={subtext} descriptions={descriptions} />
|
<Ticket seed={currentTx+descriptions} icon={"🏦"} subtext={subtext} descriptions={descriptions} />
|
||||||
finalEventList.push({
|
finalEventList.push({
|
||||||
eventType: "Withdraw",
|
eventType: "Withdraw",
|
||||||
eventDescription: txt,
|
eventDescription: txt,
|
||||||
@ -313,7 +327,7 @@ export const getEvents = () => async dispatch => {
|
|||||||
amount2.toFixed(2) + "% on transcoding fees"
|
amount2.toFixed(2) + "% on transcoding fees"
|
||||||
]
|
]
|
||||||
const txt =
|
const txt =
|
||||||
<Ticket icon={"🔄"} subtext={subtext} descriptions={descriptions} />
|
<Ticket seed={currentTx+descriptions} icon={"🔄"} subtext={subtext} descriptions={descriptions} />
|
||||||
finalEventList.push({
|
finalEventList.push({
|
||||||
eventType: "Update",
|
eventType: "Update",
|
||||||
eventDescription: txt,
|
eventDescription: txt,
|
||||||
@ -343,7 +357,7 @@ export const getEvents = () => async dispatch => {
|
|||||||
"+" + amount2.toFixed(4) + " Eth fees"
|
"+" + amount2.toFixed(4) + " Eth fees"
|
||||||
]
|
]
|
||||||
let txt =
|
let txt =
|
||||||
<Ticket icon={"💰"} subtext={subtext} descriptions={descriptions} />
|
<Ticket seed={currentTx+descriptions} icon={"💰"} subtext={subtext} descriptions={descriptions} />
|
||||||
finalEventList.push({
|
finalEventList.push({
|
||||||
eventType: "Claim",
|
eventType: "Claim",
|
||||||
eventDescription: txt,
|
eventDescription: txt,
|
||||||
@ -367,7 +381,7 @@ export const getEvents = () => async dispatch => {
|
|||||||
"+" + amount1.toFixed(2) + " LPT" + (Math.floor(amount1) == 69 ? "... Nice!" : "")
|
"+" + amount1.toFixed(2) + " LPT" + (Math.floor(amount1) == 69 ? "... Nice!" : "")
|
||||||
]
|
]
|
||||||
const txt =
|
const txt =
|
||||||
<Ticket icon={"💸"} subtext={subtext} descriptions={descriptions} />
|
<Ticket seed={currentTx+descriptions} icon={"💸"} subtext={subtext} descriptions={descriptions} />
|
||||||
finalEventList.push({
|
finalEventList.push({
|
||||||
eventType: "Reward",
|
eventType: "Reward",
|
||||||
eventDescription: txt,
|
eventDescription: txt,
|
||||||
@ -469,7 +483,7 @@ export const getTickets = () => async dispatch => {
|
|||||||
"+" + amount.toFixed(4) + " Eth"
|
"+" + amount.toFixed(4) + " Eth"
|
||||||
]
|
]
|
||||||
const txt =
|
const txt =
|
||||||
<Ticket icon={"🎟️"} subtext={subtext} descriptions={descriptions} />
|
<Ticket seed={currentTx+descriptions} icon={"🎟️"} subtext={subtext} descriptions={descriptions} />
|
||||||
finalTicketList.push({
|
finalTicketList.push({
|
||||||
eventType: "RedeemTicket",
|
eventType: "RedeemTicket",
|
||||||
eventDescription: txt,
|
eventDescription: txt,
|
||||||
@ -526,11 +540,14 @@ export const getOrchestratorInfo = (orchAddr) => async dispatch => {
|
|||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
if (data && data.id) {
|
if (data && data.id) {
|
||||||
|
console.log(data);
|
||||||
|
dispatch(cacheNewOrch(data));
|
||||||
return dispatch(setOrchestratorInfo(data));
|
return dispatch(setOrchestratorInfo(data));
|
||||||
} else {
|
} else {
|
||||||
const response = await apiUtil.getOrchestratorByDelegator(orchAddr);
|
const response = await apiUtil.getOrchestratorByDelegator(orchAddr);
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
|
dispatch(cacheNewOrch(data));
|
||||||
return dispatch(setOrchestratorInfo(data));
|
return dispatch(setOrchestratorInfo(data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -538,6 +555,10 @@ export const getOrchestratorInfo = (orchAddr) => async dispatch => {
|
|||||||
return dispatch(receiveErrors(data));
|
return dispatch(receiveErrors(data));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const setCachedOrch = (orchObj) => async dispatch => {
|
||||||
|
return dispatch(setOrchestratorInfo(orchObj));
|
||||||
|
};
|
||||||
|
|
||||||
export const clearOrchestrator = () => async dispatch => {
|
export const clearOrchestrator = () => async dispatch => {
|
||||||
return dispatch(clearOrchestratorInfo({}));
|
return dispatch(clearOrchestratorInfo({}));
|
||||||
};
|
};
|
||||||
@ -587,9 +608,26 @@ export const getOrchestratorScores = (year, month) => async dispatch => {
|
|||||||
export const getAllOrchScores = () => async dispatch => {
|
export const getAllOrchScores = () => async dispatch => {
|
||||||
const response = await apiUtil.getAllOrchScores();
|
const response = await apiUtil.getAllOrchScores();
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
console.log(data);
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
return dispatch(setAllOrchScores(data));
|
return dispatch(setAllOrchScores(data));
|
||||||
}
|
}
|
||||||
return dispatch(receiveErrors(data));
|
return dispatch(receiveErrors(data));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getAllOrchInfo = () => async dispatch => {
|
||||||
|
const response = await apiUtil.getAllOrchInfo();
|
||||||
|
const data = await response.json();
|
||||||
|
if (response.ok) {
|
||||||
|
return dispatch(setAllOrchInfo(data));
|
||||||
|
}
|
||||||
|
return dispatch(receiveErrors(data));
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getAllDelInfo = () => async dispatch => {
|
||||||
|
const response = await apiUtil.getAllDelInfo();
|
||||||
|
const data = await response.json();
|
||||||
|
if (response.ok) {
|
||||||
|
return dispatch(setAllDelInfo(data));
|
||||||
|
}
|
||||||
|
return dispatch(receiveErrors(data));
|
||||||
|
};
|
@ -17,7 +17,7 @@ const Ticket = (obj) => {
|
|||||||
<div className="stroke" style={{ flex: 2 }}>
|
<div className="stroke" style={{ flex: 2 }}>
|
||||||
{obj.descriptions.map(function (thisTextItem, i) {
|
{obj.descriptions.map(function (thisTextItem, i) {
|
||||||
return (
|
return (
|
||||||
<p className="smallTxt">
|
<p className="smallTxt" key={obj.seed}>
|
||||||
{thisTextItem}
|
{thisTextItem}
|
||||||
</p>
|
</p>
|
||||||
)
|
)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import {
|
import {
|
||||||
getOrchestratorInfo, getEnsInfo, getThreeBoxInfo
|
getOrchestratorInfo, getEnsInfo, getThreeBoxInfo, setCachedOrch
|
||||||
} from "../actions/livepeer";
|
} from "../actions/livepeer";
|
||||||
import { useDispatch, useSelector } from 'react-redux';
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
|
|
||||||
@ -126,7 +126,22 @@ const EventButtonAddress = (obj) => {
|
|||||||
</button>
|
</button>
|
||||||
<span>{obj.name}</span>
|
<span>{obj.name}</span>
|
||||||
{thisIcon}
|
{thisIcon}
|
||||||
<button className="selectOrch" style={{ padding: '0.5em', cursor: 'help' }} onClick={() => { dispatch(getOrchestratorInfo(obj.address)) }} >
|
<button className="selectOrch" style={{ padding: '0.5em', cursor: 'help' }} onClick={() => {
|
||||||
|
// Check if cached as an orchestrator
|
||||||
|
if (livepeer.orchInfo) {
|
||||||
|
for (const thisOrch of livepeer.orchInfo) {
|
||||||
|
if (thisOrch.id === obj.address) {
|
||||||
|
const now = new Date().getTime();
|
||||||
|
if (now - thisOrch.lastGet < 120000) {
|
||||||
|
dispatch(setCachedOrch(thisOrch));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dispatch(getOrchestratorInfo(obj.address));
|
||||||
|
}} >
|
||||||
{thisName}
|
{thisName}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -23,9 +23,10 @@ const Livepeer = (obj) => {
|
|||||||
console.log("Rendering Livepeer");
|
console.log("Rendering Livepeer");
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (prefill.get('orchAddr') && prefill.get('orchAddr') !== "") {
|
const searchOrch = prefill.get('orchAddr');
|
||||||
dispatch(getOrchestratorInfo(prefill.get('orchAddr')));
|
if (searchOrch && searchOrch !== "") {
|
||||||
setSearchTerm(prefill.get('orchAddr'));
|
dispatch(getOrchestratorInfo(searchOrch));
|
||||||
|
setSearchTerm(searchOrch);
|
||||||
}
|
}
|
||||||
}, [prefill]);
|
}, [prefill]);
|
||||||
|
|
||||||
|
@ -5,7 +5,8 @@ import {
|
|||||||
} from "../actions/user";
|
} from "../actions/user";
|
||||||
import {
|
import {
|
||||||
getQuotes, getBlockchainData, getEvents, getCurrentOrchestratorInfo, getTickets,
|
getQuotes, getBlockchainData, getEvents, getCurrentOrchestratorInfo, getTickets,
|
||||||
getAllEnsDomains, getAllEnsInfo, getAllThreeBoxInfo, getAllOrchScores
|
getAllEnsDomains, getAllEnsInfo, getAllThreeBoxInfo, getAllOrchScores, getAllOrchInfo,
|
||||||
|
getAllDelInfo
|
||||||
} from "../actions/livepeer";
|
} from "../actions/livepeer";
|
||||||
import { login } from "../actions/session";
|
import { login } from "../actions/session";
|
||||||
|
|
||||||
@ -43,6 +44,14 @@ const Startup = (obj) => {
|
|||||||
dispatch(getAllThreeBoxInfo());
|
dispatch(getAllThreeBoxInfo());
|
||||||
dispatch(getAllEnsDomains());
|
dispatch(getAllEnsDomains());
|
||||||
dispatch(getAllEnsInfo());
|
dispatch(getAllEnsInfo());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const refreshStaticProps = () => {
|
||||||
|
console.log("Refreshing global data...");
|
||||||
|
batch(() => {
|
||||||
|
dispatch(getAllOrchInfo());
|
||||||
|
dispatch(getAllDelInfo());
|
||||||
dispatch(getAllOrchScores());
|
dispatch(getAllOrchScores());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -51,6 +60,7 @@ const Startup = (obj) => {
|
|||||||
refreshLogin();
|
refreshLogin();
|
||||||
refreshAllZeData();
|
refreshAllZeData();
|
||||||
refreshENS();
|
refreshENS();
|
||||||
|
refreshStaticProps();
|
||||||
setIsLoaded(true);
|
setIsLoaded(true);
|
||||||
if (refreshInterval) {
|
if (refreshInterval) {
|
||||||
const interval = setInterval(refreshAllZeData, refreshInterval);
|
const interval = setInterval(refreshAllZeData, refreshInterval);
|
||||||
|
@ -202,7 +202,7 @@ const Tickets = (obj) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Accordion.Item
|
<Accordion.Item
|
||||||
label={data.year + "-" + thisMonth + ": " + data.orchestrators.length + " orchestrators earned " + data.total.toFixed(4) + " Eth"}
|
label={data.year + "-" + thisMonth + ": " + data.orchestrators.length + " orchestrators earned " + data.total.toFixed(2) + " Eth"}
|
||||||
className="stroke"
|
className="stroke"
|
||||||
key={data.year + "-" + data.month + "-" + data.total}>
|
key={data.year + "-" + data.month + "-" + data.total}>
|
||||||
<WinnerMonth
|
<WinnerMonth
|
||||||
|
@ -10,7 +10,10 @@ import {
|
|||||||
SET_ALL_ENS_INFO,
|
SET_ALL_ENS_INFO,
|
||||||
SET_ALL_ENS_DOMAINS,
|
SET_ALL_ENS_DOMAINS,
|
||||||
SET_ALL_THREEBOX_INFO,
|
SET_ALL_THREEBOX_INFO,
|
||||||
SET_ALL_ORCH_SCORES
|
SET_ALL_ORCH_SCORES,
|
||||||
|
SET_ALL_ORCH_INFO,
|
||||||
|
SET_ALL_DEL_INFO,
|
||||||
|
CACHE_ORCHESTRATOR
|
||||||
} from "../../actions/livepeer";
|
} from "../../actions/livepeer";
|
||||||
|
|
||||||
export default (state = {
|
export default (state = {
|
||||||
@ -51,6 +54,41 @@ export default (state = {
|
|||||||
return { ...state, threeBoxInfo: message };
|
return { ...state, threeBoxInfo: message };
|
||||||
case SET_ALL_ORCH_SCORES:
|
case SET_ALL_ORCH_SCORES:
|
||||||
return { ...state, orchScores: message };
|
return { ...state, orchScores: message };
|
||||||
|
case SET_ALL_ORCH_INFO:
|
||||||
|
return { ...state, orchInfo: message };
|
||||||
|
case CACHE_ORCHESTRATOR:
|
||||||
|
let isCached = false;
|
||||||
|
// Check to see if it is already cached
|
||||||
|
if (state.orchInfo) {
|
||||||
|
for (const thisOrch of state.orchInfo) {
|
||||||
|
if (thisOrch.id === message.id) {
|
||||||
|
isCached = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If cached, lookup and modify existing entry
|
||||||
|
if (isCached) {
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
contents: state.orchInfo.map(
|
||||||
|
(content) => {
|
||||||
|
if (content.id == message.id) {
|
||||||
|
return message;
|
||||||
|
} else {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
orchInfo: [...state.orchInfo, message]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
case SET_ALL_DEL_INFO:
|
||||||
|
return { ...state, delInfo: message };
|
||||||
default:
|
default:
|
||||||
return { ...state };
|
return { ...state };
|
||||||
}
|
}
|
||||||
|
@ -126,3 +126,21 @@ export const getAllOrchScores = () => (
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const getAllOrchInfo = () => (
|
||||||
|
fetch("api/livepeer/getAllOrchInfo", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
export const getAllDelInfo = () => (
|
||||||
|
fetch("api/livepeer/getAllDelInfo", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
Loading…
x
Reference in New Issue
Block a user