コード例 #1
0
ファイル: obc-pbft.go プロジェクト: masterDev1985/obc-peer
// New creates a new Obc* instance that provides the Consenter interface.
// Internally, it uses an opaque pbft-core instance.
func New(cpi consensus.CPI) consensus.Consenter {
	config := readConfig()
	addr, _, _ := cpi.GetReplicaHash()
	id, _ := cpi.GetReplicaID(addr)

	switch config.GetString("general.mode") {
	case "classic":
		return newObcClassic(id, config, cpi)
	case "batch":
		return newObcBatch(id, config, cpi)
	case "sieve":
		return newObcSieve(id, config, cpi)
	default:
		panic(fmt.Errorf("Invalid PBFT mode: %s", config.GetString("general.mode")))
	}
}
コード例 #2
0
ファイル: obc-pbft.go プロジェクト: tenc/obc-peer-pre-public
// New creates a new Obc* instance that provides the Consenter interface.
// Internally, it uses an opaque pbft-core instance.
func New(cpi consensus.CPI) consensus.Consenter {
	config = loadConfig()
	handle, _, _ := cpi.GetNetworkHandles()
	id, _ := getValidatorID(handle)

	switch config.GetString("general.mode") {
	case "classic":
		return newObcClassic(id, config, cpi)
	case "batch":
		return newObcBatch(id, config, cpi)
	case "sieve":
		return newObcSieve(id, config, cpi)
	default:
		panic(fmt.Errorf("Invalid PBFT mode: %s", config.GetString("general.mode")))
	}
}