Skip to content

Commit

Permalink
Resolve merge
Browse files Browse the repository at this point in the history
  • Loading branch information
ferranbt committed Oct 25, 2021
1 parent 7bb4884 commit 7282cf9
Show file tree
Hide file tree
Showing 14 changed files with 636 additions and 221 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ GO ?= latest
GORUN = env GO111MODULE=on go run
GOPATH = $(shell go env GOPATH)

protoc:
protoc --go_out=. --go-grpc_out=. ./command/server/proto/*.proto

bor:
$(GORUN) build/ci.go install ./cmd/geth
mkdir -p $(GOPATH)/bin/
Expand Down
44 changes: 44 additions & 0 deletions command/debug.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package main

import (
"fmt"

"github.com/ethereum/go-ethereum/command/flagset"
)

type DebugCommand struct {
*Meta2
}

// Help implements the cli.Command interface
func (d *DebugCommand) Help() string {
return `Usage: bor debug
Debug`
}

func (d *DebugCommand) Flags() *flagset.Flagset {
return d.NewFlagSet("debug")
}

// Synopsis implements the cli.Command interface
func (d *DebugCommand) Synopsis() string {
return "Debug"
}

// Run implements the cli.Command interface
func (d *DebugCommand) Run(args []string) int {
flags := d.Flags()
if err := flags.Parse(args); err != nil {
d.UI.Error(err.Error())
return 1
}

clt, err := d.BorConn()
if err != nil {
d.UI.Error(err.Error())
return 1
}
fmt.Println(clt)
return 0
}
46 changes: 46 additions & 0 deletions command/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import (
"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/ethereum/go-ethereum/command/flagset"
"github.com/ethereum/go-ethereum/command/server"
"github.com/ethereum/go-ethereum/command/server/proto"
"github.com/ethereum/go-ethereum/node"
"github.com/mitchellh/cli"
"github.com/ryanuber/columnize"
"google.golang.org/grpc"
)

func main() {
Expand Down Expand Up @@ -40,6 +42,9 @@ func commands() map[string]cli.CommandFactory {
ErrorWriter: os.Stderr,
}

meta2 := &Meta2{
UI: ui,
}
meta := &Meta{
UI: ui,
}
Expand All @@ -54,6 +59,11 @@ func commands() map[string]cli.CommandFactory {
UI: ui,
}, nil
},
"debug": func() (cli.Command, error) {
return &DebugCommand{
Meta2: meta2,
}, nil
},
"account": func() (cli.Command, error) {
return &Account{
UI: ui,
Expand All @@ -77,6 +87,42 @@ func commands() map[string]cli.CommandFactory {
}
}

type Meta2 struct {
UI cli.Ui

addr string
}

func (m *Meta2) NewFlagSet(n string) *flagset.Flagset {
f := flagset.NewFlagSet(n)

f.StringFlag(&flagset.StringFlag{
Name: "address",
Value: &m.addr,
Usage: "Address of the grpc endpoint",
})
return f
}

func (m *Meta2) Conn() (*grpc.ClientConn, error) {
if m.addr == "" {
m.addr = "http://localhost:3131"
}
conn, err := grpc.Dial(m.addr, grpc.WithInsecure())
if err != nil {
return nil, fmt.Errorf("failed to connect to server: %v", err)
}
return conn, nil
}

func (m *Meta2) BorConn() (proto.BorClient, error) {
conn, err := m.Conn()
if err != nil {
return nil, err
}
return proto.NewBorClient(conn), nil
}

// Meta is a helper utility for the commands
type Meta struct {
UI cli.Ui
Expand Down
Loading

0 comments on commit 7282cf9

Please sign in to comment.