本文整理匯總了Golang中github.com/FactomProject/FactomCode/util.ReadConfig函數的典型用法代碼示例。如果您正苦於以下問題:Golang ReadConfig函數的具體用法?Golang ReadConfig怎麽用?Golang ReadConfig使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ReadConfig函數的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: isSyncCandidateFactom
// isSyncCandidateFactom returns whether or not the peer is a candidate to consider
// syncing from.
func (b *blockManager) isSyncCandidateFactom(p *peer) bool {
// Typically a peer is not a candidate for sync if it's not a Factom SERVER node,
if common.SERVER_NODE == util.ReadConfig().App.NodeMode {
return true
}
return true
}
示例2: loadConfigurations
// Load settings from configuration file: factomd.conf
func loadConfigurations() {
cfg = util.ReadConfig()
ldbpath = cfg.App.LdbPath
boltDBpath = cfg.App.BoltDBPath
process.LoadConfigurations(cfg)
}
示例3: main
func main() {
fmt.Println("+================+")
fmt.Println("| fctwallet v1 |")
fmt.Println("+================+")
cfg := util.ReadConfig().Wallet
factom.SetServer(fmt.Sprintf("%s:%d", cfg.FactomdAddress, cfg.FactomdPort))
Start()
for {
time.Sleep(time.Second)
}
}
示例4: initRPCClient
func initRPCClient() error {
anchorLog.Debug("init RPC client")
cfg = util.ReadConfig()
certHomePath := cfg.Btc.CertHomePath
rpcClientHost := cfg.Btc.RpcClientHost
rpcClientEndpoint := cfg.Btc.RpcClientEndpoint
rpcClientUser := cfg.Btc.RpcClientUser
rpcClientPass := cfg.Btc.RpcClientPass
certHomePathBtcd := cfg.Btc.CertHomePathBtcd
rpcBtcdHost := cfg.Btc.RpcBtcdHost
// Connect to local btcwallet RPC server using websockets.
ntfnHandlers := createBtcwalletNotificationHandlers()
certHomeDir := btcutil.AppDataDir(certHomePath, false)
certs, err := ioutil.ReadFile(filepath.Join(certHomeDir, "rpc.cert"))
if err != nil {
return fmt.Errorf("cannot read rpc.cert file: %s", err)
}
connCfg := &btcrpcclient.ConnConfig{
Host: rpcClientHost,
Endpoint: rpcClientEndpoint,
User: rpcClientUser,
Pass: rpcClientPass,
Certificates: certs,
}
wclient, err = btcrpcclient.New(connCfg, &ntfnHandlers)
if err != nil {
return fmt.Errorf("cannot create rpc client for btcwallet: %s", err)
}
// Connect to local btcd RPC server using websockets.
dntfnHandlers := createBtcdNotificationHandlers()
certHomeDir = btcutil.AppDataDir(certHomePathBtcd, false)
certs, err = ioutil.ReadFile(filepath.Join(certHomeDir, "rpc.cert"))
if err != nil {
return fmt.Errorf("cannot read rpc.cert file for btcd rpc server: %s", err)
}
dconnCfg := &btcrpcclient.ConnConfig{
Host: rpcBtcdHost,
Endpoint: rpcClientEndpoint,
User: rpcClientUser,
Pass: rpcClientPass,
Certificates: certs,
}
dclient, err = btcrpcclient.New(dconnCfg, &dntfnHandlers)
if err != nil {
return fmt.Errorf("cannot create rpc client for btcd: %s", err)
}
return nil
}
示例5: initServerKeys
// Initialize server private key and server public key for milestone 1
func initServerKeys() {
if nodeMode == common.SERVER_NODE {
var err error
serverPrivKey, err = common.NewPrivateKeyFromHex(serverPrivKeyHex)
if err != nil {
panic("Cannot parse Server Private Key from configuration file: " + err.Error())
}
//Set server's public key
serverPubKey = serverPrivKey.Pub
} else {
cfg := util.ReadConfig().App
serverPubKey = common.PubKeyFromString(cfg.ServerPubKey)
}
}
示例6: main
func main() {
cfg = util.ReadConfig()
ldbpath := cfg.App.LdbPath
initDB(ldbpath)
anchorChainID, _ := common.HexToHash(cfg.Anchor.AnchorChainID)
//fmt.Println("anchorChainID: ", cfg.Anchor.AnchorChainID)
processAnchorChain(anchorChainID)
//initDB("/home/bw/.factom/ldb.prd")
//dirBlockInfoMap, _ := db.FetchAllDirBlockInfo() // map[string]*common.DirBlockInfo
//for _, dirBlockInfo := range dirBlockInfoMap {
//fmt.Printf("dirBlockInfo: %s\n", spew.Sdump(dirBlockInfo))
//}
}
示例7: sanityCheck
func sanityCheck() {
cfg = util.ReadConfig()
ldbpath := cfg.App.LdbPath
initDB(ldbpath)
dirBlockInfoMap = make(map[uint32]*common.DirBlockInfo)
anchorChainID, _ = common.HexToHash(cfg.Anchor.AnchorChainID)
fmt.Printf("ldbPath=%s, anchorChainID=%s\n", ldbpath, cfg.Anchor.AnchorChainID)
dblocks, _ = db.FetchAllDBlocks()
dirBlockInfoMap, _ := db.FetchAllDirBlockInfo()
eblocks, _ = db.FetchAllEBlocksByChain(anchorChainID)
fmt.Printf("There are %d directory blocks, %d DirBlockInfos, and %d anchor chain blocks in this database.\n",
len(dblocks), len(dirBlockInfoMap), len(*eblocks))
if len(dblocks) == len(dirBlockInfoMap) {
fmt.Println("All dir blocks have dirBlockInfo. All good and done!")
os.Exit(0)
}
}
示例8: InitRPCClient
// InitRPCClient is used to create rpc client for btcd and btcwallet
// and it can be used to test connecting to btcd / btcwallet servers
// running in different machine.
func InitRPCClient() error {
//anchorLog.Debug("init RPC client")
cfg = util.ReadConfig()
//certHomePath := cfg.Btc.CertHomePath
//rpcClientHost := cfg.Btc.RpcClientHost
rpcClientEndpoint := cfg.Btc.RpcClientEndpoint
rpcClientUser := cfg.Btc.RpcClientUser
rpcClientPass := cfg.Btc.RpcClientPass
certHomePathBtcd := cfg.Btc.CertHomePathBtcd
rpcBtcdHost := cfg.Btc.RpcBtcdHost
//confirmationsNeeded = cfg.Anchor.ConfirmationsNeeded
var err error
// Connect to local btcd RPC server using websockets.
dntfnHandlers := createBtcdNotificationHandlers()
certHomeDir := btcutil.AppDataDir(certHomePathBtcd, false)
fmt.Println("btcd.cert.home=", certHomeDir)
certs, err := ioutil.ReadFile(filepath.Join(certHomeDir, "rpc.cert"))
if err != nil {
return fmt.Errorf("cannot read rpc.cert file for btcd rpc server: %s\n", err)
}
dconnCfg := &btcrpcclient.ConnConfig{
Host: rpcBtcdHost,
Endpoint: rpcClientEndpoint,
User: rpcClientUser,
Pass: rpcClientPass,
Certificates: certs,
}
dclient, err = btcrpcclient.New(dconnCfg, &dntfnHandlers)
if err != nil {
return fmt.Errorf("cannot create rpc client for btcd: %s\n", err)
}
fmt.Println("successfully created rpc client for btcd")
return nil
}
示例9: InitRPCClient
// InitRPCClient is used to create rpc client for btcd and btcwallet
// and it can be used to test connecting to btcd / btcwallet servers
// running in different machine.
func InitRPCClient() error {
anchorLog.Debug("init RPC client")
cfg = util.ReadConfig()
certHomePath := cfg.Btc.CertHomePath
rpcClientHost := cfg.Btc.RpcClientHost
rpcClientEndpoint := cfg.Btc.RpcClientEndpoint
rpcClientUser := cfg.Btc.RpcClientUser
rpcClientPass := cfg.Btc.RpcClientPass
certHomePathBtcd := cfg.Btc.CertHomePathBtcd
rpcBtcdHost := cfg.Btc.RpcBtcdHost
confirmationsNeeded = cfg.Anchor.ConfirmationsNeeded
//Added anchor parameters
var err error
serverECKey, err = common.NewPrivateKeyFromHex(cfg.Anchor.ServerECKey)
if err != nil {
panic("Cannot parse Server EC Key from configuration file: " + err.Error())
}
anchorChainID, err = common.HexToHash(cfg.Anchor.AnchorChainID)
anchorLog.Debug("anchorChainID: ", anchorChainID)
if err != nil || anchorChainID == nil {
panic("Cannot parse Server AnchorChainID from configuration file: " + err.Error())
}
// Connect to local btcwallet RPC server using websockets.
ntfnHandlers := createBtcwalletNotificationHandlers()
certHomeDir := btcutil.AppDataDir(certHomePath, false)
anchorLog.Debug("btcwallet.cert.home=", certHomeDir)
certs, err := ioutil.ReadFile(filepath.Join(certHomeDir, "rpc.cert"))
if err != nil {
return fmt.Errorf("cannot read rpc.cert file: %s\n", err)
}
connCfg := &btcrpcclient.ConnConfig{
Host: rpcClientHost,
Endpoint: rpcClientEndpoint,
User: rpcClientUser,
Pass: rpcClientPass,
Certificates: certs,
}
wclient, err = btcrpcclient.New(connCfg, &ntfnHandlers)
if err != nil {
return fmt.Errorf("cannot create rpc client for btcwallet: %s\n", err)
}
anchorLog.Debug("successfully created rpc client for btcwallet")
// Connect to local btcd RPC server using websockets.
dntfnHandlers := createBtcdNotificationHandlers()
certHomeDir = btcutil.AppDataDir(certHomePathBtcd, false)
anchorLog.Debug("btcd.cert.home=", certHomeDir)
certs, err = ioutil.ReadFile(filepath.Join(certHomeDir, "rpc.cert"))
if err != nil {
return fmt.Errorf("cannot read rpc.cert file for btcd rpc server: %s\n", err)
}
dconnCfg := &btcrpcclient.ConnConfig{
Host: rpcBtcdHost,
Endpoint: rpcClientEndpoint,
User: rpcClientUser,
Pass: rpcClientPass,
Certificates: certs,
}
dclient, err = btcrpcclient.New(dconnCfg, &dntfnHandlers)
if err != nil {
return fmt.Errorf("cannot create rpc client for btcd: %s\n", err)
}
anchorLog.Debug("successfully created rpc client for btcd")
return nil
}
示例10: Start
"github.com/FactomProject/FactomCode/common"
"github.com/FactomProject/FactomCode/database"
"github.com/FactomProject/FactomCode/factomapi"
"github.com/FactomProject/FactomCode/util"
"github.com/FactomProject/btcd/wire"
fct "github.com/FactomProject/factoid"
"github.com/hoisie/web"
)
const (
httpOK = 200
httpBad = 400
)
var (
cfg = util.ReadConfig().Wsapi
portNumber = cfg.PortNumber
applicationName = cfg.ApplicationName
dataStorePath = "/tmp/store/seed/csv"
)
var _ = fmt.Println
var server = web.NewServer()
var (
inMessageQ chan wire.FtmInternalMsg
dbase database.Db
)
func Start(db database.Db, inMsgQ chan wire.FtmInternalMsg) {
示例11:
// Copyright 2015 Factom Foundation
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.
package Wallet
import (
"github.com/FactomProject/FactomCode/util"
"github.com/FactomProject/factoid/state/stateinit"
)
var (
cfg = util.ReadConfig().Wallet
applicationName = "Factom/fctwallet"
ipaddressFD = cfg.FactomdAddress
portNumberFD = cfg.FactomdPort
databasefile = "factoid_wallet_bolt.db"
)
var factoidState = stateinit.NewFactoidState(cfg.BoltDBPath + databasefile)
const Version = "0.1.8.0"
示例12:
// Copyright 2015 FactomProject Authors. All rights reserved.
// Use of this source code is governed by the MIT license
// that can be found in the LICENSE file.
package anchor
import (
"os"
"github.com/FactomProject/FactomCode/factomlog"
"github.com/FactomProject/FactomCode/util"
)
var (
logcfg = util.ReadConfig().Log
logPath = logcfg.LogPath
logLevel = logcfg.LogLevel
logfile, _ = os.OpenFile(logPath, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0660)
)
// setup subsystem loggers
var (
anchorLog = factomlog.New(logfile, logLevel, "ANCH")
)