Skip to content

Commit

Permalink
Default to RAFT enabled
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew B White <[email protected]>
  • Loading branch information
mbwhite authored and denyeart committed Jun 3, 2024
1 parent 8289cb7 commit ecd05ab
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
.vscode

microfabd

_mfcfg
microfab
_*cfg

8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,11 @@ unit:

integration:
go run github.com/onsi/ginkgo/ginkgo integration

binary:
go build -o microfabd cmd/microfabd/main.go
go build -o microfab cmd/microfab/main.go

.PHONY: docker
docker:
docker build -t microfab -f Dockerfile2 .
3 changes: 3 additions & 0 deletions internal/app/microfabd/microfabd.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ func (m *Microfab) Start() error {
}
}()

// wait for the orderer to wakeup
time.Sleep(8 * time.Second)

// Create and join all of the channels.
if m.state == nil {
for i := range m.config.Channels {
Expand Down
45 changes: 40 additions & 5 deletions internal/pkg/orderer/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/hyperledger-labs/microfab/internal/pkg/util"
"github.com/hyperledger/fabric-protos-go/common"
"github.com/hyperledger/fabric-protos-go/orderer"
"github.com/hyperledger/fabric-protos-go/orderer/etcdraft"
"github.com/pkg/errors"
)

Expand Down Expand Up @@ -186,6 +187,44 @@ func (o *Orderer) hasStarted() bool {
func (o *Orderer) createGenesisBlock(consortium []*organization.Organization) error {
txID := txid.New(o.mspID, o.identity)
header := protoutil.BuildHeader(common.HeaderType_CONFIG, "testchainid", txID)

var consensusType *orderer.ConsensusType

if o.tls != nil {
// can either create a SOLO or full RAFT orderering service
consensusType = &orderer.ConsensusType{
// Metadata: nil,
// State: orderer.ConsensusType_STATE_NORMAL,
// Type: "solo",
Metadata: util.MarshalOrPanic(&etcdraft.ConfigMetadata{
Consenters: []*etcdraft.Consenter{
{
Host: o.apiURL.Host,
Port: uint32(o.apiPort),
// TODO: errr... what certificates?!
ClientTlsCert: o.tls.Certificate().Bytes(),
ServerTlsCert: o.tls.Certificate().Bytes(),
},
},
Options: &etcdraft.Options{
TickInterval: "2500ms",
ElectionTick: 5,
HeartbeatTick: 1,
MaxInflightBlocks: 5,
SnapshotIntervalSize: 1048576,
},
}),
State: orderer.ConsensusType_STATE_NORMAL,
Type: "etcdraft",
}
} else {
consensusType = &orderer.ConsensusType{
Metadata: nil,
State: orderer.ConsensusType_STATE_NORMAL,
Type: "solo",
}
}

config := &common.Config{
ChannelGroup: &common.ConfigGroup{
Groups: map[string]*common.ConfigGroup{
Expand Down Expand Up @@ -263,11 +302,7 @@ func (o *Orderer) createGenesisBlock(consortium []*organization.Organization) er
},
"ConsensusType": {
ModPolicy: "Admins",
Value: util.MarshalOrPanic(&orderer.ConsensusType{
Metadata: nil,
State: orderer.ConsensusType_STATE_NORMAL,
Type: "solo",
}),
Value: util.MarshalOrPanic(consensusType),
},
},
},
Expand Down

0 comments on commit ecd05ab

Please sign in to comment.