Skip to content

Commit a35b6ca

Browse files
committed
move ordering info interface to types
Signed-off-by: Hagar Meir <hagar.meir@ibm.com>
1 parent 3cd436f commit a35b6ca

File tree

8 files changed

+27
-30
lines changed

8 files changed

+27
-30
lines changed

common/types/types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ SPDX-License-Identifier: Apache-2.0
77
package types
88

99
import (
10+
"fmt"
1011
"math"
1112
)
1213

@@ -66,3 +67,9 @@ type Batch interface {
6667
BatchID
6768
Requests() BatchedRequests
6869
}
70+
71+
// OrderingInfo is an opaque object that provides extra information on the order of the batch attestation and
72+
// metadata to be used in the construction of the block.
73+
type OrderingInfo interface {
74+
fmt.Stringer
75+
}

core/abc_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ func (s *bafSender) SendBAF(baf arma_types.BatchAttestationFragment) {
5151
}
5252

5353
type naiveblock struct {
54-
order core.OrderingInfo
54+
order arma_types.OrderingInfo
5555
batch arma_types.Batch
5656
attestation arma_types.BatchAttestation
5757
}
5858

5959
type naiveBlockLedger chan naiveblock
6060

61-
func (n naiveBlockLedger) Append(batch arma_types.Batch, orderingInfo core.OrderingInfo) {
61+
func (n naiveBlockLedger) Append(batch arma_types.Batch, orderingInfo arma_types.OrderingInfo) {
6262
n <- naiveblock{
6363
order: orderingInfo,
6464
batch: batch,

core/assembler.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ package core
99
import (
1010
"encoding/hex"
1111
"errors"
12-
"fmt"
1312
"sync"
1413
"time"
1514

@@ -24,7 +23,7 @@ type OrderedBatchAttestation interface {
2423
BatchAttestation() types.BatchAttestation
2524
// OrderingInfo is an opaque object that provides extra information on the order of the batch attestation and
2625
// metadata to be used in the construction of the block.
27-
OrderingInfo() OrderingInfo
26+
OrderingInfo() types.OrderingInfo
2827
}
2928

3029
type BatchReplicator interface {
@@ -37,12 +36,8 @@ type AssemblerIndex interface {
3736
Stop()
3837
}
3938

40-
type OrderingInfo interface {
41-
fmt.Stringer
42-
}
43-
4439
type AssemblerLedgerWriter interface {
45-
Append(batch types.Batch, orderingInfo OrderingInfo)
40+
Append(batch types.Batch, orderingInfo types.OrderingInfo)
4641
Close()
4742
}
4843

core/assembler_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,20 +138,20 @@ func (noi *naiveOrderingInfo) String() string {
138138

139139
type naiveOrderedBatchAttestation struct {
140140
ba types.BatchAttestation
141-
orderingInfo core.OrderingInfo
141+
orderingInfo types.OrderingInfo
142142
}
143143

144144
func (noba *naiveOrderedBatchAttestation) BatchAttestation() types.BatchAttestation {
145145
return noba.ba
146146
}
147147

148-
func (noba *naiveOrderedBatchAttestation) OrderingInfo() core.OrderingInfo {
148+
func (noba *naiveOrderedBatchAttestation) OrderingInfo() types.OrderingInfo {
149149
return noba.orderingInfo
150150
}
151151

152152
type naiveAssemblerLedger chan core.OrderedBatchAttestation
153153

154-
func (n naiveAssemblerLedger) Append(batch types.Batch, orderingInfo core.OrderingInfo) {
154+
func (n naiveAssemblerLedger) Append(batch types.Batch, orderingInfo types.OrderingInfo) {
155155
noba := &naiveOrderedBatchAttestation{
156156
ba: &naiveBatchAttestation{
157157
primary: batch.Primary(),

node/assembler/assembler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func createLedgerMockWrappingRealLedger(logger types.Logger, ledgerPath string)
6464
mock := &ledger_mocks.FakeAssemblerLedgerReaderWriter{}
6565
ledger, err := node_ledger.NewAssemblerLedger(logger, ledgerPath)
6666

67-
mock.AppendCalls(func(b types.Batch, i core.OrderingInfo) {
67+
mock.AppendCalls(func(b types.Batch, i types.OrderingInfo) {
6868
ledger.Append(b, i)
6969
})
7070
mock.AppendConfigCalls(func(b *common.Block, dn types.DecisionNum) {

node/consensus/state/available_batch_ordered.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ package state
99
import (
1010
"fmt"
1111

12-
"github.com/hyperledger/fabric-x-orderer/common/types"
13-
"github.com/hyperledger/fabric-x-orderer/core"
14-
1512
smartbft_types "github.com/hyperledger-labs/SmartBFT/pkg/types"
13+
"github.com/hyperledger/fabric-x-orderer/common/types"
1614
)
1715

1816
type OrderingInformation struct {
@@ -42,6 +40,6 @@ func (abo *AvailableBatchOrdered) BatchAttestation() types.BatchAttestation {
4240

4341
// OrderingInfo returns an opaque object that provides extra information on the order of the batch attestation and
4442
// metadata to be used in the construction of the block.
45-
func (abo *AvailableBatchOrdered) OrderingInfo() core.OrderingInfo {
43+
func (abo *AvailableBatchOrdered) OrderingInfo() types.OrderingInfo {
4644
return abo.OrderingInformation
4745
}

node/ledger/assembler_ledger.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@ import (
1313
"sync/atomic"
1414
"time"
1515

16+
"github.com/hyperledger/fabric-lib-go/common/metrics/disabled"
17+
"github.com/hyperledger/fabric-protos-go-apiv2/common"
1618
"github.com/hyperledger/fabric-x-orderer/common/ledger/blkstorage"
1719
"github.com/hyperledger/fabric-x-orderer/common/ledger/blockledger"
1820
"github.com/hyperledger/fabric-x-orderer/common/ledger/blockledger/fileledger"
1921
"github.com/hyperledger/fabric-x-orderer/common/types"
20-
"github.com/hyperledger/fabric-x-orderer/core"
2122
"github.com/hyperledger/fabric-x-orderer/node/consensus/state"
22-
23-
"github.com/hyperledger/fabric-lib-go/common/metrics/disabled"
24-
"github.com/hyperledger/fabric-protos-go-apiv2/common"
2523
"github.com/hyperledger/fabric/protoutil"
2624
)
2725

@@ -33,7 +31,7 @@ type (
3331
//go:generate counterfeiter -o ./mocks/assembler_ledger.go . AssemblerLedgerReaderWriter
3432
type AssemblerLedgerReaderWriter interface {
3533
GetTxCount() uint64
36-
Append(batch types.Batch, orderingInfo core.OrderingInfo)
34+
Append(batch types.Batch, orderingInfo types.OrderingInfo)
3735
AppendConfig(configBlock *common.Block, decisionNum types.DecisionNum)
3836
LastOrderingInfo() (*state.OrderingInformation, error)
3937
LedgerReader() blockledger.Reader
@@ -134,7 +132,7 @@ func (l *AssemblerLedger) GetTxCount() uint64 {
134132
return c
135133
}
136134

137-
func (l *AssemblerLedger) Append(batch types.Batch, orderingInfo core.OrderingInfo) {
135+
func (l *AssemblerLedger) Append(batch types.Batch, orderingInfo types.OrderingInfo) {
138136
ordInfo := orderingInfo.(*state.OrderingInformation)
139137
t1 := time.Now()
140138
defer func() {

node/ledger/mocks/assembler_ledger.go

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

0 commit comments

Comments
 (0)