Skip to content

Commit b4c2cbd

Browse files
author
Jason Yellick
committed
Move configfilter to configtx package
The broadcastfilter package had a subpackage called configfilter. This was wrong for a number of reasons. First off, the package name stuttered, and secondly it does not filter configuration, rather, it filters configuration transactions. Finally, because of the close dependency on the configtx package, it is natural to group the two together. This move is meant to serve as a prelude to introducing a multichain broadcastfilter which will live within the multichain package. Change-Id: Ibfe2ccc4d5285333ef1d745597ae57641c1c425c Signed-off-by: Jason Yellick <[email protected]>
1 parent 50120eb commit b4c2cbd

File tree

5 files changed

+9
-11
lines changed

5 files changed

+9
-11
lines changed

orderer/common/broadcastfilter/configfilter/configfilter.go orderer/common/configtx/filter.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,21 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package configfilter
17+
package configtx
1818

1919
import (
2020
"github.com/hyperledger/fabric/orderer/common/broadcastfilter"
21-
"github.com/hyperledger/fabric/orderer/common/configtx"
2221
cb "github.com/hyperledger/fabric/protos/common"
2322

2423
"github.com/golang/protobuf/proto"
2524
)
2625

2726
type configFilter struct {
28-
configManager configtx.Manager
27+
configManager Manager
2928
}
3029

31-
// New creates a new configfilter Rule based on the given configtx.Manager
32-
func New(manager configtx.Manager) broadcastfilter.Rule {
30+
// New creates a new configfilter Rule based on the given Manager
31+
func NewFilter(manager Manager) broadcastfilter.Rule {
3332
return &configFilter{
3433
configManager: manager,
3534
}

orderer/common/broadcastfilter/configfilter/configfilter_test.go orderer/common/configtx/filter_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package configfilter
17+
package configtx
1818

1919
import (
2020
"fmt"
@@ -43,7 +43,7 @@ func (mcm *mockConfigManager) ChainID() string {
4343
}
4444

4545
func TestForwardNonConfig(t *testing.T) {
46-
cf := New(&mockConfigManager{})
46+
cf := NewFilter(&mockConfigManager{})
4747
result := cf.Apply(&cb.Envelope{
4848
Payload: []byte("Opaque"),
4949
})
@@ -53,7 +53,7 @@ func TestForwardNonConfig(t *testing.T) {
5353
}
5454

5555
func TestAcceptGoodConfig(t *testing.T) {
56-
cf := New(&mockConfigManager{})
56+
cf := NewFilter(&mockConfigManager{})
5757
config, _ := proto.Marshal(&cb.ConfigurationEnvelope{})
5858
configBytes, _ := proto.Marshal(&cb.Payload{Header: &cb.Header{ChainHeader: &cb.ChainHeader{Type: int32(cb.HeaderType_CONFIGURATION_TRANSACTION)}}, Data: config})
5959
result := cf.Apply(&cb.Envelope{
@@ -65,7 +65,7 @@ func TestAcceptGoodConfig(t *testing.T) {
6565
}
6666

6767
func TestRejectBadConfig(t *testing.T) {
68-
cf := New(&mockConfigManager{err: fmt.Errorf("Error")})
68+
cf := NewFilter(&mockConfigManager{err: fmt.Errorf("Error")})
6969
config, _ := proto.Marshal(&cb.ConfigurationEnvelope{})
7070
configBytes, _ := proto.Marshal(&cb.Payload{Header: &cb.Header{ChainHeader: &cb.ChainHeader{Type: int32(cb.HeaderType_CONFIGURATION_TRANSACTION)}}, Data: config})
7171
result := cf.Apply(&cb.Envelope{
File renamed without changes.

orderer/multichain/chainsupport.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"github.com/hyperledger/fabric/orderer/common/blockcutter"
2121
"github.com/hyperledger/fabric/orderer/common/broadcast"
2222
"github.com/hyperledger/fabric/orderer/common/broadcastfilter"
23-
"github.com/hyperledger/fabric/orderer/common/broadcastfilter/configfilter"
2423
"github.com/hyperledger/fabric/orderer/common/configtx"
2524
"github.com/hyperledger/fabric/orderer/common/deliver"
2625
"github.com/hyperledger/fabric/orderer/common/policies"
@@ -115,7 +114,7 @@ func newChainSupport(configManager configtx.Manager, policyManager policies.Mana
115114
func createBroadcastRuleset(configManager configtx.Manager) *broadcastfilter.RuleSet {
116115
return broadcastfilter.NewRuleSet([]broadcastfilter.Rule{
117116
broadcastfilter.EmptyRejectRule,
118-
configfilter.New(configManager),
117+
configtx.NewFilter(configManager),
119118
broadcastfilter.AcceptRule,
120119
})
121120
}

0 commit comments

Comments
 (0)