Skip to content

Commit c9f860a

Browse files
committed
Add an initial Consenter interface skeleton to SBFT
Change-Id: If153df0ca493942d76aaaba66622e5d701f3d320 Signed-off-by: Gabor Hosszu <[email protected]>
1 parent c3f26d8 commit c9f860a

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

orderer/sbft/main/main.go

+51
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ import (
2424

2525
"github.com/hyperledger/fabric/orderer/common/bootstrap/provisional"
2626
localconfig "github.com/hyperledger/fabric/orderer/localconfig"
27+
"github.com/hyperledger/fabric/orderer/multichain"
2728
"github.com/hyperledger/fabric/orderer/rawledger/fileledger"
2829
"github.com/hyperledger/fabric/orderer/sbft"
2930
"github.com/hyperledger/fabric/orderer/sbft/backend"
3031
"github.com/hyperledger/fabric/orderer/sbft/connection"
3132
"github.com/hyperledger/fabric/orderer/sbft/persist"
3233
pb "github.com/hyperledger/fabric/orderer/sbft/simplebft"
34+
cb "github.com/hyperledger/fabric/protos/common"
3335
ab "github.com/hyperledger/fabric/protos/orderer"
3436
"github.com/op/go-logging"
3537
"google.golang.org/grpc"
@@ -59,6 +61,55 @@ func init() {
5961
logging.SetLevel(logging.DEBUG, "")
6062
}
6163

64+
// Consenter interface implementation for new main application:
65+
// This part is Work In Progress
66+
67+
type consenter struct{}
68+
69+
type chain struct {
70+
support multichain.ConsenterSupport
71+
}
72+
73+
// New creates a new consenter for the SBFT consensus scheme.
74+
// It accepts messages being delivered via Enqueue, orders them, and then
75+
// uses the blockcutter to form the messages into blocks before writing to
76+
// the given ledger.
77+
func New() multichain.Consenter {
78+
return &consenter{}
79+
}
80+
81+
// HandleChain creates/returns a reference to a Chain for the given set of support resources.
82+
func (solo *consenter) HandleChain(support multichain.ConsenterSupport) (multichain.Chain, error) {
83+
return newChain(support), nil
84+
}
85+
86+
func newChain(support multichain.ConsenterSupport) *chain {
87+
return &chain{
88+
support: support,
89+
}
90+
}
91+
92+
// Chain interface implementation:
93+
94+
// TODO
95+
// Start allocates whatever resources are needed for staying up to date with the chain
96+
func (ch *chain) Start() {
97+
98+
}
99+
100+
// TODO
101+
// Halt frees the resources which were allocated for this Chain
102+
func (ch *chain) Halt() {
103+
104+
}
105+
106+
// TODO
107+
// Enqueue accepts a message and returns true on acceptance, or false on shutdown
108+
func (ch *chain) Enqueue(env *cb.Envelope) bool {
109+
return false
110+
}
111+
112+
// The "old", SBFT only application:
62113
func main() {
63114
var c flags
64115

0 commit comments

Comments
 (0)