-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-5535]: Add coordinator for blocks and pvtdata
Currently there is a state transfer layer in gossip, which takes care to reordering the blocks according to the sequence number order, as well it takes care to replicate blocks in case of network distruptions and there are missing blocks in peer state. In context of work required for FAB-1151, where there is private data which distributed off the leadger, meaning not a part of transaction proposal submitted to the ordering service. There is a need to coordinate availability of this private data and the block itself. Therefore this commit adds new entity to orchestrate the arrival of blocks and the readiness of the block for commit, e.g. when peer will have all relevant private data kept in transient store coordinator will commit it into the ledger providing required private data. Change-Id: I9cf47c9647e3f7fc949c5af2c6cd73c991f970d5 Signed-off-by: Artem Barger <[email protected]>
- Loading branch information
Showing
3 changed files
with
373 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
Copyright IBM Corp. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package state | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hyperledger/fabric/core/committer" | ||
"github.com/hyperledger/fabric/protos/common" | ||
"github.com/hyperledger/fabric/protos/ledger/rwset" | ||
) | ||
|
||
// PvtData a placeholder to represent private data | ||
type PvtData struct { | ||
Payload *rwset.TxPvtReadWriteSet | ||
} | ||
|
||
// Coordinator orchestrates the flow of the new | ||
// blocks arrival and in flight transient data, responsible | ||
// to complete missing parts of transient data for given block. | ||
type Coordinator interface { | ||
// StoreBlock deliver new block with underlined private data | ||
// returns missing transaction ids | ||
StoreBlock(block *common.Block, data ...[]*PvtData) ([]string, error) | ||
|
||
// GetBlockByNum returns block and related to the block private data | ||
GetBlockByNum(seqNum uint64) (*common.Block, []*PvtData, error) | ||
|
||
// Get recent block sequence number | ||
LedgerHeight() (uint64, error) | ||
|
||
// Close coordinator, shuts down coordinator service | ||
Close() | ||
} | ||
|
||
type coordinator struct { | ||
committer.Committer | ||
} | ||
|
||
// NewCoordinator creates a new instance of coordinator | ||
func NewCoordinator(committer committer.Committer) Coordinator { | ||
return &coordinator{Committer: committer} | ||
} | ||
|
||
func (c *coordinator) StoreBlock(block *common.Block, data ...[]*PvtData) ([]string, error) { | ||
// Need to check whenever there are missing private rwset | ||
return nil, c.Committer.Commit(block) | ||
} | ||
|
||
func (c *coordinator) GetBlockByNum(seqNum uint64) (*common.Block, []*PvtData, error) { | ||
blocks := c.Committer.GetBlocks([]uint64{seqNum}) | ||
if len(blocks) == 0 { | ||
return nil, nil, fmt.Errorf("Cannot retreive block number %d", seqNum) | ||
} | ||
return blocks[0], nil, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.