MCPcopy
hub / github.com/hyperledger/fabric / Work

Method Work

core/chaincode/lifecycle/custodian.go:87–126  ·  view source on GitHub ↗
(buildRegistry *container.BuildRegistry, builder ChaincodeBuilder, launcher ChaincodeLauncher)

Source from the content-addressed store, hash-verified

85}
86
87func (cc *ChaincodeCustodian) Work(buildRegistry *container.BuildRegistry, builder ChaincodeBuilder, launcher ChaincodeLauncher) {
88 for {
89 cc.mutex.Lock()
90 if len(cc.choreQueue) == 0 && !cc.halt {
91 cc.cond.Wait()
92 }
93 if cc.halt {
94 cc.mutex.Unlock()
95 return
96 }
97 chore := cc.choreQueue[0]
98 cc.choreQueue = cc.choreQueue[1:]
99 cc.mutex.Unlock()
100
101 if chore.runnable {
102 if err := launcher.Launch(chore.chaincodeID); err != nil {
103 logger.Warningf("could not launch chaincode '%s': %s", chore.chaincodeID, err)
104 }
105 continue
106 }
107
108 if chore.stoppable {
109 if err := launcher.Stop(chore.chaincodeID); err != nil {
110 logger.Warningf("could not stop chaincode '%s': %s", chore.chaincodeID, err)
111 }
112 continue
113 }
114
115 buildStatus, ok := buildRegistry.BuildStatus(chore.chaincodeID)
116 if ok {
117 logger.Debugf("skipping build of chaincode '%s' as it is already in progress", chore.chaincodeID)
118 continue
119 }
120 err := builder.Build(chore.chaincodeID)
121 if err != nil {
122 logger.Warningf("could not build chaincode '%s': %s", chore.chaincodeID, err)
123 }
124 buildStatus.Notify(err)
125 }
126}

Callers 3

serveFunction · 0.95
custodian_test.goFile · 0.80
cache_test.goFile · 0.80

Calls 10

LockMethod · 0.80
UnlockMethod · 0.80
BuildStatusMethod · 0.80
DebugfMethod · 0.80
WaitMethod · 0.65
LaunchMethod · 0.65
WarningfMethod · 0.65
StopMethod · 0.65
BuildMethod · 0.65
NotifyMethod · 0.45

Tested by

no test coverage detected