コード例 #1
0
ファイル: noops.go プロジェクト: C0rWin/fabric
func (i *Noops) notifyBlockAdded(block *pb.Block, delta *statemgmt.StateDelta) error {
	//make Payload nil to reduce block size..
	//anything else to remove .. do we need StateDelta ?
	for _, tx := range block.Transactions {
		tx.Payload = nil
	}
	data, err := proto.Marshal(&pb.BlockState{Block: block, StateDelta: delta.Marshal()})
	if err != nil {
		return fmt.Errorf("Fail to marshall BlockState structure: %v", err)
	}
	if logger.IsEnabledFor(logging.DEBUG) {
		logger.Debug("Broadcasting Message_SYNC_BLOCK_ADDED to non-validators")
	}

	// Broadcast SYNC_BLOCK_ADDED to connected NVPs
	// VPs already know about this newly added block since they participate
	// in the execution. That is, they can compare their current block with
	// the network block
	msg := &pb.Message{Type: pb.Message_SYNC_BLOCK_ADDED,
		Payload: data, Timestamp: util.CreateUtcTimestamp()}
	if errs := i.stack.Broadcast(msg, pb.PeerEndpoint_NON_VALIDATOR); nil != errs {
		return fmt.Errorf("Failed to broadcast with errors: %v", errs)
	}
	return nil
}
コード例 #2
0
ファイル: state_impl.go プロジェクト: RJAugust/fabric
// PrepareWorkingSet - method implementation for interface 'statemgmt.HashableState'
func (stateImpl *StateImpl) PrepareWorkingSet(stateDelta *statemgmt.StateDelta) error {
	logger.Debug("Enter - PrepareWorkingSet()")
	if stateDelta.IsEmpty() {
		logger.Debug("Ignoring working-set as it is empty")
		return nil
	}
	stateImpl.dataNodesDelta = newDataNodesDelta(stateDelta)
	stateImpl.bucketTreeDelta = newBucketTreeDelta()
	stateImpl.recomputeCryptoHash = true
	return nil
}
コード例 #3
0
ファイル: data_nodes_delta.go プロジェクト: RJAugust/fabric
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
}
コード例 #4
0
ファイル: trie_delta.go プロジェクト: yoshiharay/fabric
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.IsDeleted() {
				trieDelta.delete(chaincodeID, key)
			} else {
				if stateDelta.RollBackwards {
					trieDelta.set(chaincodeID, key, updatedvalue.GetPreviousValue())
				} else {
					trieDelta.set(chaincodeID, key, updatedvalue.GetValue())
				}
			}
		}
	}
	return trieDelta
}