mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-12 04:41:22 +00:00
linter: couple fixes
This commit is contained in:
4
Makefile
4
Makefile
@ -31,9 +31,7 @@ metalinter_test: ensure_tools
|
|||||||
--enable=deadcode \
|
--enable=deadcode \
|
||||||
--enable=gas \
|
--enable=gas \
|
||||||
--enable=goconst \
|
--enable=goconst \
|
||||||
--enable=goimports \
|
|
||||||
--enable=gosimple \
|
--enable=gosimple \
|
||||||
--enable=gotype \
|
|
||||||
--enable=ineffassign \
|
--enable=ineffassign \
|
||||||
--enable=interfacer \
|
--enable=interfacer \
|
||||||
--enable=megacheck \
|
--enable=megacheck \
|
||||||
@ -52,5 +50,7 @@ metalinter_test: ensure_tools
|
|||||||
#--enable=dupl \
|
#--enable=dupl \
|
||||||
#--enable=errcheck \
|
#--enable=errcheck \
|
||||||
#--enable=gocyclo \
|
#--enable=gocyclo \
|
||||||
|
#--enable=goimports \
|
||||||
#--enable=golint \ <== comments on anything exported
|
#--enable=golint \ <== comments on anything exported
|
||||||
|
#--enable=gotype \
|
||||||
#--enable=unparam \
|
#--enable=unparam \
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
// nolint: goimports
|
|
||||||
package autofile
|
package autofile
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -8,19 +7,18 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
. "github.com/tendermint/tmlibs/common"
|
cmn "github.com/tendermint/tmlibs/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSIGHUP(t *testing.T) {
|
func TestSIGHUP(t *testing.T) {
|
||||||
|
|
||||||
// First, create an AutoFile writing to a tempfile dir
|
// First, create an AutoFile writing to a tempfile dir
|
||||||
file, name := Tempfile("sighup_test")
|
file, name := cmn.Tempfile("sighup_test")
|
||||||
err := file.Close()
|
if err := file.Close(); err != nil {
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Error creating tempfile: %v", err)
|
t.Fatalf("Error creating tempfile: %v", err)
|
||||||
}
|
}
|
||||||
// Here is the actual AutoFile
|
// Here is the actual AutoFile
|
||||||
af, err := OpenAutoFile(name)
|
af, err := cmn.OpenAutoFile(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error creating autofile: %v", err)
|
t.Fatalf("Error creating autofile: %v", err)
|
||||||
}
|
}
|
||||||
@ -36,8 +34,7 @@ func TestSIGHUP(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Move the file over
|
// Move the file over
|
||||||
err = os.Rename(name, name+"_old")
|
if err := os.Rename(name, name+"_old"); err != nil {
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Error moving autofile: %v", err)
|
t.Fatalf("Error moving autofile: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,17 +56,15 @@ func TestSIGHUP(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error writing to autofile: %v", err)
|
t.Fatalf("Error writing to autofile: %v", err)
|
||||||
}
|
}
|
||||||
err = af.Close()
|
if err := af.Close(); err != nil {
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Error closing autofile")
|
t.Fatalf("Error closing autofile")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Both files should exist
|
// Both files should exist
|
||||||
if body := MustReadFile(name + "_old"); string(body) != "Line 1\nLine 2\n" {
|
if body := cmn.MustReadFile(name + "_old"); string(body) != "Line 1\nLine 2\n" {
|
||||||
t.Errorf("Unexpected body %s", body)
|
t.Errorf("Unexpected body %s", body)
|
||||||
}
|
}
|
||||||
if body := MustReadFile(name); string(body) != "Line 3\nLine 4\n" {
|
if body := cmn.MustReadFile(name); string(body) != "Line 3\nLine 4\n" {
|
||||||
t.Errorf("Unexpected body %s", body)
|
t.Errorf("Unexpected body %s", body)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -18,7 +17,7 @@ var (
|
|||||||
func TrapSignal(cb func()) {
|
func TrapSignal(cb func()) {
|
||||||
c := make(chan os.Signal, 1)
|
c := make(chan os.Signal, 1)
|
||||||
signal.Notify(c, os.Interrupt)
|
signal.Notify(c, os.Interrupt)
|
||||||
signal.Notify(c, syscall.SIGTERM)
|
signal.Notify(c, os.Kill) // nolint: megacheck
|
||||||
go func() {
|
go func() {
|
||||||
for sig := range c {
|
for sig := range c {
|
||||||
fmt.Printf("captured %v, exiting...\n", sig)
|
fmt.Printf("captured %v, exiting...\n", sig)
|
||||||
|
@ -140,18 +140,16 @@ func (bs *BaseService) OnStop() {}
|
|||||||
|
|
||||||
// Implements Service
|
// Implements Service
|
||||||
func (bs *BaseService) Reset() (bool, error) {
|
func (bs *BaseService) Reset() (bool, error) {
|
||||||
if atomic.CompareAndSwapUint32(&bs.stopped, 1, 0) {
|
if stopped := atomic.CompareAndSwapUint32(&bs.stopped, 1, 0); !stopped {
|
||||||
// whether or not we've started, we can reset
|
|
||||||
atomic.CompareAndSwapUint32(&bs.started, 1, 0)
|
|
||||||
|
|
||||||
bs.Quit = make(chan struct{})
|
|
||||||
return true, bs.impl.OnReset()
|
|
||||||
} else {
|
|
||||||
bs.Logger.Debug(Fmt("Can't reset %v. Not stopped", bs.name), "impl", bs.impl)
|
bs.Logger.Debug(Fmt("Can't reset %v. Not stopped", bs.name), "impl", bs.impl)
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
// never happens
|
|
||||||
return false, nil // nolint: vet
|
// whether or not we've started, we can reset
|
||||||
|
atomic.CompareAndSwapUint32(&bs.started, 1, 0)
|
||||||
|
|
||||||
|
bs.Quit = make(chan struct{})
|
||||||
|
return true, bs.impl.OnReset()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements Service
|
// Implements Service
|
||||||
|
@ -22,7 +22,6 @@ For larger datasets, use IAVLTree.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// nolint: goimports
|
|
||||||
package merkle
|
package merkle
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
Reference in New Issue
Block a user