pond: Basic storage client
This commit is contained in:
parent
6a4af984af
commit
604eeaa36b
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/rand"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/filecoin-project/go-lotus/lib/jsonrpc"
|
"github.com/filecoin-project/go-lotus/lib/jsonrpc"
|
||||||
"io"
|
"io"
|
||||||
@ -203,6 +204,24 @@ func (api *api) SpawnStorage(fullNodeRepo string) (nodeInfo, error) {
|
|||||||
return info, nil
|
return info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (api *api) CreateRandomFile(size int64) (string, error) {
|
||||||
|
tf, err := ioutil.TempFile(os.TempDir(), "pond-random-")
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = io.CopyN(tf, rand.Reader, size)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := tf.Close(); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return tf.Name(), nil
|
||||||
|
}
|
||||||
|
|
||||||
type client struct {
|
type client struct {
|
||||||
Nodes func() []nodeInfo
|
Nodes func() []nodeInfo
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,9 @@ class ChainExplorer extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fetch(h, cache, msgcache) {
|
async fetch(h, cache, msgcache) {
|
||||||
|
if (h < 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
const cids = cache[h + 1].Blocks.map(b => b.Parents).reduce((acc, val) => acc.concat(val), [])
|
const cids = cache[h + 1].Blocks.map(b => b.Parents).reduce((acc, val) => acc.concat(val), [])
|
||||||
const blocks = await Promise.all(cids.map(cid => this.props.client.call('Filecoin.ChainGetBlock', [cid])))
|
const blocks = await Promise.all(cids.map(cid => this.props.client.call('Filecoin.ChainGetBlock', [cid])))
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Client } from 'rpc-websockets'
|
|
||||||
import Cristal from 'react-cristal'
|
import Cristal from 'react-cristal'
|
||||||
import { BlockLinks } from "./BlockLink";
|
import { BlockLinks } from "./BlockLink";
|
||||||
import StorageNodeInit from "./StorageNodeInit";
|
import StorageNodeInit from "./StorageNodeInit";
|
||||||
import Address from "./Address";
|
import Address from "./Address";
|
||||||
import ChainExplorer from "./ChainExplorer";
|
import ChainExplorer from "./ChainExplorer";
|
||||||
|
import Client from "./Client";
|
||||||
|
|
||||||
class FullNode extends React.Component {
|
class FullNode extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@ -18,6 +18,7 @@ class FullNode extends React.Component {
|
|||||||
this.startStorageMiner = this.startStorageMiner.bind(this)
|
this.startStorageMiner = this.startStorageMiner.bind(this)
|
||||||
this.add1k = this.add1k.bind(this)
|
this.add1k = this.add1k.bind(this)
|
||||||
this.explorer = this.explorer.bind(this)
|
this.explorer = this.explorer.bind(this)
|
||||||
|
this.client = this.client.bind(this)
|
||||||
|
|
||||||
this.loadInfo()
|
this.loadInfo()
|
||||||
setInterval(this.loadInfo, 2050)
|
setInterval(this.loadInfo, 2050)
|
||||||
@ -86,6 +87,10 @@ class FullNode extends React.Component {
|
|||||||
this.props.mountWindow((onClose) => <ChainExplorer onClose={onClose} ts={this.state.tipset} client={this.props.client} mountWindow={this.props.mountWindow}/>)
|
this.props.mountWindow((onClose) => <ChainExplorer onClose={onClose} ts={this.state.tipset} client={this.props.client} mountWindow={this.props.mountWindow}/>)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
client() {
|
||||||
|
this.props.mountWindow((onClose) => <Client onClose={onClose} node={this.props.node} client={this.props.client} pondClient={this.props.pondClient} mountWindow={this.props.mountWindow}/>)
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let runtime = <div></div>
|
let runtime = <div></div>
|
||||||
|
|
||||||
@ -96,7 +101,7 @@ class FullNode extends React.Component {
|
|||||||
<div>
|
<div>
|
||||||
Head: {
|
Head: {
|
||||||
<BlockLinks cids={this.state.tipset.Cids} conn={this.props.client} mountWindow={this.props.mountWindow} />
|
<BlockLinks cids={this.state.tipset.Cids} conn={this.props.client} mountWindow={this.props.mountWindow} />
|
||||||
} H:{this.state.tipset.Height} <a href="#" onClick={this.explorer}>[Explore]</a>
|
} H:{this.state.tipset.Height} <a href="#" onClick={this.explorer}>[Explore]</a> <a href="#" onClick={this.client}>[Client]</a>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user