Initial structure
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
This commit is contained in:
parent
8fbe9df39b
commit
8417f515a1
69
api/api.go
Normal file
69
api/api.go
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
package api
|
||||||
|
|
||||||
|
type Version struct {
|
||||||
|
Version string
|
||||||
|
|
||||||
|
// TODO: git commit / os / genesis cid?
|
||||||
|
}
|
||||||
|
|
||||||
|
type API interface {
|
||||||
|
// chain
|
||||||
|
|
||||||
|
// // head
|
||||||
|
|
||||||
|
// messages
|
||||||
|
|
||||||
|
// // wait
|
||||||
|
// // send
|
||||||
|
// // status
|
||||||
|
// // mpool
|
||||||
|
// // // ls / show / rm
|
||||||
|
|
||||||
|
// dag
|
||||||
|
|
||||||
|
// // get block
|
||||||
|
// // (cli: show / info)
|
||||||
|
|
||||||
|
// network
|
||||||
|
|
||||||
|
// // peers
|
||||||
|
// // ping
|
||||||
|
// // connect
|
||||||
|
|
||||||
|
// client
|
||||||
|
|
||||||
|
// miner
|
||||||
|
|
||||||
|
// // create
|
||||||
|
// // owner
|
||||||
|
// // power
|
||||||
|
// // set-price
|
||||||
|
// // set-perrid
|
||||||
|
|
||||||
|
// // UX ?
|
||||||
|
|
||||||
|
// wallet
|
||||||
|
|
||||||
|
// // import
|
||||||
|
// // export
|
||||||
|
// // list
|
||||||
|
// // (on cli - cmd to list associations)
|
||||||
|
|
||||||
|
// dht
|
||||||
|
|
||||||
|
// // need ?
|
||||||
|
|
||||||
|
// paych
|
||||||
|
|
||||||
|
// // todo
|
||||||
|
|
||||||
|
// retrieval
|
||||||
|
|
||||||
|
// // retrieve piece
|
||||||
|
|
||||||
|
// Other
|
||||||
|
|
||||||
|
// // ID (on cli - print with other info)
|
||||||
|
|
||||||
|
Version() Version
|
||||||
|
}
|
9
api/client/client.go
Normal file
9
api/client/client.go
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package client
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/filecoin-project/go-lotus/api"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewRPC(addr string) api.API {
|
||||||
|
return nil // TODO
|
||||||
|
}
|
3
build/version.go
Normal file
3
build/version.go
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
package build
|
||||||
|
|
||||||
|
const Version = "0.0.0"
|
9
cli/cmd.go
Normal file
9
cli/cmd.go
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package cli
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gopkg.in/urfave/cli.v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Commands = []*cli.Command{
|
||||||
|
versionCmd,
|
||||||
|
}
|
16
cli/version.go
Normal file
16
cli/version.go
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package cli
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gopkg.in/urfave/cli.v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
var versionCmd = &cli.Command{
|
||||||
|
Name: "version",
|
||||||
|
Usage: "Print version",
|
||||||
|
Action: func(context *cli.Context) error {
|
||||||
|
// TODO: print more useful things
|
||||||
|
|
||||||
|
cli.VersionPrinter(context)
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
31
cmd/lotus/main.go
Normal file
31
cmd/lotus/main.go
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"gopkg.in/urfave/cli.v2"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-lotus/build"
|
||||||
|
lcli "github.com/filecoin-project/go-lotus/cli"
|
||||||
|
"github.com/filecoin-project/go-lotus/daemon"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
local := []*cli.Command{
|
||||||
|
daemon.Cmd,
|
||||||
|
}
|
||||||
|
|
||||||
|
app := &cli.App{
|
||||||
|
Name: "lotus",
|
||||||
|
Usage: "Filecoin decentralized storage network client",
|
||||||
|
Version: build.Version,
|
||||||
|
|
||||||
|
Commands: append(local, lcli.Commands...),
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := app.Run(os.Args); err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
3
daemon/builder.go
Normal file
3
daemon/builder.go
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
package daemon
|
||||||
|
|
||||||
|
|
13
daemon/cmd.go
Normal file
13
daemon/cmd.go
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package daemon
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gopkg.in/urfave/cli.v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Cmd = &cli.Command{
|
||||||
|
Name: "daemon",
|
||||||
|
Usage: "Start a lotus daemon process",
|
||||||
|
Action: func(context *cli.Context) error {
|
||||||
|
return serveRPC()
|
||||||
|
},
|
||||||
|
}
|
1
daemon/modules/core.go
Normal file
1
daemon/modules/core.go
Normal file
@ -0,0 +1 @@
|
|||||||
|
package modules
|
1
daemon/modules/libp2p.go
Normal file
1
daemon/modules/libp2p.go
Normal file
@ -0,0 +1 @@
|
|||||||
|
package modules
|
3
daemon/modules/testing.go
Normal file
3
daemon/modules/testing.go
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
package modules
|
||||||
|
|
||||||
|
|
31
daemon/rpc.go
Normal file
31
daemon/rpc.go
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package daemon
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/gorilla/rpc/v2"
|
||||||
|
"github.com/gorilla/rpc/v2/json"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-lotus/build"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Filecoin struct {}
|
||||||
|
|
||||||
|
func (*Filecoin) ServerVersion(r *http.Request, _ *struct{}, out *string) error {
|
||||||
|
*out = build.Version
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func serveRPC() error {
|
||||||
|
fc := new(Filecoin)
|
||||||
|
|
||||||
|
rpcServer := rpc.NewServer()
|
||||||
|
rpcServer.RegisterCodec(json.NewCodec(), "application/json")
|
||||||
|
if err := rpcServer.RegisterService(fc, ""); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
http.Handle("/rpc/v0", rpcServer)
|
||||||
|
return http.ListenAndServe(":1234", http.DefaultServeMux)
|
||||||
|
}
|
||||||
|
|
12
go.mod
Normal file
12
go.mod
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
module github.com/filecoin-project/go-lotus
|
||||||
|
|
||||||
|
go 1.12
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/gorilla/rpc v1.2.0
|
||||||
|
go.uber.org/atomic v1.4.0 // indirect
|
||||||
|
go.uber.org/dig v1.7.0 // indirect
|
||||||
|
go.uber.org/fx v1.9.0 // indirect
|
||||||
|
go.uber.org/multierr v1.1.0 // indirect
|
||||||
|
gopkg.in/urfave/cli.v2 v2.0.0-20180128182452-d3ae77c26ac8
|
||||||
|
)
|
12
go.sum
Normal file
12
go.sum
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
github.com/gorilla/rpc v1.2.0 h1:WvvdC2lNeT1SP32zrIce5l0ECBfbAlmrmSBsuc57wfk=
|
||||||
|
github.com/gorilla/rpc v1.2.0/go.mod h1:V4h9r+4sF5HnzqbwIez0fKSpANP0zlYd3qR7p36jkTQ=
|
||||||
|
go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU=
|
||||||
|
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||||
|
go.uber.org/dig v1.7.0 h1:E5/L92iQTNJTjfgJF2KgU+/JpMaiuvK2DHLBj0+kSZk=
|
||||||
|
go.uber.org/dig v1.7.0/go.mod h1:z+dSd2TP9Usi48jL8M3v63iSBVkiwtVyMKxMZYYauPg=
|
||||||
|
go.uber.org/fx v1.9.0 h1:7OAz8ucp35AU8eydejpYG7QrbE8rLKzGhHbZlJi5LYY=
|
||||||
|
go.uber.org/fx v1.9.0/go.mod h1:mFdUyAUuJ3w4jAckiKSKbldsxy1ojpAMJ+dVZg5Y0Aw=
|
||||||
|
go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI=
|
||||||
|
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||||
|
gopkg.in/urfave/cli.v2 v2.0.0-20180128182452-d3ae77c26ac8 h1:Ggy3mWN4l3PUFPfSG0YB3n5fVYggzysUmiUQ89SnX6Y=
|
||||||
|
gopkg.in/urfave/cli.v2 v2.0.0-20180128182452-d3ae77c26ac8/go.mod h1:cKXr3E0k4aosgycml1b5z33BVV6hai1Kh7uDgFOkbcs=
|
Loading…
Reference in New Issue
Block a user