Skip to content

Commit

Permalink
[FABG-830] Add wait method for chaincoded
Browse files Browse the repository at this point in the history
Change-Id: Ibc7b0cc616dc02cfb369be98e936ec3110e9c4c3
Signed-off-by: Firas Qutishat <firas.qutishat@securekey.com>
  • Loading branch information
fqutishat committed Mar 20, 2019
1 parent 00a50ff commit 11dc83c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions scripts/_go/src/chaincoded/cmd/chaincoded/chaincoded.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var (
containerNameRegEx = regexp.MustCompile("(.*)-(.*)-(.*)-(.*)")
containerStartRegEx = regexp.MustCompile("/containers/(.+)/start")
containerUploadRegEx = regexp.MustCompile("/containers/(.+)/archive")
waitUploadRegEx = regexp.MustCompile("/containers/(.+)/wait")
)

var peerEndpoints map[string]string
Expand Down Expand Up @@ -241,6 +242,10 @@ func (d *chaincoded) handleOtherRequest(w http.ResponseWriter, r *http.Request)
w.WriteHeader(200)
}

func (d *chaincoded) handleWaitRequest(w http.ResponseWriter, r *http.Request) {
select {}
}

func randomHexString(len int) string {
b := make([]byte, len)
rand.Read(b)
Expand Down Expand Up @@ -299,6 +304,7 @@ func (d *chaincoded) ServeHTTP(w http.ResponseWriter, r *http.Request) {
startMatches := containerStartRegEx.FindStringSubmatch(r.URL.Path)
uploadMatches := containerUploadRegEx.FindStringSubmatch(r.URL.Path)
createMatches := containerCreateRegEx.FindStringSubmatch(r.URL.Path)
waitMatches := waitUploadRegEx.FindStringSubmatch(r.URL.Path)

logDebugf("Handling HTTP request [%s]", r.URL)
if startMatches != nil {
Expand All @@ -307,6 +313,9 @@ func (d *chaincoded) ServeHTTP(w http.ResponseWriter, r *http.Request) {
d.handleUploadToContainerRequest(w, r, uploadMatches[1])
} else if createMatches != nil {
d.handleCreateContainerRequest(w, r)
} else if waitMatches != nil {
logDebugf("Handling handleWaitRequest")
d.handleWaitRequest(w, r)
} else {
d.handleOtherRequest(w, r)
}
Expand Down

0 comments on commit 11dc83c

Please sign in to comment.