本文整理汇总了Golang中github.com/hyperledger/fabric/core/ledger/statemgmt.StateDelta类的典型用法代码示例。如果您正苦于以下问题:Golang StateDelta类的具体用法?Golang StateDelta怎么用?Golang StateDelta使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StateDelta类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: notifyBlockAdded
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: PrepareWorkingSet
// 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: newDataNodesDelta
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: newTrieDelta
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
}