Skip to content

Commit

Permalink
[FAB-1190] Make Rawledger accept metadata
Browse files Browse the repository at this point in the history
SBFT needs to persist its own batch headers and signatures on its ledger
(Rawledger, implementations: Fileledger, Ramledger). Rawledger interface
needs to be modified to accept custom metadata where those objects can
be stored.


Change-Id: I0127b2a31a327c8ac39082b07627871951f82a0e
Signed-off-by: Gabor Hosszu <gabor@digitalasset.com>
  • Loading branch information
gaborh-da committed Nov 23, 2016
1 parent 68aef4e commit f6d1be2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions orderer/rawledger/fileledger/fileledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func (fl *fileLedger) Height() uint64 {
}

// Append creates a new block and appends it to the ledger
func (fl *fileLedger) Append(messages []*cb.Envelope, proof []byte) *cb.Block {
func (fl *fileLedger) Append(messages []*cb.Envelope, metadata [][]byte) *cb.Block {
data := &cb.BlockData{
Data: make([][]byte, len(messages)),
}
Expand All @@ -170,7 +170,7 @@ func (fl *fileLedger) Append(messages []*cb.Envelope, proof []byte) *cb.Block {
},
Data: data,
Metadata: &cb.BlockMetadata{
Metadata: [][]byte{proof},
Metadata: metadata,
},
}
fl.writeBlock(block)
Expand Down
4 changes: 2 additions & 2 deletions orderer/rawledger/ramledger/ramledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func (cu *cursor) ReadyChan() <-chan struct{} {
}

// Append creates a new block and appends it to the ledger
func (rl *ramLedger) Append(messages []*cb.Envelope, proof []byte) *cb.Block {
func (rl *ramLedger) Append(messages []*cb.Envelope, metadata [][]byte) *cb.Block {
data := &cb.BlockData{
Data: make([][]byte, len(messages)),
}
Expand All @@ -154,7 +154,7 @@ func (rl *ramLedger) Append(messages []*cb.Envelope, proof []byte) *cb.Block {
},
Data: data,
Metadata: &cb.BlockMetadata{
Metadata: [][]byte{proof},
Metadata: metadata,
},
}
rl.appendBlock(block)
Expand Down
2 changes: 1 addition & 1 deletion orderer/rawledger/rawledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type Reader interface {
// Writer allows the caller to modify the raw ledger
type Writer interface {
// Append a new block to the ledger
Append(blockContents []*cb.Envelope, proof []byte) *cb.Block
Append(blockContents []*cb.Envelope, metadata [][]byte) *cb.Block
}

// ReadWriter encapsulated both the reading and writing functions of the rawledger
Expand Down
2 changes: 1 addition & 1 deletion orderer/sbft/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ func (t *Backend) Deliver(batch *s.Batch) {
logger.Warningf("Payload cannot be unmarshalled.")
}
}
t.ledger.Append(blockContents, []byte{})
t.ledger.Append(blockContents, nil)
}

func (t *Backend) Persist(key string, data proto.Message) {
Expand Down

0 comments on commit f6d1be2

Please sign in to comment.