Commit 9796c04d authored by Noah Zinsmeister's avatar Noah Zinsmeister Committed by GitHub

slow down polling interval (#420)

parent 54ef6518
...@@ -68,11 +68,23 @@ export default function Provider({ children }) { ...@@ -68,11 +68,23 @@ export default function Provider({ children }) {
} }
export function Updater() { export function Updater() {
const { networkId, library } = useWeb3Context() const { networkId, library, connectorName } = useWeb3Context()
const globalBlockNumber = useBlockNumber() const globalBlockNumber = useBlockNumber()
const [, { updateBlockNumber, updateUSDPrice }] = useApplicationContext() const [, { updateBlockNumber, updateUSDPrice }] = useApplicationContext()
// slow down polling interval
useEffect(() => {
if (library) {
if (connectorName === 'Network') {
library.pollingInterval = 15
} else {
library.pollingInterval = 5
}
}
}, [library, connectorName])
// update usd price
useEffect(() => { useEffect(() => {
let stale = false let stale = false
...@@ -89,6 +101,7 @@ export function Updater() { ...@@ -89,6 +101,7 @@ export function Updater() {
}) })
}, [globalBlockNumber, library, networkId, updateUSDPrice]) }, [globalBlockNumber, library, networkId, updateUSDPrice])
// update block number
useEffect(() => { useEffect(() => {
if ((networkId || networkId === 0) && library) { if ((networkId || networkId === 0) && library) {
let stale = false let stale = false
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment