Skip to content

Commit

Permalink
Merge "recon: commit oldBlks' pvData to pvtStore"
Browse files Browse the repository at this point in the history
  • Loading branch information
denyeart authored and Gerrit Code Review committed Nov 13, 2018
2 parents adaf1eb + 20fb9b8 commit b2ea980
Show file tree
Hide file tree
Showing 6 changed files with 645 additions and 34 deletions.
4 changes: 4 additions & 0 deletions core/ledger/ledger_interface.go
Expand Up @@ -234,6 +234,8 @@ type MissingPrivateData struct {
IsEligible bool
}

// MissingPrivateDataList encapsulates a list of
// MissingPrivateData
type MissingPrivateDataList struct {
List []*MissingPrivateData
}
Expand All @@ -252,6 +254,7 @@ type BlockPvtData struct {
WriteSets map[uint64]*TxPvtData
}

// Add adds a given missing private data in the MissingPrivateDataList
func (missing *MissingPrivateDataList) Add(txId string, txNum uint64, ns, coll string, isEligible bool) {
missing.List = append(missing.List, &MissingPrivateData{txId, txNum, ns, coll, isEligible})
}
Expand Down Expand Up @@ -386,6 +389,7 @@ type CollectionConfigInfo struct {
CommittingBlockNum uint64
}

// Add adds a missing data entry to the MissingPvtDataInfo Map
func (missingPvtDataInfo MissingPvtDataInfo) Add(blkNum, txNum uint64, ns, coll string) {
missingBlockPvtDataInfo, ok := missingPvtDataInfo[blkNum]
if !ok {
Expand Down
1 change: 1 addition & 0 deletions core/ledger/pvtdatastorage/kv_encoding.go
Expand Up @@ -26,6 +26,7 @@ var (
eligibleMissingDataKeyPrefix = []byte{4}
ineligibleMissingDataKeyPrefix = []byte{5}
collElgKeyPrefix = []byte{6}
lastUpdatedOldBlocksKey = []byte{7}

nilByte = byte(0)
emptyValue = []byte{}
Expand Down
11 changes: 10 additions & 1 deletion core/ledger/pvtdatastorage/persistent_msgs_helper.go
Expand Up @@ -17,8 +17,17 @@ func (e *ExpiryData) getOrCreateCollections(ns string) *Collections {
Map: make(map[string]*TxNums),
MissingDataMap: make(map[string]bool)}
e.Map[ns] = collections
} else {
// due to protobuf encoding/decoding, the previously
// initialized map could be a nil now due to 0 length.
// Hence, we need to reinitialize the map.
if collections.Map == nil {
collections.Map = make(map[string]*TxNums)
}
if collections.MissingDataMap == nil {
collections.MissingDataMap = make(map[string]bool)
}
}

return collections
}

Expand Down
11 changes: 11 additions & 0 deletions core/ledger/pvtdatastorage/store.go
Expand Up @@ -65,6 +65,17 @@ type Store interface {
// collection upgrade transaction and the parameter 'nsCollMap' contains the collections for which the peer
// is now eligible to recieve pvt data
ProcessCollsEligibilityEnabled(committingBlk uint64, nsCollMap map[string][]string) error
// CommitPvtDataOfOldBlocks commits the pvtData (i.e., previously missing data) of old blocks.
// The parameter `blocksPvtData` refers a list of old block's pvtdata which are missing in the pvtstore.
// This call stores an additional entry called `lastUpdatedOldBlocksList` which keeps the exact list
// of updated blocks. This list would be used during recovery process. Once the stateDB is updated with
// these pvtData, the `lastUpdatedOldBlocksList` must be removed. During the peer startup,
// if the `lastUpdatedOldBlocksList` exists, stateDB needs to be updated with the appropriate pvtData.
CommitPvtDataOfOldBlocks(blocksPvtData map[uint64][]*ledger.TxPvtData) error
// GetLastUpdatedOldBlocksList returns the value of `lastUpdatedOldBlocksList`
GetLastUpdatedOldBlocksList() ([]uint64, error)
// ResetLastUpdatedOldBlocksList removes the `lastUpdatedOldBlocksList` entry from the store
ResetLastUpdatedOldBlocksList() error
// IsEmpty returns true if the store does not have any block committed yet
IsEmpty() (bool, error)
// LastCommittedBlockHeight returns the height of the last committed block
Expand Down

0 comments on commit b2ea980

Please sign in to comment.