Skip to content

Commit

Permalink
refactor(P2P): DebugMode handling
Browse files Browse the repository at this point in the history
  • Loading branch information
deblasis committed Jan 9, 2023
1 parent d313d97 commit bd85dd4
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ rebuild_client_start: docker_check ## Rebuild and run a client daemon which is o

.PHONY: client_connect
client_connect: docker_check ## Connect to the running client debugging daemon
docker exec -it client /bin/bash -c "POCKET_CLIENT_DEBUG_MODE=true go run -tags=debug app/client/*.go debug"
docker exec -it client /bin/bash -c "go run -tags=debug app/client/*.go debug"

.PHONY: build_and_watch
build_and_watch: ## Continous build Pocket's main entrypoint as files change
Expand Down
2 changes: 1 addition & 1 deletion app/client/cli/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func NewDebugCommand() *cobra.Command {
Args: cobra.ExactArgs(0),
PersistentPreRun: func(cmd *cobra.Command, args []string) {
var err error
runtimeMgr := runtime.NewManagerFromFiles(defaultConfigPath, defaultGenesisPath, runtime.WithRandomPK())
runtimeMgr := runtime.NewManagerFromFiles(defaultConfigPath, defaultGenesisPath, runtime.WithClientDebugMode(), runtime.WithRandomPK())

// HACK(#416): this is a temporary solution that guarantees backward compatibility while we implement peer discovery.
validators = runtimeMgr.GetGenesis().Validators
Expand Down
1 change: 0 additions & 1 deletion build/config/config1.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"root_directory": "/go/src/github.com/pocket-network",
"private_key": "6fd0bc54cc2dd205eaf226eebdb0451629b321f11d279013ce6fdd5a33059256b2eda2232ffb2750bf761141f70f75a03a025f65b2b2b417c7f8b3c9ca91e8e4",
"client_debug_mode": false,
"consensus": {
"max_mempool_bytes": 500000000,
"pacemaker_config": {
Expand Down
13 changes: 1 addition & 12 deletions p2p/raintree/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,7 @@ func (n *rainTreeNetwork) networkSendInternal(data []byte, address cryptoPocket.
return err
}

// this is because in client mode there's no bus
bus := n.GetBus()
if bus == nil {
return nil
}

bus.
n.GetBus().
GetTelemetryModule().
GetEventMetricsAgent().
EmitEvent(
Expand Down Expand Up @@ -258,11 +252,6 @@ func (n *rainTreeNetwork) SetBus(bus modules.Bus) {
}

func (n *rainTreeNetwork) GetBus() modules.Bus {
// TODO: Do we need this if?
// if n.bus == nil {
// log.Printf("[WARN] PocketBus is not initialized in rainTreeNetwork")
// return nil
// }
return n.bus
}

Expand Down
6 changes: 6 additions & 0 deletions runtime/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,9 @@ func WithClock(clockMgr clock.Clock) func(*Manager) {
b.clock = clockMgr
}
}

func WithClientDebugMode() func(*Manager) {
return func(b *Manager) {
b.config.ClientDebugMode = true
}
}

0 comments on commit bd85dd4

Please sign in to comment.