File tree Expand file tree Collapse file tree 4 files changed +22
-14
lines changed
Expand file tree Collapse file tree 4 files changed +22
-14
lines changed Original file line number Diff line number Diff line change @@ -13,11 +13,14 @@ $(BINARY): $(GO_FILES)
1313 go mod tidy
1414 go build -o $(BINARY ) ./cmd/$(BINARY )
1515
16- .PHONY : build image
16+ .PHONY : build clean image
1717
1818# Alias for building program binary
1919build : $(BINARY )
2020
21+ clean :
22+ rm -f $(BINARY )
23+
2124# Build docker image
2225image : build
2326 docker build -t cloudstruct/$(BINARY ) .
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ module github.com/cloudstruct/go-cardano-submit-api
33go 1.17
44
55require (
6- github.com/cloudstruct/go-ouroboros-network v0.13.0
6+ github.com/cloudstruct/go-ouroboros-network v0.13.1
77 github.com/fxamacker/cbor/v2 v2.4.0
88 github.com/gin-contrib/zap v0.0.2
99 github.com/gin-gonic/gin v1.7.7
Original file line number Diff line number Diff line change 11github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8 =
22github.com/benbjohnson/clock v1.1.0 /go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA =
3- github.com/cloudstruct/go-ouroboros-network v0.13.0 h1:q6l4QQocuDTz0TOynEo5jwe9R+9tCL6vLJpWdMer9kc =
4- github.com/cloudstruct/go-ouroboros-network v0.13.0 /go.mod h1:06ggUMerJLwKJkVi5DLX1QMDz8r+R8o92rht7Z4ss9k =
3+ github.com/cloudstruct/go-ouroboros-network v0.13.1 h1:/F9fXKXLmGPdMQrqyBovbTbLUZdj/7cG0qjA/a31cZk =
4+ github.com/cloudstruct/go-ouroboros-network v0.13.1 /go.mod h1:06ggUMerJLwKJkVi5DLX1QMDz8r+R8o92rht7Z4ss9k =
55github.com/davecgh/go-spew v1.1.0 /go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38 =
66github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c =
77github.com/davecgh/go-spew v1.1.1 /go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38 =
Original file line number Diff line number Diff line change @@ -86,15 +86,13 @@ func handleSubmitTx(c *gin.Context) {
8686 },
8787 },
8888 }
89- go func () {
90- err , ok := <- errorChan
91- if ok {
92- logger .Errorf ("failure communicating with node: %s" , err )
93- c .String (500 , "failure communicating with node" )
94- doneChan <- true
95- }
96- }()
9789 oConn , err := ouroboros .New (oOpts )
90+ defer func () {
91+ // We have to close the channel to break out of the async error handler goroutine
92+ close (errorChan )
93+ // Close Ouroboros connection
94+ oConn .Close ()
95+ }()
9896 if err != nil {
9997 logger .Errorf ("failure creating Ouroboros connection: %s" , err )
10098 c .String (500 , "failure communicating with node" )
@@ -113,6 +111,15 @@ func handleSubmitTx(c *gin.Context) {
113111 return
114112 }
115113 }
114+ // Start async error handler
115+ go func () {
116+ err , ok := <- errorChan
117+ if ok {
118+ logger .Errorf ("failure communicating with node: %s" , err )
119+ c .String (500 , "failure communicating with node" )
120+ doneChan <- true
121+ }
122+ }()
116123 // TODO: figure out better way to determine era
117124 if err = oConn .LocalTxSubmission .SubmitTx (block .TX_TYPE_ALONZO , rawTx ); err != nil {
118125 logger .Errorf ("failure submitting transaction: %s" , err )
@@ -121,6 +128,4 @@ func handleSubmitTx(c *gin.Context) {
121128 }
122129 // Wait for async process to finish
123130 <- doneChan
124- // We have to close the channel to break out of the Goroutine waiting on it
125- close (errorChan )
126131}
You can’t perform that action at this time.
0 commit comments