本文整理匯總了Golang中github.com/FactomProject/factomd/state.State.CustomNetworkID方法的典型用法代碼示例。如果您正苦於以下問題:Golang State.CustomNetworkID方法的具體用法?Golang State.CustomNetworkID怎麽用?Golang State.CustomNetworkID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/FactomProject/factomd/state.State
的用法示例。
在下文中一共展示了State.CustomNetworkID方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: NetStart
//.........這裏部分代碼省略.........
}
// Modify Identities of new nodes
if len(fnodes) > 1 && len(s.Prefix) == 0 {
modifyLoadIdentities() // We clone s to make all of our servers
}
for i := range fnodes {
fnodes[i].State.CreateBlankFactomIdentity(fnodes[i].State.IdentityChainID)
}
// Start the P2P netowork
var networkID p2p.NetworkID
var seedURL, networkPort, specialPeers string
switch s.Network {
case "MAIN", "main":
networkID = p2p.MainNet
seedURL = s.MainSeedURL
networkPort = s.MainNetworkPort
specialPeers = s.MainSpecialPeers
case "TEST", "test":
networkID = p2p.TestNet
seedURL = s.TestSeedURL
networkPort = s.TestNetworkPort
specialPeers = s.TestSpecialPeers
case "LOCAL", "local":
networkID = p2p.LocalNet
seedURL = s.LocalSeedURL
networkPort = s.LocalNetworkPort
specialPeers = s.LocalSpecialPeers
case "CUSTOM", "custom":
if bytes.Compare(customNet, []byte("\xe3\xb0\xc4\x42")) == 0 {
panic("Please specify a custom network with -customnet=<something unique here>")
}
s.CustomNetworkID = customNet
networkID = p2p.NetworkID(binary.BigEndian.Uint32(customNet))
for i := range fnodes {
fnodes[i].State.CustomNetworkID = customNet
}
seedURL = s.LocalSeedURL
networkPort = s.LocalNetworkPort
specialPeers = s.LocalSpecialPeers
default:
panic("Invalid Network choice in Config File or command line. Choose MAIN, TEST, LOCAL, or CUSTOM")
}
connectionMetricsChannel := make(chan interface{}, p2p.StandardChannelSize)
p2p.NetworkDeadline = time.Duration(deadline) * time.Millisecond
if enableNet {
if 0 < networkPortOverride {
networkPort = fmt.Sprintf("%d", networkPortOverride)
}
ci := p2p.ControllerInit{
Port: networkPort,
PeersFile: s.PeersFile,
Network: networkID,
Exclusive: exclusive,
SeedURL: seedURL,
SpecialPeers: specialPeers,
ConnectionMetricsChannel: connectionMetricsChannel,
}
p2pNetwork = new(p2p.Controller).Init(ci)
p2pNetwork.StartNetwork()
// Setup the proxy (Which translates from network parcels to factom messages, handling addressing for directed messages)
p2pProxy = new(P2PProxy).Init(fnodes[0].State.FactomNodeName, "P2P Network").(*P2PProxy)