mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-06 13:26:23 +00:00
Closes https://github.com/tendermint/tendermint/issues/3857 Moves `lib/` folder to `jsonrpc/`. Renames: **packages** `rpc` package -> `jsonrpc` package `rpcclient` package -> `client` package `rpcserver` package -> `server` package **structs and interfaces** ``` JSONRPCClient to Client JSONRPCRequestBatch to RequestBatch JSONRPCCaller to Caller ``` **functions** ``` StartHTTPServer to Serve StartHTTPAndTLSServer to ServeTLS rpc/jsonrpc/client: rename NewURIClient to NewURI NewJSONRPCClient to New NewJSONRPCClientWithHTTPClient to NewWithHTTPClient NewWSClient to NewWS ``` **misc** - unexpose `ResponseWriterWrapper` - remove unused http_params.go
57 lines
1.5 KiB
Go
57 lines
1.5 KiB
Go
package core
|
|
|
|
import (
|
|
"os"
|
|
"runtime/pprof"
|
|
|
|
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
|
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
|
|
)
|
|
|
|
// UnsafeFlushMempool removes all transactions from the mempool.
|
|
func UnsafeFlushMempool(ctx *rpctypes.Context) (*ctypes.ResultUnsafeFlushMempool, error) {
|
|
env.Mempool.Flush()
|
|
return &ctypes.ResultUnsafeFlushMempool{}, nil
|
|
}
|
|
|
|
var profFile *os.File
|
|
|
|
// UnsafeStartCPUProfiler starts a pprof profiler using the given filename.
|
|
func UnsafeStartCPUProfiler(ctx *rpctypes.Context, filename string) (*ctypes.ResultUnsafeProfile, error) {
|
|
var err error
|
|
profFile, err = os.Create(filename)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
err = pprof.StartCPUProfile(profFile)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &ctypes.ResultUnsafeProfile{}, nil
|
|
}
|
|
|
|
// UnsafeStopCPUProfiler stops the running pprof profiler.
|
|
func UnsafeStopCPUProfiler(ctx *rpctypes.Context) (*ctypes.ResultUnsafeProfile, error) {
|
|
pprof.StopCPUProfile()
|
|
if err := profFile.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
return &ctypes.ResultUnsafeProfile{}, nil
|
|
}
|
|
|
|
// UnsafeWriteHeapProfile dumps a heap profile to the given filename.
|
|
func UnsafeWriteHeapProfile(ctx *rpctypes.Context, filename string) (*ctypes.ResultUnsafeProfile, error) {
|
|
memProfFile, err := os.Create(filename)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if err := pprof.WriteHeapProfile(memProfFile); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := memProfFile.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &ctypes.ResultUnsafeProfile{}, nil
|
|
}
|