Skip to content

Commit

Permalink
sketches for using API for logging... may be overkill
Browse files Browse the repository at this point in the history
may be worth thinking about more flexible and beautiful
ways to display information... 'monitor', 'attach', etc,
along with termui, graphs...

output can be 'machiney'-- line-by-line,
or human-y -- pictures of buffalo and whatnot.
  • Loading branch information
whilei committed Jul 27, 2017
1 parent f26c0ba commit 8effd93
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 4 deletions.
11 changes: 8 additions & 3 deletions cmd/geth/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,9 @@ func makeNodeName(version string, ctx *cli.Context) string {

// MakeSystemNode sets up a local node, configures the services to launch and
// assembles the P2P protocol stack.
func MakeSystemNode(version string, ctx *cli.Context) *node.Node {
func MakeSystemNode(version string, ctx *cli.Context) (*node.Node, *eth.Ethereum) {

var ethInstance *eth.Ethereum
// global settings

if ctx.GlobalIsSet(aliasableName(ExtraDataFlag.Name, ctx)) {
Expand Down Expand Up @@ -479,7 +480,11 @@ func MakeSystemNode(version string, ctx *cli.Context) *node.Node {
glog.Fatalf("%v: failed to create the protocol stack: ", ErrStackFail, err)
}
if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
return eth.New(ctx, ethConf)
e, err := eth.New(ctx, ethConf)
if err == nil {
ethInstance = e
}
return e, err
}); err != nil {
glog.Fatalf("%v: failed to register the Ethereum service: ", ErrStackFail, err)
}
Expand All @@ -493,7 +498,7 @@ func MakeSystemNode(version string, ctx *cli.Context) *node.Node {
glog.V(logger.Info).Infoln(fmt.Sprintf("Geth started with --%s flag, which is unused by Geth Classic and can be omitted", Unused1.Name))
}

return stack
return stack, ethInstance
}

// shouldAttemptDirMigration decides based on flags if
Expand Down
32 changes: 31 additions & 1 deletion cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
"github.com/ethereumproject/go-ethereum/logger/glog"
"github.com/ethereumproject/go-ethereum/metrics"
"github.com/ethereumproject/go-ethereum/node"
"time"
)

// Version is the application revision identifier. It can be set with the linker
Expand Down Expand Up @@ -262,8 +263,37 @@ func main() {
// It creates a default node based on the command line arguments and runs it in
// blocking mode, waiting for it to be shut down.
func geth(ctx *cli.Context) error {
node := MakeSystemNode(Version, ctx)
node, e := MakeSystemNode(Version, ctx)
startNode(ctx, node)

eAPI := eth.NewPublicEthereumAPI(e)
netAPI := eth.NewPublicNetAPI()
//
//
//startTime := time.Now()
//lastLogTime := time.Now()
//go func() {
// for {
// select {
// case <-pm.quitSync:
// return
// case time.Since(lastLogTime) > time.Second*5:
// // "RO" -> "ReadOut"
// modeRO := "Import"
// if pm.downloader.GetMode() == downloader.FastSync {
// modeRO = "Sync"
// }
// _, current, highest, _, _ := pm.downloader.Progress()
// currentBlock := pm.blockchain.GetBlockByNumber(current)
// highestBlock := pm.blockchain.GetBlockByNumber(highest)
// bodyMean := metrics.DLBodies.RateMean()
// headerMean := metrics.DLHeaders.RateMean()
//
// glog.V(logger.Info).Infof("%s", modeRO)
// }
// }
//}()

node.Wait()

return nil
Expand Down
9 changes: 9 additions & 0 deletions eth/downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,15 @@ func (d *Downloader) Synchronising() bool {
return atomic.LoadInt32(&d.synchronising) > 0
}

// Experimental getter functions for new logging.
func (d *Downloader) GetMode() SyncMode {
return d.mode
}

func (d *Downloader) GetPeers() *peerSet {
return d.peers
}

// RegisterPeer injects a new download peer into the set of block source to be
// used for fetching hashes and blocks from.
func (d *Downloader) RegisterPeer(id string, version int, currentHead currentHeadRetrievalFn,
Expand Down
1 change: 1 addition & 0 deletions eth/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
"github.com/ethereumproject/go-ethereum/p2p/discover"
"github.com/ethereumproject/go-ethereum/pow"
"github.com/ethereumproject/go-ethereum/rlp"
"github.com/ethereumproject/go-ethereum/metrics"
)

const (
Expand Down

0 comments on commit 8effd93

Please sign in to comment.