diff --git a/orderer/common/bootstrap/static/static.go b/orderer/common/bootstrap/static/static.go index 5d7c046d95f..57fd6e803ef 100644 --- a/orderer/common/bootstrap/static/static.go +++ b/orderer/common/bootstrap/static/static.go @@ -17,9 +17,6 @@ limitations under the License. package static import ( - "fmt" - - "github.com/hyperledger/fabric/core/crypto/primitives" "github.com/hyperledger/fabric/orderer/common/bootstrap" "github.com/hyperledger/fabric/orderer/common/cauthdsl" "github.com/hyperledger/fabric/orderer/common/configtx" @@ -27,6 +24,8 @@ import ( cb "github.com/hyperledger/fabric/protos/common" ) +var TestChainID = []byte("**TEST_CHAINID**") + const msgVersion = int32(1) type bootstrapper struct { @@ -35,11 +34,7 @@ type bootstrapper struct { // New returns a new static bootstrap helper. func New() bootstrap.Helper { - chainID, err := primitives.GetRandomBytes(16) - if err != nil { - panic(fmt.Errorf("Cannot generate random chain ID: %s", err)) - } - return &bootstrapper{chainID} + return &bootstrapper{chainID: TestChainID} } // GenesisBlock returns the genesis block to be used for bootstrapping diff --git a/orderer/sample_clients/bd_counter/broadcast.go b/orderer/sample_clients/bd_counter/broadcast.go index faeaf10cdcf..652dfa91942 100644 --- a/orderer/sample_clients/bd_counter/broadcast.go +++ b/orderer/sample_clients/bd_counter/broadcast.go @@ -21,9 +21,11 @@ import ( "io" "strconv" - "github.com/golang/protobuf/proto" + "github.com/hyperledger/fabric/orderer/common/bootstrap/static" cb "github.com/hyperledger/fabric/protos/common" ab "github.com/hyperledger/fabric/protos/orderer" + + "github.com/golang/protobuf/proto" context "golang.org/x/net/context" ) @@ -49,7 +51,14 @@ func (c *clientImpl) broadcast() { logger.Info("Client shutting down") return case tokenChan <- struct{}{}: - payload, err := proto.Marshal(&cb.Payload{Data: []byte(strconv.Itoa(count))}) + payload, err := proto.Marshal(&cb.Payload{ + Header: &cb.Header{ + ChainHeader: &cb.ChainHeader{ + ChainID: static.TestChainID, + }, + }, + Data: []byte(strconv.Itoa(count)), + }) if err != nil { panic(err) } diff --git a/orderer/sample_clients/bd_counter/deliver.go b/orderer/sample_clients/bd_counter/deliver.go index 39b8768d76c..1a3a2aadbd1 100644 --- a/orderer/sample_clients/bd_counter/deliver.go +++ b/orderer/sample_clients/bd_counter/deliver.go @@ -21,6 +21,7 @@ import ( "io" "log" + "github.com/hyperledger/fabric/orderer/common/bootstrap/static" ab "github.com/hyperledger/fabric/protos/orderer" context "golang.org/x/net/context" ) @@ -30,6 +31,7 @@ func (c *clientImpl) deliver() { Type: &ab.DeliverUpdate_Seek{ Seek: &ab.SeekInfo{ WindowSize: uint64(c.config.window), + ChainID: static.TestChainID, }, }, } diff --git a/orderer/sample_clients/broadcast_timestamp/client.go b/orderer/sample_clients/broadcast_timestamp/client.go index a38ba10d778..63ca7ba19b0 100644 --- a/orderer/sample_clients/broadcast_timestamp/client.go +++ b/orderer/sample_clients/broadcast_timestamp/client.go @@ -21,6 +21,7 @@ import ( "time" "github.com/golang/protobuf/proto" + "github.com/hyperledger/fabric/orderer/common/bootstrap/static" "github.com/hyperledger/fabric/orderer/config" cb "github.com/hyperledger/fabric/protos/common" ab "github.com/hyperledger/fabric/protos/orderer" @@ -38,7 +39,14 @@ func newBroadcastClient(client ab.AtomicBroadcast_BroadcastClient) *broadcastCli } func (s *broadcastClient) broadcast(transaction []byte) error { - payload, err := proto.Marshal(&cb.Payload{Data: transaction}) + payload, err := proto.Marshal(&cb.Payload{ + Header: &cb.Header{ + ChainHeader: &cb.ChainHeader{ + ChainID: static.TestChainID, + }, + }, + Data: transaction, + }) if err != nil { panic(err) } diff --git a/orderer/sample_clients/deliver_stdout/client.go b/orderer/sample_clients/deliver_stdout/client.go index 74166f40552..16ee633dd7b 100644 --- a/orderer/sample_clients/deliver_stdout/client.go +++ b/orderer/sample_clients/deliver_stdout/client.go @@ -19,6 +19,7 @@ package main import ( "fmt" + "github.com/hyperledger/fabric/orderer/common/bootstrap/static" "github.com/hyperledger/fabric/orderer/config" cb "github.com/hyperledger/fabric/protos/common" ab "github.com/hyperledger/fabric/protos/orderer" @@ -42,6 +43,7 @@ func (r *deliverClient) seekOldest() error { Seek: &ab.SeekInfo{ Start: ab.SeekInfo_OLDEST, WindowSize: r.windowSize, + ChainID: static.TestChainID, }, }, }) @@ -53,6 +55,7 @@ func (r *deliverClient) seekNewest() error { Seek: &ab.SeekInfo{ Start: ab.SeekInfo_NEWEST, WindowSize: r.windowSize, + ChainID: static.TestChainID, }, }, }) @@ -65,6 +68,7 @@ func (r *deliverClient) seek(blockNumber uint64) error { Start: ab.SeekInfo_SPECIFIED, SpecifiedNumber: blockNumber, WindowSize: r.windowSize, + ChainID: static.TestChainID, }, }, }) diff --git a/orderer/sample_clients/single_tx_client/single_tx_client.go b/orderer/sample_clients/single_tx_client/single_tx_client.go index 49ce22eb85d..0a8ed19e02a 100644 --- a/orderer/sample_clients/single_tx_client/single_tx_client.go +++ b/orderer/sample_clients/single_tx_client/single_tx_client.go @@ -20,9 +20,11 @@ import ( "fmt" "time" - "github.com/golang/protobuf/proto" + "github.com/hyperledger/fabric/orderer/common/bootstrap/static" cb "github.com/hyperledger/fabric/protos/common" ab "github.com/hyperledger/fabric/protos/orderer" + + "github.com/golang/protobuf/proto" "github.com/op/go-logging" "golang.org/x/net/context" "google.golang.org/grpc" @@ -96,7 +98,7 @@ func updateReceiver(resultch chan byte, errorch chan error, client ab.AtomicBroa errorch <- fmt.Errorf("Failed to get Deliver stream: %s", err) return } - dstream.Send(&ab.DeliverUpdate{Type: &ab.DeliverUpdate_Seek{Seek: &ab.SeekInfo{Start: ab.SeekInfo_NEWEST, WindowSize: 10}}}) + dstream.Send(&ab.DeliverUpdate{Type: &ab.DeliverUpdate_Seek{Seek: &ab.SeekInfo{Start: ab.SeekInfo_NEWEST, WindowSize: 10, ChainID: static.TestChainID}}}) logger.Info("{Update Receiver} Listening to ledger updates.") for i := 0; i < 2; i++ { m, inerr := dstream.Recv() @@ -129,7 +131,14 @@ func broadcastSender(resultch chan byte, errorch chan error, client ab.AtomicBro return } bs := []byte{0, 1, 2, 3} - pl := &cb.Payload{Data: bs} + pl := &cb.Payload{ + Header: &cb.Header{ + ChainHeader: &cb.ChainHeader{ + ChainID: static.TestChainID, + }, + }, + Data: bs, + } mpl, err := proto.Marshal(pl) if err != nil { panic("Failed to marshal payload.")