-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adding PoA to 3SpeakApp * chore: pinning debug, fix CumulativeSize * tweak: add date to * partial: pinning progress * PoA access fixes Refactoring and optimizing * Fix for pin page issue * Update proofofaccess releases path * partial: dag import ipfs * partial: wire up pinning progress indicator * Keep PoA running when changing pages --------- Co-authored-by: vaultec <47548474+vaultec81@users.noreply.github.com>
- Loading branch information
1 parent
e1afcf1
commit cd4409b
Showing
70 changed files
with
3,586 additions
and
2,136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react'; | ||
import { FaCogs } from 'react-icons/fa'; | ||
export const CustomToggle = React.forwardRef<any, any>(({ children, onClick }, ref) => ( | ||
<button | ||
style={{ float: 'right' }} | ||
ref={ref} | ||
onClick={(e) => { | ||
e.preventDefault(); | ||
onClick(e); | ||
}} | ||
className="btn btn-sm dropdown-toggle btn-secondary" | ||
id="videoOptions" | ||
type="button" | ||
data-toggle="dropdown" | ||
> | ||
<FaCogs /> | ||
</button> | ||
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import { FaSitemap } from 'react-icons/fa'; | ||
import * as IPFSHTTPClient from 'ipfs-http-client'; | ||
import { IPFS_HOST } from '../common/constants'; | ||
|
||
let ipfsClient; | ||
try { | ||
ipfsClient = IPFSHTTPClient.create({ host: IPFS_HOST }); | ||
} catch (error) { | ||
console.error(`Error creating IPFS client in watch.tsx: `, error); | ||
throw error; | ||
} | ||
|
||
export function DHTProviders(props) { | ||
const [peers, setPeers] = useState(0); | ||
|
||
useEffect(() => { | ||
void load(); | ||
|
||
async function load() { | ||
if (!props.rootCid) { | ||
return; | ||
} | ||
let out = 0; | ||
for await (const pov of ipfsClient.dht.findProvs(props.rootCid)) { | ||
out = out + 1; | ||
setPeers(out); | ||
} | ||
setPeers(out); | ||
} | ||
}, []); | ||
|
||
return ( | ||
<div> | ||
<FaSitemap /> DHT Providers <strong>{peers}</strong> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import os from 'os'; | ||
import Path from 'path'; | ||
import fs from 'fs'; | ||
import axios from 'axios'; | ||
import compareVersions from 'compare-versions'; | ||
import { EventEmitter } from 'events'; | ||
|
||
const isWin = process.platform === 'win32'; | ||
|
||
class PoAInstaller extends EventEmitter { | ||
async main() { | ||
try { | ||
await this.install(); | ||
} catch (error) { | ||
console.error(error); | ||
this.emit('error', error); | ||
process.exit(1); | ||
} | ||
} | ||
async getCurrentVersion(installDir) { | ||
const versionFilePath = Path.join(installDir, 'version.txt'); | ||
try { | ||
const currentVersion = await fs.promises.readFile(versionFilePath, 'utf-8'); | ||
return currentVersion.trim(); | ||
} catch (error) { | ||
// If the file doesn't exist or there is an error reading it, return a default version | ||
return '0.0.0'; | ||
} | ||
} | ||
async getDefaultPath() { | ||
let defaultPath; | ||
switch (process.platform) { | ||
case 'win32': | ||
defaultPath = Path.join('AppData/Roaming/Microsoft/Windows/Start Menu/Programs/PoA'); | ||
return defaultPath; | ||
case 'darwin': | ||
defaultPath = Path.join(os.homedir(), 'Applications/PoA/poa'); | ||
break; | ||
case 'linux': | ||
defaultPath = Path.join(os.homedir(), 'bin/PoA/poa'); | ||
break; | ||
default: | ||
throw new Error(`Unsupported platform: ${process.platform}`); | ||
} | ||
|
||
// Check if the default path exists | ||
try { | ||
await fs.promises.access(defaultPath, fs.constants.F_OK); | ||
return defaultPath; | ||
} catch (error) { | ||
// Default path does not exist, return null | ||
return null; | ||
} | ||
} | ||
async install() { | ||
const installDir = Path.join(os.homedir(), (await this.getDefaultPath()) || ''); | ||
console.log(`Installing PoA to ${installDir}`); | ||
if (!fs.existsSync(installDir)) { | ||
fs.mkdirSync(installDir, { recursive: true }); | ||
} | ||
|
||
console.log('Installing PoA...'); | ||
|
||
const { data } = await axios.get('https://api.github.com/repos/spknetwork/proofofaccess/releases/latest'); | ||
const { tag_name, assets } = data; | ||
|
||
console.log(tag_name); | ||
const currentVersion = await this.getCurrentVersion(installDir); | ||
if (compareVersions.compare(tag_name, currentVersion, '>')) { | ||
console.log('Update available'); | ||
this.emit('update-available', tag_name); | ||
const asset = assets.find((a) => a.name.includes('win-main') && a.name.includes('exe') && isWin); | ||
|
||
if (!asset) { | ||
console.error('Could not find PoA asset for this platform'); | ||
return; | ||
} | ||
|
||
console.log(`Downloading PoA for ${process.platform}...`); | ||
|
||
const response = await axios({ | ||
method: 'get', | ||
url: asset.browser_download_url, | ||
responseType: 'arraybuffer', | ||
}); | ||
|
||
const installPath = Path.join(installDir, 'PoA.exe'); | ||
|
||
fs.writeFileSync(installPath, Buffer.from(response.data)); | ||
|
||
console.log(`PoA installed at: ${installPath}`); | ||
this.emit('installed', installPath); | ||
|
||
// Update version.txt file | ||
const versionFilePath = Path.join(installDir, 'version.txt'); | ||
fs.writeFileSync(versionFilePath, tag_name); | ||
console.log(`Version ${tag_name} saved to ${versionFilePath}`); | ||
this.emit('version-updated', tag_name); | ||
} else { | ||
console.log('PoA is already up-to-date'); | ||
this.emit('up-to-date'); | ||
} | ||
} | ||
} | ||
|
||
export default PoAInstaller; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.