Ejemplo n.º 1
0
// 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")))
	}
}
Ejemplo n.º 2
0
// 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")))
	}
}