Skip to content

Commit

Permalink
Implement review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
dhaavi committed Sep 27, 2021
1 parent 483cbad commit ac0a517
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion api/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ func (e *Endpoint) ServeHTTP(w http.ResponseWriter, r *http.Request) {

// Wait for the owning module to be ready.
if !moduleIsReady(e.BelongsTo) {
http.Error(w, "The API endpoint is not ready yet. Please try again later.", http.StatusServiceUnavailable)
http.Error(w, "The API endpoint is not ready yet or the its module is not enabled. Please try again later.", http.StatusServiceUnavailable)
return
}

Expand Down
18 changes: 9 additions & 9 deletions formats/varint/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@ func GetNextBlock(data []byte) ([]byte, int, error) {
// EncodedSize returns the size required to varint-encode an uint.
func EncodedSize(n uint64) (size int) {
switch {
case n < 128:
case n < 1<<7: // < 128
return 1
case n < 16384:
case n < 1<<14: // < 16384
return 2
case n < 2097152:
case n < 1<<21: // < 2097152
return 3
case n < 268435456:
case n < 1<<28: // < 268435456
return 4
case n < 34359738368:
case n < 1<<35: // < 34359738368
return 5
case n < 4398046511104:
case n < 1<<42: // < 4398046511104
return 6
case n < 562949953421312:
case n < 1<<49: // < 562949953421312
return 7
case n < 72057594037927936:
case n < 1<<56: // < 72057594037927936
return 8
case n < 9223372036854775808:
case n < 1<<63: // < 9223372036854775808
return 9
default:
return 10
Expand Down
7 changes: 3 additions & 4 deletions modules/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,11 @@ func (m *Module) checkIfStopComplete() {
}

func (m *Module) stop(reports chan *report) {
// check and set intermediate status
m.Lock()
defer m.Unlock()

// check and set intermediate status
if m.status != StatusOnline {
m.Unlock()
go func() {
reports <- &report{
module: m,
Expand All @@ -249,8 +250,6 @@ func (m *Module) stop(reports chan *report) {
m.stopFlag.Set()
m.cancelCtx()

m.Unlock()

go m.stopAllTasks(reports, stopComplete)
}

Expand Down

0 comments on commit ac0a517

Please sign in to comment.