mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-14 13:51:21 +00:00
remove viper from rpc except test
This commit is contained in:
@ -293,7 +293,6 @@ func (n *Node) AddListener(l p2p.Listener) {
|
|||||||
// ConfigureRPC sets all variables in rpccore so they will serve
|
// ConfigureRPC sets all variables in rpccore so they will serve
|
||||||
// rpc calls from this node
|
// rpc calls from this node
|
||||||
func (n *Node) ConfigureRPC() {
|
func (n *Node) ConfigureRPC() {
|
||||||
rpccore.SetConfig(n.config)
|
|
||||||
rpccore.SetEventSwitch(n.evsw)
|
rpccore.SetEventSwitch(n.evsw)
|
||||||
rpccore.SetBlockStore(n.blockStore)
|
rpccore.SetBlockStore(n.blockStore)
|
||||||
rpccore.SetConsensusState(n.consensusState)
|
rpccore.SetConsensusState(n.consensusState)
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package core
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
"runtime/pprof"
|
"runtime/pprof"
|
||||||
"strconv"
|
|
||||||
|
|
||||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||||
)
|
)
|
||||||
@ -14,31 +12,6 @@ func UnsafeFlushMempool() (*ctypes.ResultUnsafeFlushMempool, error) {
|
|||||||
return &ctypes.ResultUnsafeFlushMempool{}, nil
|
return &ctypes.ResultUnsafeFlushMempool{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func UnsafeSetConfig(typ, key, value string) (*ctypes.ResultUnsafeSetConfig, error) {
|
|
||||||
switch typ {
|
|
||||||
case "string":
|
|
||||||
config.Set(key, value)
|
|
||||||
case "int":
|
|
||||||
val, err := strconv.Atoi(value)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("non-integer value found. key:%s; value:%s; err:%v", key, value, err)
|
|
||||||
}
|
|
||||||
config.Set(key, val)
|
|
||||||
case "bool":
|
|
||||||
switch value {
|
|
||||||
case "true":
|
|
||||||
config.Set(key, true)
|
|
||||||
case "false":
|
|
||||||
config.Set(key, false)
|
|
||||||
default:
|
|
||||||
return nil, fmt.Errorf("bool value must be true or false. got %s", value)
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return nil, fmt.Errorf("Unknown type %s", typ)
|
|
||||||
}
|
|
||||||
return &ctypes.ResultUnsafeSetConfig{}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var profFile *os.File
|
var profFile *os.File
|
||||||
|
|
||||||
func UnsafeStartCPUProfiler(filename string) (*ctypes.ResultUnsafeProfile, error) {
|
func UnsafeStartCPUProfiler(filename string) (*ctypes.ResultUnsafeProfile, error) {
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package core
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/spf13/viper"
|
|
||||||
|
|
||||||
crypto "github.com/tendermint/go-crypto"
|
crypto "github.com/tendermint/go-crypto"
|
||||||
"github.com/tendermint/tendermint/consensus"
|
"github.com/tendermint/tendermint/consensus"
|
||||||
p2p "github.com/tendermint/tendermint/p2p"
|
p2p "github.com/tendermint/tendermint/p2p"
|
||||||
@ -34,7 +32,6 @@ var (
|
|||||||
// external, thread safe interfaces
|
// external, thread safe interfaces
|
||||||
eventSwitch types.EventSwitch
|
eventSwitch types.EventSwitch
|
||||||
proxyAppQuery proxy.AppConnQuery
|
proxyAppQuery proxy.AppConnQuery
|
||||||
config *viper.Viper
|
|
||||||
|
|
||||||
// interfaces defined in types and above
|
// interfaces defined in types and above
|
||||||
blockStore types.BlockStore
|
blockStore types.BlockStore
|
||||||
@ -49,10 +46,6 @@ var (
|
|||||||
txIndexer txindex.TxIndexer
|
txIndexer txindex.TxIndexer
|
||||||
)
|
)
|
||||||
|
|
||||||
func SetConfig(c *viper.Viper) {
|
|
||||||
config = c
|
|
||||||
}
|
|
||||||
|
|
||||||
func SetEventSwitch(evsw types.EventSwitch) {
|
func SetEventSwitch(evsw types.EventSwitch) {
|
||||||
eventSwitch = evsw
|
eventSwitch = evsw
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,12 @@ package core
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
rpc "github.com/tendermint/tendermint/rpc/lib/server"
|
rpc "github.com/tendermint/tendermint/rpc/lib/server"
|
||||||
|
|
||||||
|
data "github.com/tendermint/go-wire/data"
|
||||||
|
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||||
|
rpc "github.com/tendermint/tendermint/rpc/lib/server"
|
||||||
|
"github.com/tendermint/tendermint/rpc/lib/types"
|
||||||
|
"github.com/tendermint/tendermint/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: better system than "unsafe" prefix
|
// TODO: better system than "unsafe" prefix
|
||||||
@ -36,9 +42,6 @@ var Routes = map[string]*rpc.RPCFunc{
|
|||||||
"dial_seeds": rpc.NewRPCFunc(UnsafeDialSeeds, "seeds"),
|
"dial_seeds": rpc.NewRPCFunc(UnsafeDialSeeds, "seeds"),
|
||||||
"unsafe_flush_mempool": rpc.NewRPCFunc(UnsafeFlushMempool, ""),
|
"unsafe_flush_mempool": rpc.NewRPCFunc(UnsafeFlushMempool, ""),
|
||||||
|
|
||||||
// config is not in general thread safe. expose specifics if you need em
|
|
||||||
// "unsafe_set_config": rpc.NewRPCFunc(UnsafeSetConfig, "type,key,value"),
|
|
||||||
|
|
||||||
// profiler API
|
// profiler API
|
||||||
"unsafe_start_cpu_profiler": rpc.NewRPCFunc(UnsafeStartCPUProfiler, "filename"),
|
"unsafe_start_cpu_profiler": rpc.NewRPCFunc(UnsafeStartCPUProfiler, "filename"),
|
||||||
"unsafe_stop_cpu_profiler": rpc.NewRPCFunc(UnsafeStopCPUProfiler, ""),
|
"unsafe_stop_cpu_profiler": rpc.NewRPCFunc(UnsafeStopCPUProfiler, ""),
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
abci "github.com/tendermint/abci/types"
|
abci "github.com/tendermint/abci/types"
|
||||||
"github.com/tendermint/go-crypto"
|
"github.com/tendermint/go-crypto"
|
||||||
"github.com/tendermint/go-wire/data"
|
"github.com/tendermint/go-wire/data"
|
||||||
|
|
||||||
"github.com/tendermint/tendermint/p2p"
|
"github.com/tendermint/tendermint/p2p"
|
||||||
"github.com/tendermint/tendermint/types"
|
"github.com/tendermint/tendermint/types"
|
||||||
)
|
)
|
||||||
@ -116,8 +117,6 @@ type ResultABCIQuery struct {
|
|||||||
|
|
||||||
type ResultUnsafeFlushMempool struct{}
|
type ResultUnsafeFlushMempool struct{}
|
||||||
|
|
||||||
type ResultUnsafeSetConfig struct{}
|
|
||||||
|
|
||||||
type ResultUnsafeProfile struct{}
|
type ResultUnsafeProfile struct{}
|
||||||
|
|
||||||
type ResultSubscribe struct{}
|
type ResultSubscribe struct{}
|
||||||
|
@ -13,12 +13,13 @@ import (
|
|||||||
|
|
||||||
abci "github.com/tendermint/abci/types"
|
abci "github.com/tendermint/abci/types"
|
||||||
"github.com/tendermint/go-wire/data"
|
"github.com/tendermint/go-wire/data"
|
||||||
|
. "github.com/tendermint/tmlibs/common"
|
||||||
|
|
||||||
"github.com/tendermint/tendermint/rpc/core"
|
"github.com/tendermint/tendermint/rpc/core"
|
||||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||||
rpc "github.com/tendermint/tendermint/rpc/lib/client"
|
rpc "github.com/tendermint/tendermint/rpc/lib/client"
|
||||||
"github.com/tendermint/tendermint/state/txindex/null"
|
"github.com/tendermint/tendermint/state/txindex/null"
|
||||||
"github.com/tendermint/tendermint/types"
|
"github.com/tendermint/tendermint/types"
|
||||||
. "github.com/tendermint/tmlibs/common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------
|
||||||
@ -349,54 +350,3 @@ func TestWSDoubleFire(t *testing.T) {
|
|||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------
|
|
||||||
//TODO needs to be refactored so we don't use a mutable config but rather update specific values we're interested in
|
|
||||||
// unsafe_set_config
|
|
||||||
|
|
||||||
//var stringVal = "my string"
|
|
||||||
//var intVal = 987654321
|
|
||||||
//var boolVal = true
|
|
||||||
//
|
|
||||||
//// don't change these
|
|
||||||
//var testCasesUnsafeSetConfig = [][]string{
|
|
||||||
// []string{"string", "key1", stringVal},
|
|
||||||
// []string{"int", "key2", fmt.Sprintf("%v", intVal)},
|
|
||||||
// []string{"bool", "key3", fmt.Sprintf("%v", boolVal)},
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//func TestURIUnsafeSetConfig(t *testing.T) {
|
|
||||||
// for _, testCase := range testCasesUnsafeSetConfig {
|
|
||||||
// result := new(ctypes.TMResult)
|
|
||||||
// _, err := GetURIClient().Call("unsafe_set_config", map[string]interface{}{
|
|
||||||
// "type": testCase[0],
|
|
||||||
// "key": testCase[1],
|
|
||||||
// "value": testCase[2],
|
|
||||||
// }, result)
|
|
||||||
// require.Nil(t, err)
|
|
||||||
// }
|
|
||||||
// testUnsafeSetConfig(t)
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//func TestJSONUnsafeSetConfig(t *testing.T) {
|
|
||||||
// for _, testCase := range testCasesUnsafeSetConfig {
|
|
||||||
// result := new(ctypes.TMResult)
|
|
||||||
// _, err := GetJSONClient().Call("unsafe_set_config",
|
|
||||||
// map[string]interface{}{"type": testCase[0], "key": testCase[1], "value": testCase[2]},
|
|
||||||
// result)
|
|
||||||
// require.Nil(t, err)
|
|
||||||
// }
|
|
||||||
// testUnsafeSetConfig(t)
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//func testUnsafeSetConfig(t *testing.T) {
|
|
||||||
// require := require.New(t)
|
|
||||||
// s := config.GetString("key1")
|
|
||||||
// require.Equal(stringVal, s)
|
|
||||||
//
|
|
||||||
// i := config.GetInt("key2")
|
|
||||||
// require.Equal(intVal, i)
|
|
||||||
//
|
|
||||||
// b := config.GetBool("key3")
|
|
||||||
// require.Equal(boolVal, b)
|
|
||||||
//}
|
|
||||||
|
Reference in New Issue
Block a user