From 7cd2b2e0a220bb0b347d9eb8519b1a6e68e4fde1 Mon Sep 17 00:00:00 2001 From: vaultec <47548474+vaultec81@users.noreply.github.com> Date: Mon, 31 May 2021 20:51:35 -0700 Subject: [PATCH] feat (watch): dht provider widget --- src/renderer/views/watch.js | 49 ++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/src/renderer/views/watch.js b/src/renderer/views/watch.js index fbea35f..b593892 100644 --- a/src/renderer/views/watch.js +++ b/src/renderer/views/watch.js @@ -1,8 +1,8 @@ -import React from 'react'; +import React, {useState, useEffect} from 'react'; import Player from '../components/video/Player'; import { Col, Row, Container, Dropdown, Tabs, Tab } from 'react-bootstrap'; import utils from '../utils'; -import { FaThumbsUp, FaThumbsDown, FaCogs, FaDownload } from 'react-icons/fa'; +import { FaThumbsUp, FaThumbsDown, FaCogs, FaDownload, FaSitemap } from 'react-icons/fa'; import { BsInfoSquare } from 'react-icons/bs'; import DateTime from 'date-and-time'; import ReactMarkdown from 'react-markdown'; @@ -29,6 +29,7 @@ import 'brace/mode/json'; import 'brace/theme/github'; import ArraySearch from 'arraysearch'; import Knex from 'knex' +import IPFSHTTPClient from 'ipfs-http-client' import Consts from '../../consts' const debug = Debug("3speak:watch") const Finder = ArraySearch.Finder; @@ -46,6 +47,33 @@ const knex = Knex({ } }); +const ipfsClient = new IPFSHTTPClient('/ip4/127.0.0.1/tcp/5001') +function DHTProviders(props) { + const [peers, setPeers] = useState(0) + useEffect(() => { + (async () => { + if(!props.rootCid) { + return; + } + console.log(ipfsClient) + console.log(props.rootCid) + let out = 0; + for await(const pov of ipfsClient.dht.findProvs(props.rootCid)) { + console.log(pov) + out = out + 1; + setPeers(out) + } + setPeers(out) + })(); + return () => { + + } + }, []) + return