Browse Source

more config options

pull/147/head
Ethan Buchman 9 years ago
parent
commit
bb662b8861
7 changed files with 53 additions and 9 deletions
  1. +2
    -1
      Makefile
  2. +7
    -1
      config/tendermint/config.go
  3. +4
    -1
      config/tendermint_test/config.go
  4. +12
    -0
      node/node.go
  5. +4
    -0
      p2p/netaddress.go
  6. +13
    -0
      vm/config.go
  7. +11
    -6
      vm/vm.go

+ 2
- 1
Makefile View File

@ -50,4 +50,5 @@ gen_client:
go generate rpc/core_client/*.go
revision:
-echo `git rev-parse --verify HEAD` >> $(TMROOT)/revisions
-echo `git rev-parse --verify HEAD` > $(TMROOT)/revision
-echo `git rev-parse --verify HEAD` >> $(TMROOT)/revision_history

+ 7
- 1
config/tendermint/config.go View File

@ -54,6 +54,9 @@ func GetConfig(rootDir string) cfg.Config {
if mapConfig.IsSet("chain_id") {
Exit("Cannot set 'chain_id' via config.toml")
}
if mapConfig.IsSet("revisions_file") {
Exit("Cannot set 'revisions_file' via config.toml. It must match what's in the Makefile")
}
mapConfig.SetDefault("chain_id", "tendermint_testnet_10")
mapConfig.SetDefault("genesis_file", rootDir+"/genesis.json")
mapConfig.SetDefault("moniker", "anonymous")
@ -65,9 +68,12 @@ func GetConfig(rootDir string) cfg.Config {
mapConfig.SetDefault("priv_validator_file", rootDir+"/priv_validator.json")
mapConfig.SetDefault("db_backend", "leveldb")
mapConfig.SetDefault("db_dir", rootDir+"/data")
mapConfig.SetDefault("vm_log", true)
mapConfig.SetDefault("log_level", "info")
mapConfig.SetDefault("rpc_laddr", "0.0.0.0:46657")
mapConfig.SetDefault("revisions_file", rootDir+"/revisions")
mapConfig.SetDefault("prof_laddr", "")
mapConfig.SetDefault("revisions_file", rootDir+"/revision")
mapConfig.SetDefault("local_routing", false)
return mapConfig
}


+ 4
- 1
config/tendermint_test/config.go View File

@ -70,8 +70,11 @@ func GetConfig(rootDir string) cfg.Config {
mapConfig.SetDefault("db_backend", "memdb")
mapConfig.SetDefault("db_dir", rootDir+"/data")
mapConfig.SetDefault("log_level", "debug")
mapConfig.SetDefault("vm_log", true)
mapConfig.SetDefault("rpc_laddr", "0.0.0.0:36657")
mapConfig.SetDefault("revisions_file", rootDir+"/revisions")
mapConfig.SetDefault("prof_laddr", "")
mapConfig.SetDefault("revisions_file", rootDir+"/revision")
mapConfig.SetDefault("local_routing", false)
return mapConfig
}


+ 12
- 0
node/node.go View File

@ -24,6 +24,7 @@ import (
sm "github.com/tendermint/tendermint/state"
stypes "github.com/tendermint/tendermint/state/types"
"github.com/tendermint/tendermint/types"
"github.com/tendermint/tendermint/vm"
"github.com/tendermint/tendermint/wire"
)
@ -127,6 +128,17 @@ func NewNode() *Node {
// they should all satisfy events.Eventable
SetFireable(eventSwitch, pexReactor, bcReactor, mempoolReactor, consensusReactor)
// run the profile server
profileHost := config.GetString("prof_laddr")
if profileHost != "" {
go func() {
log.Warn("Profile server", "error", http.ListenAndServe(profileHost, nil))
}()
}
// set vm log level
vm.SetDebug(config.GetBool("vm_log"))
return &Node{
sw: sw,
evsw: eventSwitch,


+ 4
- 0
p2p/netaddress.go View File

@ -110,6 +110,10 @@ func (na *NetAddress) DialTimeout(timeout time.Duration) (net.Conn, error) {
}
func (na *NetAddress) Routable() bool {
if config.GetBool("local_routing") {
return na.Valid()
}
// TODO(oga) bitcoind doesn't include RFC3849 here, but should we?
return na.Valid() && !(na.RFC1918() || na.RFC3927() || na.RFC4862() ||
na.RFC4193() || na.RFC4843() || na.Local())


+ 13
- 0
vm/config.go View File

@ -0,0 +1,13 @@
package vm
import (
cfg "github.com/tendermint/tendermint/config"
)
var config cfg.Config = nil
func init() {
cfg.OnConfig(func(newConfig cfg.Config) {
config = newConfig
})
}

+ 11
- 6
vm/vm.go View File

@ -36,15 +36,20 @@ func (err ErrPermission) Error() string {
return fmt.Sprintf("Contract does not have permission to %s", err.typ)
}
type Debug bool
const (
dataStackCapacity = 1024
callStackCapacity = 100 // TODO ensure usage.
memoryCapacity = 1024 * 1024 // 1 MB
dbg Debug = true
dataStackCapacity = 1024
callStackCapacity = 100 // TODO ensure usage.
memoryCapacity = 1024 * 1024 // 1 MB
)
type Debug bool
var dbg Debug
func SetDebug(d bool) {
dbg = Debug(d)
}
func (d Debug) Printf(s string, a ...interface{}) {
if d {
fmt.Printf(s, a...)


Loading…
Cancel
Save