func newDataNodesDelta(stateDelta *statemgmt.StateDelta) *dataNodesDelta { dataNodesDelta := &dataNodesDelta{make(map[bucketKey]dataNodes)} chaincodeIDs := stateDelta.GetUpdatedChaincodeIds(false) for _, chaincodeID := range chaincodeIDs { updates := stateDelta.GetUpdates(chaincodeID) for key, updatedValue := range updates { if stateDelta.RollBackwards { dataNodesDelta.add(chaincodeID, key, updatedValue.GetPreviousValue()) } else { dataNodesDelta.add(chaincodeID, key, updatedValue.GetValue()) } } } for _, dataNodes := range dataNodesDelta.byBucket { sort.Sort(dataNodes) } return dataNodesDelta }
func newTrieDelta(stateDelta *statemgmt.StateDelta) *trieDelta { trieDelta := &trieDelta{0, make(map[int]levelDeltaMap)} chaincodes := stateDelta.GetUpdatedChaincodeIds(false) for _, chaincodeID := range chaincodes { updates := stateDelta.GetUpdates(chaincodeID) for key, updatedvalue := range updates { if updatedvalue.IsDelete() { trieDelta.delete(chaincodeID, key) } else { if stateDelta.RollBackwards { trieDelta.set(chaincodeID, key, updatedvalue.GetPreviousValue()) } else { trieDelta.set(chaincodeID, key, updatedvalue.GetValue()) } } } } return trieDelta }