Skip to content

Commit

Permalink
This commits replace peer.Block2 by common.Block
Browse files Browse the repository at this point in the history
https://jira.hyperledger.org/browse/FAB-1201

Change-Id: I34f7f56887c25dae712188a50e8bdcd13ae619d2
Signed-off-by: manish <manish.sethi@gmail.com>
  • Loading branch information
manish-sethi committed Dec 1, 2016
1 parent 2570f8f commit f09b5da
Show file tree
Hide file tree
Showing 67 changed files with 1,357 additions and 1,304 deletions.
4 changes: 3 additions & 1 deletion core/chaincode/exectransaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric/core/crypto/primitives"
"github.com/hyperledger/fabric/msp"
"github.com/hyperledger/fabric/protos/common"
"github.com/spf13/viper"
"golang.org/x/net/context"
"google.golang.org/grpc"
Expand Down Expand Up @@ -182,7 +183,8 @@ func endTxSimulation(txsim ledger.TxSimulator, payload []byte, commit bool, prop
}

//create the block with 1 transaction
block := &pb.Block2{Transactions: [][]byte{envBytes}}
block := common.NewBlock(1, []byte{})
block.Data.Data = [][]byte{envBytes}
if _, _, err = lgr.RemoveInvalidTransactionsAndPrepare(block); err != nil {
return err
}
Expand Down
54 changes: 27 additions & 27 deletions core/chaincode/shim/table.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions core/committer/committer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ limitations under the License.

package committer

import (
pb "github.com/hyperledger/fabric/protos/peer"
)
import "github.com/hyperledger/fabric/protos/common"

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

// Commit block to the ledger
CommitBlock(block *pb.Block2) error
CommitBlock(block *common.Block) error

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

// Gets blocks with sequence numbers provided in the slice
GetBlocks(blockSeqs []uint64) []*pb.Block2
GetBlocks(blockSeqs []uint64) []*common.Block

// Closes committing service
Close()
Expand Down
7 changes: 4 additions & 3 deletions core/committer/committer_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package committer

import (
"github.com/hyperledger/fabric/core/ledger"
"github.com/hyperledger/fabric/protos/common"
pb "github.com/hyperledger/fabric/protos/peer"
"github.com/op/go-logging"
)
Expand Down Expand Up @@ -46,7 +47,7 @@ func NewLedgerCommitter(ledger ledger.ValidatedLedger) *LedgerCommitter {
}

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

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

for _, seqNum := range blockSeqs {
if blck, err := lc.ledger.GetBlockByNumber(seqNum); err != nil {
Expand Down
5 changes: 2 additions & 3 deletions core/committer/committer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestKVLedgerBlockStorage(t *testing.T) {
simulator.Done()

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

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

bcInfo, _ = ledger.GetBlockchainInfo()
serBlock1, _ := pb.ConstructSerBlock2(block1)
block1Hash := serBlock1.ComputeHash()
block1Hash := block1.Header.Hash()
testutil.AssertEquals(t, bcInfo, &pb.BlockchainInfo{
Height: 1, CurrentBlockHash: block1Hash, PreviousBlockHash: []byte{}})
}
12 changes: 7 additions & 5 deletions core/committer/noopssinglechain/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import (
"github.com/hyperledger/fabric/gossip/integration"
gossip_proto "github.com/hyperledger/fabric/gossip/proto"
"github.com/hyperledger/fabric/gossip/state"
pb "github.com/hyperledger/fabric/protos/peer"
)

var logger *logging.Logger // package-level logger
Expand Down Expand Up @@ -243,8 +242,11 @@ func (d *DeliverService) readUntilClose() {
}
logger.Warning("Got error ", t)
case *orderer.DeliverResponse_Block:
block := &pb.Block2{}
seqNum := t.Block.Header.Number
block := &common.Block{}
block.Header = t.Block.Header
block.Metadata = t.Block.Metadata
block.Data = &common.BlockData{}
for _, d := range t.Block.Data.Data {
if d != nil {
if env, err := putils.GetEnvelopeFromBlock(d); err != nil {
Expand All @@ -264,7 +266,7 @@ func (d *DeliverService) readUntilClose() {
} else {
// TODO: call VSCC now
if t, err := proto.Marshal(env); err == nil {
block.Transactions = append(block.Transactions, t)
block.Data.Data = append(block.Data.Data, t)
} else {
fmt.Printf("Cannot marshal transactoins %s\n", err)
}
Expand Down Expand Up @@ -321,8 +323,8 @@ func createGossipMsg(payload *gossip_proto.Payload) *gossip_proto.GossipMessage
return gossipMsg
}

func createPayload(seqNum uint64, block2 *pb.Block2) *gossip_proto.Payload {
marshaledBlock, _ := proto.Marshal(block2)
func createPayload(seqNum uint64, block *common.Block) *gossip_proto.Payload {
marshaledBlock, _ := proto.Marshal(block)
return &gossip_proto.Payload{
Data: marshaledBlock,
SeqNum: seqNum,
Expand Down
18 changes: 9 additions & 9 deletions core/crypto/attributes/proto/attributes.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion core/endorser/endorser.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/hyperledger/fabric/core/ledger/kvledger"
"github.com/hyperledger/fabric/core/peer"
"github.com/hyperledger/fabric/msp"
"github.com/hyperledger/fabric/protos/common"
pb "github.com/hyperledger/fabric/protos/peer"
putils "github.com/hyperledger/fabric/protos/utils"
)
Expand Down Expand Up @@ -310,7 +311,9 @@ func (e *Endorser) commitTxSimulation(proposal *pb.Proposal, signer msp.SigningI
if err != nil {
return err
}
block := &pb.Block2{Transactions: [][]byte{txBytes}}
block := common.NewBlock(1, []byte{})
block.Data.Data = [][]byte{txBytes}
block.Header.DataHash = block.Data.Hash()
if _, _, err = lgr.RemoveInvalidTransactionsAndPrepare(block); err != nil {
return err
}
Expand Down
7 changes: 4 additions & 3 deletions core/ledger/blkstorage/blockstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

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

"github.com/hyperledger/fabric/protos/common"
pb "github.com/hyperledger/fabric/protos/peer"
)

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

0 comments on commit f09b5da

Please sign in to comment.