Skip to content

Commit 8288ed0

Browse files
authored
move consenter to node consensus (#176)
Signed-off-by: Hagar Meir <hagar.meir@ibm.com>
1 parent 4e34d9c commit 8288ed0

File tree

8 files changed

+27
-42
lines changed

8 files changed

+27
-42
lines changed

node/consensus/consensus.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,17 @@ import (
1616
"math/rand"
1717
"sync"
1818

19+
"github.com/hyperledger-labs/SmartBFT/pkg/consensus"
20+
smartbft_types "github.com/hyperledger-labs/SmartBFT/pkg/types"
21+
"github.com/hyperledger-labs/SmartBFT/smartbftprotos"
22+
"github.com/hyperledger/fabric-protos-go-apiv2/orderer"
1923
arma_types "github.com/hyperledger/fabric-x-orderer/common/types"
20-
"github.com/hyperledger/fabric-x-orderer/core/badb"
2124
"github.com/hyperledger/fabric-x-orderer/node/comm"
2225
"github.com/hyperledger/fabric-x-orderer/node/config"
26+
"github.com/hyperledger/fabric-x-orderer/node/consensus/badb"
2327
"github.com/hyperledger/fabric-x-orderer/node/consensus/state"
2428
"github.com/hyperledger/fabric-x-orderer/node/delivery"
2529
protos "github.com/hyperledger/fabric-x-orderer/node/protos/comm"
26-
27-
"github.com/hyperledger-labs/SmartBFT/pkg/consensus"
28-
smartbft_types "github.com/hyperledger-labs/SmartBFT/pkg/types"
29-
"github.com/hyperledger-labs/SmartBFT/smartbftprotos"
30-
"github.com/hyperledger/fabric-protos-go-apiv2/orderer"
3130
"github.com/pkg/errors"
3231
"google.golang.org/protobuf/proto"
3332
)

node/consensus/consensus_builder.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ import (
2424
"github.com/hyperledger/fabric-protos-go-apiv2/common"
2525
"github.com/hyperledger/fabric-x-orderer/common/ledger/blockledger"
2626
arma_types "github.com/hyperledger/fabric-x-orderer/common/types"
27-
"github.com/hyperledger/fabric-x-orderer/core"
28-
"github.com/hyperledger/fabric-x-orderer/core/badb"
2927
"github.com/hyperledger/fabric-x-orderer/node/comm"
3028
"github.com/hyperledger/fabric-x-orderer/node/config"
29+
"github.com/hyperledger/fabric-x-orderer/node/consensus/badb"
3130
"github.com/hyperledger/fabric-x-orderer/node/consensus/state"
3231
"github.com/hyperledger/fabric-x-orderer/node/crypto"
3332
"github.com/hyperledger/fabric-x-orderer/node/delivery"
@@ -64,7 +63,7 @@ func CreateConsensus(conf *config.ConsenterNodeConfig, net Net, genesisBlock *co
6463
Net: net,
6564
Config: conf,
6665
BFTConfig: conf.BFTConfig,
67-
Arma: &core.Consenter{
66+
Arma: &Consenter{
6867
State: initialState,
6968
DB: badb,
7069
Logger: logger,

node/consensus/consensus_test.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,18 @@ import (
1717
"testing"
1818
"time"
1919

20+
"github.com/hyperledger-labs/SmartBFT/pkg/consensus"
21+
smartbft_types "github.com/hyperledger-labs/SmartBFT/pkg/types"
22+
"github.com/hyperledger-labs/SmartBFT/pkg/wal"
23+
"github.com/hyperledger-labs/SmartBFT/smartbftprotos"
24+
"github.com/hyperledger/fabric-protos-go-apiv2/common"
2025
arma_types "github.com/hyperledger/fabric-x-orderer/common/types"
21-
"github.com/hyperledger/fabric-x-orderer/core"
22-
"github.com/hyperledger/fabric-x-orderer/core/badb"
2326
"github.com/hyperledger/fabric-x-orderer/node/batcher"
27+
"github.com/hyperledger/fabric-x-orderer/node/consensus/badb"
2428
"github.com/hyperledger/fabric-x-orderer/node/consensus/state"
2529
"github.com/hyperledger/fabric-x-orderer/node/crypto"
2630
"github.com/hyperledger/fabric-x-orderer/node/ledger"
2731
"github.com/hyperledger/fabric-x-orderer/testutil"
28-
29-
"github.com/hyperledger-labs/SmartBFT/pkg/consensus"
30-
smartbft_types "github.com/hyperledger-labs/SmartBFT/pkg/types"
31-
"github.com/hyperledger-labs/SmartBFT/pkg/wal"
32-
"github.com/hyperledger-labs/SmartBFT/smartbftprotos"
33-
"github.com/hyperledger/fabric-protos-go-apiv2/common"
3432
"github.com/stretchr/testify/assert"
3533
"github.com/stretchr/testify/require"
3634
"google.golang.org/protobuf/proto"
@@ -272,7 +270,7 @@ func makeConsensusNode(t *testing.T, sk *ecdsa.PrivateKey, partyID arma_types.Pa
272270

273271
initialState, md := initializeStateAndMetadata(t, initialState, ledger)
274272

275-
consenter := &core.Consenter{ // TODO should this be initialized as part of consensus node start?
273+
consenter := &Consenter{ // TODO should this be initialized as part of consensus node start?
276274
State: initialState,
277275
DB: db,
278276
Logger: l,
@@ -569,7 +567,7 @@ func TestAssembleProposalAndVerify(t *testing.T) {
569567
AppContext: tst.initialAppContext.Bytes(),
570568
}
571569

572-
consenter := &core.Consenter{
570+
consenter := &Consenter{
573571
DB: db,
574572
State: initialState,
575573
Logger: logger,
@@ -683,7 +681,7 @@ func TestVerifyProposal(t *testing.T) {
683681
AppContext: initialAppContext.Bytes(),
684682
}
685683

686-
consenter := &core.Consenter{
684+
consenter := &Consenter{
687685
DB: db,
688686
State: &initialState,
689687
Logger: logger,
@@ -878,7 +876,7 @@ func TestSignProposal(t *testing.T) {
878876
AppContext: initialAppContext.Bytes(),
879877
}
880878

881-
consenter := &core.Consenter{
879+
consenter := &Consenter{
882880
DB: db,
883881
State: &initialState,
884882
Logger: logger,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Copyright IBM Corp. All Rights Reserved.
44
SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
package core
7+
package consensus
88

99
import (
1010
"slices"
Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,16 @@ Copyright IBM Corp. All Rights Reserved.
44
SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
package core_test
7+
package consensus_test
88

99
import (
1010
"testing"
1111

1212
arma_types "github.com/hyperledger/fabric-x-orderer/common/types"
13-
"github.com/hyperledger/fabric-x-orderer/core"
14-
"github.com/hyperledger/fabric-x-orderer/core/mocks"
13+
"github.com/hyperledger/fabric-x-orderer/node/consensus"
14+
"github.com/hyperledger/fabric-x-orderer/node/consensus/mocks"
1515
"github.com/hyperledger/fabric-x-orderer/node/consensus/state"
1616
"github.com/hyperledger/fabric-x-orderer/testutil"
17-
1817
"github.com/stretchr/testify/assert"
1918
)
2019

@@ -83,23 +82,13 @@ func TestConsenter(t *testing.T) {
8382
assert.Len(t, consenter.State.Complaints, 1)
8483
}
8584

86-
func createConsenter(state *state.State, logger arma_types.Logger) *core.Consenter {
87-
consenter := &core.Consenter{
85+
func createConsenter(s *state.State, logger arma_types.Logger) *consensus.Consenter {
86+
consenter := &consensus.Consenter{
8887
Logger: logger,
8988
DB: &mocks.FakeBatchAttestationDB{},
90-
BAFDeserializer: &BAFSimpleDeserializer{},
91-
State: state,
89+
BAFDeserializer: &state.BAFDeserialize{},
90+
State: s,
9291
}
9392

9493
return consenter
9594
}
96-
97-
type BAFSimpleDeserializer struct{}
98-
99-
func (bafd *BAFSimpleDeserializer) Deserialize(bytes []byte) (arma_types.BatchAttestationFragment, error) {
100-
var baf arma_types.SimpleBatchAttestationFragment
101-
if err := baf.Deserialize(bytes); err != nil {
102-
return nil, err
103-
}
104-
return &baf, nil
105-
}

core/mocks/batch_attestation_db.go renamed to node/consensus/mocks/batch_attestation_db.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)