Skip to content

Commit

Permalink
Move configfilter to configtx package
Browse files Browse the repository at this point in the history
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 <jyellick@us.ibm.com>
  • Loading branch information
Jason Yellick committed Dec 5, 2016
1 parent 50120eb commit b4c2cbd
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,21 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package configfilter
package configtx

import (
"github.com/hyperledger/fabric/orderer/common/broadcastfilter"
"github.com/hyperledger/fabric/orderer/common/configtx"
cb "github.com/hyperledger/fabric/protos/common"

"github.com/golang/protobuf/proto"
)

type configFilter struct {
configManager configtx.Manager
configManager Manager
}

// New creates a new configfilter Rule based on the given configtx.Manager
func New(manager configtx.Manager) broadcastfilter.Rule {
// New creates a new configfilter Rule based on the given Manager
func NewFilter(manager Manager) broadcastfilter.Rule {
return &configFilter{
configManager: manager,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package configfilter
package configtx

import (
"fmt"
Expand Down Expand Up @@ -43,7 +43,7 @@ func (mcm *mockConfigManager) ChainID() string {
}

func TestForwardNonConfig(t *testing.T) {
cf := New(&mockConfigManager{})
cf := NewFilter(&mockConfigManager{})
result := cf.Apply(&cb.Envelope{
Payload: []byte("Opaque"),
})
Expand All @@ -53,7 +53,7 @@ func TestForwardNonConfig(t *testing.T) {
}

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

func TestRejectBadConfig(t *testing.T) {
cf := New(&mockConfigManager{err: fmt.Errorf("Error")})
cf := NewFilter(&mockConfigManager{err: fmt.Errorf("Error")})
config, _ := proto.Marshal(&cb.ConfigurationEnvelope{})
configBytes, _ := proto.Marshal(&cb.Payload{Header: &cb.Header{ChainHeader: &cb.ChainHeader{Type: int32(cb.HeaderType_CONFIGURATION_TRANSACTION)}}, Data: config})
result := cf.Apply(&cb.Envelope{
Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions orderer/multichain/chainsupport.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/hyperledger/fabric/orderer/common/blockcutter"
"github.com/hyperledger/fabric/orderer/common/broadcast"
"github.com/hyperledger/fabric/orderer/common/broadcastfilter"
"github.com/hyperledger/fabric/orderer/common/broadcastfilter/configfilter"
"github.com/hyperledger/fabric/orderer/common/configtx"
"github.com/hyperledger/fabric/orderer/common/deliver"
"github.com/hyperledger/fabric/orderer/common/policies"
Expand Down Expand Up @@ -115,7 +114,7 @@ func newChainSupport(configManager configtx.Manager, policyManager policies.Mana
func createBroadcastRuleset(configManager configtx.Manager) *broadcastfilter.RuleSet {
return broadcastfilter.NewRuleSet([]broadcastfilter.Rule{
broadcastfilter.EmptyRejectRule,
configfilter.New(configManager),
configtx.NewFilter(configManager),
broadcastfilter.AcceptRule,
})
}
Expand Down

0 comments on commit b4c2cbd

Please sign in to comment.