Skip to content

Commit f09b5da

Browse files
committed
This commits replace peer.Block2 by common.Block
https://jira.hyperledger.org/browse/FAB-1201 Change-Id: I34f7f56887c25dae712188a50e8bdcd13ae619d2 Signed-off-by: manish <[email protected]>
1 parent 2570f8f commit f09b5da

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1357
-1304
lines changed

core/chaincode/exectransaction_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import (
4040
"github.com/golang/protobuf/proto"
4141
"github.com/hyperledger/fabric/core/crypto/primitives"
4242
"github.com/hyperledger/fabric/msp"
43+
"github.com/hyperledger/fabric/protos/common"
4344
"github.com/spf13/viper"
4445
"golang.org/x/net/context"
4546
"google.golang.org/grpc"
@@ -182,7 +183,8 @@ func endTxSimulation(txsim ledger.TxSimulator, payload []byte, commit bool, prop
182183
}
183184

184185
//create the block with 1 transaction
185-
block := &pb.Block2{Transactions: [][]byte{envBytes}}
186+
block := common.NewBlock(1, []byte{})
187+
block.Data.Data = [][]byte{envBytes}
186188
if _, _, err = lgr.RemoveInvalidTransactionsAndPrepare(block); err != nil {
187189
return err
188190
}

core/chaincode/shim/table.pb.go

+27-27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/committer/committer.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ limitations under the License.
1616

1717
package committer
1818

19-
import (
20-
pb "github.com/hyperledger/fabric/protos/peer"
21-
)
19+
import "github.com/hyperledger/fabric/protos/common"
2220

2321
// Committer is the interface supported by committers
2422
// The only committer is noopssinglechain committer.
@@ -30,13 +28,13 @@ import (
3028
type Committer interface {
3129

3230
// Commit block to the ledger
33-
CommitBlock(block *pb.Block2) error
31+
CommitBlock(block *common.Block) error
3432

3533
// Get recent block sequence number
3634
LedgerHeight() (uint64, error)
3735

3836
// Gets blocks with sequence numbers provided in the slice
39-
GetBlocks(blockSeqs []uint64) []*pb.Block2
37+
GetBlocks(blockSeqs []uint64) []*common.Block
4038

4139
// Closes committing service
4240
Close()

core/committer/committer_impl.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package committer
1818

1919
import (
2020
"github.com/hyperledger/fabric/core/ledger"
21+
"github.com/hyperledger/fabric/protos/common"
2122
pb "github.com/hyperledger/fabric/protos/peer"
2223
"github.com/op/go-logging"
2324
)
@@ -46,7 +47,7 @@ func NewLedgerCommitter(ledger ledger.ValidatedLedger) *LedgerCommitter {
4647
}
4748

4849
// CommitBlock commits block to into the ledger
49-
func (lc *LedgerCommitter) CommitBlock(block *pb.Block2) error {
50+
func (lc *LedgerCommitter) CommitBlock(block *common.Block) error {
5051
if _, _, err := lc.ledger.RemoveInvalidTransactionsAndPrepare(block); err != nil {
5152
return err
5253
}
@@ -69,8 +70,8 @@ func (lc *LedgerCommitter) LedgerHeight() (uint64, error) {
6970
}
7071

7172
// GetBlocks used to retrieve blocks with sequence numbers provided in the slice
72-
func (lc *LedgerCommitter) GetBlocks(blockSeqs []uint64) []*pb.Block2 {
73-
var blocks []*pb.Block2
73+
func (lc *LedgerCommitter) GetBlocks(blockSeqs []uint64) []*common.Block {
74+
var blocks []*common.Block
7475

7576
for _, seqNum := range blockSeqs {
7677
if blck, err := lc.ledger.GetBlockByNumber(seqNum); err != nil {

core/committer/committer_test.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func TestKVLedgerBlockStorage(t *testing.T) {
5151
simulator.Done()
5252

5353
simRes, _ := simulator.GetTxSimulationResults()
54-
block1 := testutil.ConstructBlockForSimulationResults(t, [][]byte{simRes}, true)
54+
block1 := testutil.ConstructBlock(t, [][]byte{simRes}, true)
5555

5656
err = committer.CommitBlock(block1)
5757
assert.NoError(t, err)
@@ -65,8 +65,7 @@ func TestKVLedgerBlockStorage(t *testing.T) {
6565
assert.NoError(t, err)
6666

6767
bcInfo, _ = ledger.GetBlockchainInfo()
68-
serBlock1, _ := pb.ConstructSerBlock2(block1)
69-
block1Hash := serBlock1.ComputeHash()
68+
block1Hash := block1.Header.Hash()
7069
testutil.AssertEquals(t, bcInfo, &pb.BlockchainInfo{
7170
Height: 1, CurrentBlockHash: block1Hash, PreviousBlockHash: []byte{}})
7271
}

core/committer/noopssinglechain/client.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ import (
4040
"github.com/hyperledger/fabric/gossip/integration"
4141
gossip_proto "github.com/hyperledger/fabric/gossip/proto"
4242
"github.com/hyperledger/fabric/gossip/state"
43-
pb "github.com/hyperledger/fabric/protos/peer"
4443
)
4544

4645
var logger *logging.Logger // package-level logger
@@ -243,8 +242,11 @@ func (d *DeliverService) readUntilClose() {
243242
}
244243
logger.Warning("Got error ", t)
245244
case *orderer.DeliverResponse_Block:
246-
block := &pb.Block2{}
247245
seqNum := t.Block.Header.Number
246+
block := &common.Block{}
247+
block.Header = t.Block.Header
248+
block.Metadata = t.Block.Metadata
249+
block.Data = &common.BlockData{}
248250
for _, d := range t.Block.Data.Data {
249251
if d != nil {
250252
if env, err := putils.GetEnvelopeFromBlock(d); err != nil {
@@ -264,7 +266,7 @@ func (d *DeliverService) readUntilClose() {
264266
} else {
265267
// TODO: call VSCC now
266268
if t, err := proto.Marshal(env); err == nil {
267-
block.Transactions = append(block.Transactions, t)
269+
block.Data.Data = append(block.Data.Data, t)
268270
} else {
269271
fmt.Printf("Cannot marshal transactoins %s\n", err)
270272
}
@@ -321,8 +323,8 @@ func createGossipMsg(payload *gossip_proto.Payload) *gossip_proto.GossipMessage
321323
return gossipMsg
322324
}
323325

324-
func createPayload(seqNum uint64, block2 *pb.Block2) *gossip_proto.Payload {
325-
marshaledBlock, _ := proto.Marshal(block2)
326+
func createPayload(seqNum uint64, block *common.Block) *gossip_proto.Payload {
327+
marshaledBlock, _ := proto.Marshal(block)
326328
return &gossip_proto.Payload{
327329
Data: marshaledBlock,
328330
SeqNum: seqNum,

core/crypto/attributes/proto/attributes.pb.go

+9-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/endorser/endorser.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"github.com/hyperledger/fabric/core/ledger/kvledger"
2929
"github.com/hyperledger/fabric/core/peer"
3030
"github.com/hyperledger/fabric/msp"
31+
"github.com/hyperledger/fabric/protos/common"
3132
pb "github.com/hyperledger/fabric/protos/peer"
3233
putils "github.com/hyperledger/fabric/protos/utils"
3334
)
@@ -310,7 +311,9 @@ func (e *Endorser) commitTxSimulation(proposal *pb.Proposal, signer msp.SigningI
310311
if err != nil {
311312
return err
312313
}
313-
block := &pb.Block2{Transactions: [][]byte{txBytes}}
314+
block := common.NewBlock(1, []byte{})
315+
block.Data.Data = [][]byte{txBytes}
316+
block.Header.DataHash = block.Data.Hash()
314317
if _, _, err = lgr.RemoveInvalidTransactionsAndPrepare(block); err != nil {
315318
return err
316319
}

core/ledger/blkstorage/blockstorage.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121

2222
"github.com/hyperledger/fabric/core/ledger"
2323

24+
"github.com/hyperledger/fabric/protos/common"
2425
pb "github.com/hyperledger/fabric/protos/peer"
2526
)
2627

@@ -50,11 +51,11 @@ var (
5051
// An implementation of this interface is expected to take an argument
5152
// of type `IndexConfig` which configures the block store on what items should be indexed
5253
type BlockStore interface {
53-
AddBlock(block *pb.Block2) error
54+
AddBlock(block *common.Block) error
5455
GetBlockchainInfo() (*pb.BlockchainInfo, error)
5556
RetrieveBlocks(startNum uint64) (ledger.ResultsIterator, error)
56-
RetrieveBlockByHash(blockHash []byte) (*pb.Block2, error)
57-
RetrieveBlockByNumber(blockNum uint64) (*pb.Block2, error)
57+
RetrieveBlockByHash(blockHash []byte) (*common.Block, error)
58+
RetrieveBlockByNumber(blockNum uint64) (*common.Block, error)
5859
RetrieveTxByID(txID string) (*pb.Transaction, error)
5960
Shutdown()
6061
}

0 commit comments

Comments
 (0)