new logging
This commit is contained in:
parent
8d8e35ae53
commit
986bdd00a5
|
@ -1,4 +1,2 @@
|
||||||
*.swp
|
|
||||||
*.swo
|
|
||||||
*.pyc
|
|
||||||
vendor
|
vendor
|
||||||
|
.glide
|
||||||
|
|
|
@ -51,7 +51,7 @@ RETRY_LOOP:
|
||||||
if cli.mustConnect {
|
if cli.mustConnect {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Warn(fmt.Sprintf("abci.grpcClient failed to connect to %v. Retrying...\n", cli.addr))
|
cli.Logger.Error(fmt.Sprintf("abci.grpcClient failed to connect to %v. Retrying...\n", cli.addr))
|
||||||
time.Sleep(time.Second * 3)
|
time.Sleep(time.Second * 3)
|
||||||
continue RETRY_LOOP
|
continue RETRY_LOOP
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ func (cli *grpcClient) StopForError(err error) {
|
||||||
}
|
}
|
||||||
cli.mtx.Unlock()
|
cli.mtx.Unlock()
|
||||||
|
|
||||||
log.Warn(fmt.Sprintf("Stopping abci.grpcClient for error: %v", err.Error()))
|
cli.Logger.Error(fmt.Sprintf("Stopping abci.grpcClient for error: %v", err.Error()))
|
||||||
cli.Stop()
|
cli.Stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ func NewLocalClient(mtx *sync.Mutex, app types.Application) *localClient {
|
||||||
mtx: mtx,
|
mtx: mtx,
|
||||||
Application: app,
|
Application: app,
|
||||||
}
|
}
|
||||||
cli.BaseService = *cmn.NewBaseService(log, "localClient", cli)
|
cli.BaseService = *cmn.NewBaseService(nil, "localClient", cli)
|
||||||
return cli
|
return cli
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
package abcicli
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/tendermint/tmlibs/logger"
|
|
||||||
)
|
|
||||||
|
|
||||||
var log = logger.New("module", "abcicli")
|
|
|
@ -70,7 +70,7 @@ RETRY_LOOP:
|
||||||
if cli.mustConnect {
|
if cli.mustConnect {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Warn(fmt.Sprintf("abci.socketClient failed to connect to %v. Retrying...", cli.addr))
|
cli.Logger.Error(fmt.Sprintf("abci.socketClient failed to connect to %v. Retrying...", cli.addr))
|
||||||
time.Sleep(time.Second * 3)
|
time.Sleep(time.Second * 3)
|
||||||
continue RETRY_LOOP
|
continue RETRY_LOOP
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ func (cli *socketClient) StopForError(err error) {
|
||||||
}
|
}
|
||||||
cli.mtx.Unlock()
|
cli.mtx.Unlock()
|
||||||
|
|
||||||
log.Warn(fmt.Sprintf("Stopping abci.socketClient for error: %v", err.Error()))
|
cli.Logger.Error(fmt.Sprintf("Stopping abci.socketClient for error: %v", err.Error()))
|
||||||
cli.Stop()
|
cli.Stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ func (cli *socketClient) sendRequestsRoutine(conn net.Conn) {
|
||||||
cli.StopForError(fmt.Errorf("Error writing msg: %v", err))
|
cli.StopForError(fmt.Errorf("Error writing msg: %v", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// log.Debug("Sent request", "requestType", reflect.TypeOf(reqres.Request), "request", reqres.Request)
|
// cli.Logger.Debug("Sent request", "requestType", reflect.TypeOf(reqres.Request), "request", reqres.Request)
|
||||||
if _, ok := reqres.Request.Value.(*types.Request_Flush); ok {
|
if _, ok := reqres.Request.Value.(*types.Request_Flush); ok {
|
||||||
err = w.Flush()
|
err = w.Flush()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -175,7 +175,7 @@ func (cli *socketClient) recvResponseRoutine(conn net.Conn) {
|
||||||
cli.StopForError(errors.New(r.Exception.Error))
|
cli.StopForError(errors.New(r.Exception.Error))
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
// log.Debug("Received response", "responseType", reflect.TypeOf(res), "response", res)
|
// cli.Logger.Debug("Received response", "responseType", reflect.TypeOf(res), "response", res)
|
||||||
err := cli.didRecvResponse(res)
|
err := cli.didRecvResponse(res)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cli.StopForError(err)
|
cli.StopForError(err)
|
||||||
|
|
|
@ -6,13 +6,14 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
stdlog "log"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/tendermint/abci/client"
|
abcicli "github.com/tendermint/abci/client"
|
||||||
"github.com/tendermint/abci/types"
|
"github.com/tendermint/abci/types"
|
||||||
"github.com/tendermint/abci/version"
|
"github.com/tendermint/abci/version"
|
||||||
|
"github.com/tendermint/tmlibs/log"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -129,7 +130,7 @@ func main() {
|
||||||
app.Before = before
|
app.Before = before
|
||||||
err := app.Run(os.Args)
|
err := app.Run(os.Args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err.Error())
|
stdlog.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -139,8 +140,10 @@ func before(c *cli.Context) error {
|
||||||
var err error
|
var err error
|
||||||
client, err = abcicli.NewClient(c.GlobalString("address"), c.GlobalString("abci"), false)
|
client, err = abcicli.NewClient(c.GlobalString("address"), c.GlobalString("abci"), false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err.Error())
|
stdlog.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
|
logger := log.NewTmLogger(os.Stdout)
|
||||||
|
client.SetLogger(log.With(logger, "module", "abci-client"))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,13 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"log"
|
stdlog "log"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/tendermint/abci/example/counter"
|
"github.com/tendermint/abci/example/counter"
|
||||||
"github.com/tendermint/abci/server"
|
"github.com/tendermint/abci/server"
|
||||||
cmn "github.com/tendermint/tmlibs/common"
|
cmn "github.com/tendermint/tmlibs/common"
|
||||||
|
"github.com/tendermint/tmlibs/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -20,8 +22,10 @@ func main() {
|
||||||
// Start the listener
|
// Start the listener
|
||||||
srv, err := server.NewServer(*addrPtr, *abciPtr, app)
|
srv, err := server.NewServer(*addrPtr, *abciPtr, app)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err.Error())
|
stdlog.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
|
logger := log.NewTmLogger(os.Stdout)
|
||||||
|
srv.SetLogger(log.With(logger, "module", "abci-server"))
|
||||||
|
|
||||||
// Wait forever
|
// Wait forever
|
||||||
cmn.TrapSignal(func() {
|
cmn.TrapSignal(func() {
|
||||||
|
|
|
@ -2,12 +2,14 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"log"
|
stdlog "log"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/tendermint/abci/example/dummy"
|
"github.com/tendermint/abci/example/dummy"
|
||||||
"github.com/tendermint/abci/server"
|
"github.com/tendermint/abci/server"
|
||||||
"github.com/tendermint/abci/types"
|
"github.com/tendermint/abci/types"
|
||||||
cmn "github.com/tendermint/tmlibs/common"
|
cmn "github.com/tendermint/tmlibs/common"
|
||||||
|
"github.com/tendermint/tmlibs/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -17,19 +19,23 @@ func main() {
|
||||||
persistencePtr := flag.String("persist", "", "directory to use for a database")
|
persistencePtr := flag.String("persist", "", "directory to use for a database")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
logger := log.NewTmLogger(os.Stdout)
|
||||||
|
|
||||||
// Create the application - in memory or persisted to disk
|
// Create the application - in memory or persisted to disk
|
||||||
var app types.Application
|
var app types.Application
|
||||||
if *persistencePtr == "" {
|
if *persistencePtr == "" {
|
||||||
app = dummy.NewDummyApplication()
|
app = dummy.NewDummyApplication()
|
||||||
} else {
|
} else {
|
||||||
app = dummy.NewPersistentDummyApplication(*persistencePtr)
|
app = dummy.NewPersistentDummyApplication(*persistencePtr)
|
||||||
|
app.(*dummy.PersistentDummyApplication).SetLogger(log.With(logger, "module", "dummy"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start the listener
|
// Start the listener
|
||||||
srv, err := server.NewServer(*addrPtr, *abciPtr, app)
|
srv, err := server.NewServer(*addrPtr, *abciPtr, app)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err.Error())
|
stdlog.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
|
srv.SetLogger(log.With(logger, "module", "abci-server"))
|
||||||
|
|
||||||
// Wait forever
|
// Wait forever
|
||||||
cmn.TrapSignal(func() {
|
cmn.TrapSignal(func() {
|
||||||
|
|
|
@ -2,11 +2,13 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"log"
|
stdlog "log"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/tendermint/abci/server"
|
"github.com/tendermint/abci/server"
|
||||||
"github.com/tendermint/abci/types"
|
"github.com/tendermint/abci/types"
|
||||||
cmn "github.com/tendermint/tmlibs/common"
|
cmn "github.com/tendermint/tmlibs/common"
|
||||||
|
"github.com/tendermint/tmlibs/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -18,8 +20,10 @@ func main() {
|
||||||
// Start the listener
|
// Start the listener
|
||||||
srv, err := server.NewServer(*addrPtr, *abciPtr, NewChainAwareApplication())
|
srv, err := server.NewServer(*addrPtr, *abciPtr, NewChainAwareApplication())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err.Error())
|
stdlog.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
|
logger := log.NewTmLogger(os.Stdout)
|
||||||
|
srv.SetLogger(log.With(logger, "module", "abci-server"))
|
||||||
|
|
||||||
// Wait forever
|
// Wait forever
|
||||||
cmn.TrapSignal(func() {
|
cmn.TrapSignal(func() {
|
||||||
|
|
|
@ -1,33 +1,35 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"os"
|
||||||
"log"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/tendermint/abci/client"
|
abcicli "github.com/tendermint/abci/client"
|
||||||
"github.com/tendermint/abci/server"
|
"github.com/tendermint/abci/server"
|
||||||
"github.com/tendermint/abci/types"
|
"github.com/tendermint/abci/types"
|
||||||
|
"github.com/tendermint/tmlibs/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestChainAware(t *testing.T) {
|
func TestChainAware(t *testing.T) {
|
||||||
|
|
||||||
app := NewChainAwareApplication()
|
app := NewChainAwareApplication()
|
||||||
|
logger := log.NewTmLogger(os.Stdout)
|
||||||
|
|
||||||
// Start the listener
|
// Start the listener
|
||||||
srv, err := server.NewServer("unix://test.sock", "socket", app)
|
srv, err := server.NewServer("unix://test.sock", "socket", app)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
srv.SetLogger(log.With(logger, "module", "abci-server"))
|
||||||
defer srv.Stop()
|
defer srv.Stop()
|
||||||
|
|
||||||
// Connect to the socket
|
// Connect to the socket
|
||||||
client, err := abcicli.NewSocketClient("unix://test.sock", false)
|
client, err := abcicli.NewSocketClient("unix://test.sock", false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(fmt.Sprintf("Error starting socket client: %v", err.Error()))
|
t.Fatalf("Error starting socket client: %v", err.Error())
|
||||||
}
|
}
|
||||||
|
client.SetLogger(log.With(logger, "module", "abci-client"))
|
||||||
client.Start()
|
client.Start()
|
||||||
defer client.Stop()
|
defer client.Stop()
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package dummy
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -10,9 +11,10 @@ import (
|
||||||
abcicli "github.com/tendermint/abci/client"
|
abcicli "github.com/tendermint/abci/client"
|
||||||
"github.com/tendermint/abci/server"
|
"github.com/tendermint/abci/server"
|
||||||
"github.com/tendermint/abci/types"
|
"github.com/tendermint/abci/types"
|
||||||
"github.com/tendermint/go-crypto"
|
crypto "github.com/tendermint/go-crypto"
|
||||||
"github.com/tendermint/merkleeyes/iavl"
|
"github.com/tendermint/merkleeyes/iavl"
|
||||||
cmn "github.com/tendermint/tmlibs/common"
|
cmn "github.com/tendermint/tmlibs/common"
|
||||||
|
"github.com/tendermint/tmlibs/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func testDummy(t *testing.T, app types.Application, tx []byte, key, value string) {
|
func testDummy(t *testing.T, app types.Application, tx []byte, key, value string) {
|
||||||
|
@ -211,10 +213,13 @@ func valsEqual(t *testing.T, vals1, vals2 []*types.Validator) {
|
||||||
func makeSocketClientServer(app types.Application, name string) (abcicli.Client, cmn.Service, error) {
|
func makeSocketClientServer(app types.Application, name string) (abcicli.Client, cmn.Service, error) {
|
||||||
// Start the listener
|
// Start the listener
|
||||||
socket := cmn.Fmt("unix://%s.sock", name)
|
socket := cmn.Fmt("unix://%s.sock", name)
|
||||||
|
logger := log.NewTmLogger(os.Stdout)
|
||||||
|
|
||||||
server, err := server.NewSocketServer(socket, app)
|
server, err := server.NewSocketServer(socket, app)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
server.SetLogger(log.With(logger, "module", "abci-server"))
|
||||||
|
|
||||||
// Connect to the socket
|
// Connect to the socket
|
||||||
client, err := abcicli.NewSocketClient(socket, false)
|
client, err := abcicli.NewSocketClient(socket, false)
|
||||||
|
@ -222,6 +227,7 @@ func makeSocketClientServer(app types.Application, name string) (abcicli.Client,
|
||||||
server.Stop()
|
server.Stop()
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
client.SetLogger(log.With(logger, "module", "abci-client"))
|
||||||
client.Start()
|
client.Start()
|
||||||
|
|
||||||
return client, server, err
|
return client, server, err
|
||||||
|
@ -230,18 +236,21 @@ func makeSocketClientServer(app types.Application, name string) (abcicli.Client,
|
||||||
func makeGRPCClientServer(app types.Application, name string) (abcicli.Client, cmn.Service, error) {
|
func makeGRPCClientServer(app types.Application, name string) (abcicli.Client, cmn.Service, error) {
|
||||||
// Start the listener
|
// Start the listener
|
||||||
socket := cmn.Fmt("unix://%s.sock", name)
|
socket := cmn.Fmt("unix://%s.sock", name)
|
||||||
|
logger := log.NewTmLogger(os.Stdout)
|
||||||
|
|
||||||
gapp := types.NewGRPCApplication(app)
|
gapp := types.NewGRPCApplication(app)
|
||||||
server, err := server.NewGRPCServer(socket, gapp)
|
server, err := server.NewGRPCServer(socket, gapp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
server.SetLogger(log.With(logger, "module", "abci-server"))
|
||||||
|
|
||||||
client, err := abcicli.NewGRPCClient(socket, true)
|
client, err := abcicli.NewGRPCClient(socket, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
server.Stop()
|
server.Stop()
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
client.SetLogger(log.With(logger, "module", "abci-client"))
|
||||||
return client, server, err
|
return client, server, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
package dummy
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/tendermint/tmlibs/logger"
|
|
||||||
)
|
|
||||||
|
|
||||||
var log = logger.New("module", "dummy")
|
|
|
@ -6,11 +6,13 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
"github.com/tendermint/abci/types"
|
"github.com/tendermint/abci/types"
|
||||||
"github.com/tendermint/go-wire"
|
wire "github.com/tendermint/go-wire"
|
||||||
"github.com/tendermint/merkleeyes/iavl"
|
"github.com/tendermint/merkleeyes/iavl"
|
||||||
cmn "github.com/tendermint/tmlibs/common"
|
cmn "github.com/tendermint/tmlibs/common"
|
||||||
dbm "github.com/tendermint/tmlibs/db"
|
dbm "github.com/tendermint/tmlibs/db"
|
||||||
|
"github.com/tendermint/tmlibs/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -29,6 +31,8 @@ type PersistentDummyApplication struct {
|
||||||
|
|
||||||
// validator set
|
// validator set
|
||||||
changes []*types.Validator
|
changes []*types.Validator
|
||||||
|
|
||||||
|
logger log.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPersistentDummyApplication(dbDir string) *PersistentDummyApplication {
|
func NewPersistentDummyApplication(dbDir string) *PersistentDummyApplication {
|
||||||
|
@ -38,14 +42,19 @@ func NewPersistentDummyApplication(dbDir string) *PersistentDummyApplication {
|
||||||
stateTree := iavl.NewIAVLTree(0, db)
|
stateTree := iavl.NewIAVLTree(0, db)
|
||||||
stateTree.Load(lastBlock.AppHash)
|
stateTree.Load(lastBlock.AppHash)
|
||||||
|
|
||||||
log.Notice("Loaded state", "block", lastBlock.Height, "root", stateTree.Hash())
|
// log.Notice("Loaded state", "block", lastBlock.Height, "root", stateTree.Hash())
|
||||||
|
|
||||||
return &PersistentDummyApplication{
|
return &PersistentDummyApplication{
|
||||||
app: &DummyApplication{state: stateTree},
|
app: &DummyApplication{state: stateTree},
|
||||||
db: db,
|
db: db,
|
||||||
|
logger: log.NewNopLogger(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (app *PersistentDummyApplication) SetLogger(l log.Logger) {
|
||||||
|
app.logger = l
|
||||||
|
}
|
||||||
|
|
||||||
func (app *PersistentDummyApplication) Info() (resInfo types.ResponseInfo) {
|
func (app *PersistentDummyApplication) Info() (resInfo types.ResponseInfo) {
|
||||||
resInfo = app.app.Info()
|
resInfo = app.app.Info()
|
||||||
lastBlock := LoadLastBlock(app.db)
|
lastBlock := LoadLastBlock(app.db)
|
||||||
|
@ -79,13 +88,16 @@ func (app *PersistentDummyApplication) CheckTx(tx []byte) types.Result {
|
||||||
func (app *PersistentDummyApplication) Commit() types.Result {
|
func (app *PersistentDummyApplication) Commit() types.Result {
|
||||||
// Save
|
// Save
|
||||||
appHash := app.app.state.Save()
|
appHash := app.app.state.Save()
|
||||||
log.Info("Saved state", "root", appHash)
|
app.logger.Info("Saved state", "root", appHash)
|
||||||
|
|
||||||
lastBlock := LastBlockInfo{
|
lastBlock := LastBlockInfo{
|
||||||
Height: app.blockHeader.Height,
|
Height: app.blockHeader.Height,
|
||||||
AppHash: appHash, // this hash will be in the next block header
|
AppHash: appHash, // this hash will be in the next block header
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app.logger.Info("Saving block", "height", lastBlock.Height, "root", lastBlock.AppHash)
|
||||||
SaveLastBlock(app.db, lastBlock)
|
SaveLastBlock(app.db, lastBlock)
|
||||||
|
|
||||||
return types.NewResultOK(appHash, "")
|
return types.NewResultOK(appHash, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +110,7 @@ func (app *PersistentDummyApplication) InitChain(validators []*types.Validator)
|
||||||
for _, v := range validators {
|
for _, v := range validators {
|
||||||
r := app.updateValidator(v)
|
r := app.updateValidator(v)
|
||||||
if r.IsErr() {
|
if r.IsErr() {
|
||||||
log.Error("Error updating validators", "r", r)
|
app.logger.Error("Error updating validators", "r", r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,8 +146,7 @@ func LoadLastBlock(db dbm.DB) (lastBlock LastBlockInfo) {
|
||||||
r, n, err := bytes.NewReader(buf), new(int), new(error)
|
r, n, err := bytes.NewReader(buf), new(int), new(error)
|
||||||
wire.ReadBinaryPtr(&lastBlock, r, 0, n, err)
|
wire.ReadBinaryPtr(&lastBlock, r, 0, n, err)
|
||||||
if *err != nil {
|
if *err != nil {
|
||||||
// DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED
|
cmn.PanicCrisis(errors.Wrap(*err, "cannot load last block (data has been corrupted or its spec has changed)"))
|
||||||
log.Crit(cmn.Fmt("Data has been corrupted or its spec has changed: %v\n", *err))
|
|
||||||
}
|
}
|
||||||
// TODO: ensure that buf is completely read.
|
// TODO: ensure that buf is completely read.
|
||||||
}
|
}
|
||||||
|
@ -144,12 +155,11 @@ func LoadLastBlock(db dbm.DB) (lastBlock LastBlockInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func SaveLastBlock(db dbm.DB, lastBlock LastBlockInfo) {
|
func SaveLastBlock(db dbm.DB, lastBlock LastBlockInfo) {
|
||||||
log.Notice("Saving block", "height", lastBlock.Height, "root", lastBlock.AppHash)
|
|
||||||
buf, n, err := new(bytes.Buffer), new(int), new(error)
|
buf, n, err := new(bytes.Buffer), new(int), new(error)
|
||||||
wire.WriteBinary(lastBlock, buf, n, err)
|
wire.WriteBinary(lastBlock, buf, n, err)
|
||||||
if *err != nil {
|
if *err != nil {
|
||||||
// TODO
|
// TODO
|
||||||
cmn.PanicCrisis(*err)
|
cmn.PanicCrisis(errors.Wrap(*err, "cannot save last block"))
|
||||||
}
|
}
|
||||||
db.Set(lastBlockKey, buf.Bytes())
|
db.Set(lastBlockKey, buf.Bytes())
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,9 @@ package example
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
stdlog "log"
|
||||||
"net"
|
"net"
|
||||||
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
@ -12,11 +13,12 @@ import (
|
||||||
|
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
|
|
||||||
"github.com/tendermint/abci/client"
|
abcicli "github.com/tendermint/abci/client"
|
||||||
"github.com/tendermint/abci/example/dummy"
|
"github.com/tendermint/abci/example/dummy"
|
||||||
"github.com/tendermint/abci/server"
|
"github.com/tendermint/abci/server"
|
||||||
"github.com/tendermint/abci/types"
|
"github.com/tendermint/abci/types"
|
||||||
cmn "github.com/tendermint/tmlibs/common"
|
cmn "github.com/tendermint/tmlibs/common"
|
||||||
|
"github.com/tendermint/tmlibs/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDummy(t *testing.T) {
|
func TestDummy(t *testing.T) {
|
||||||
|
@ -37,19 +39,22 @@ func TestGRPC(t *testing.T) {
|
||||||
func testStream(t *testing.T, app types.Application) {
|
func testStream(t *testing.T, app types.Application) {
|
||||||
|
|
||||||
numDeliverTxs := 200000
|
numDeliverTxs := 200000
|
||||||
|
logger := log.NewTmLogger(os.Stdout)
|
||||||
|
|
||||||
// Start the listener
|
// Start the listener
|
||||||
server, err := server.NewSocketServer("unix://test.sock", app)
|
server, err := server.NewSocketServer("unix://test.sock", app)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(cmn.Fmt("Error starting socket server: %v", err.Error()))
|
stdlog.Fatal(cmn.Fmt("Error starting socket server: %v", err.Error()))
|
||||||
}
|
}
|
||||||
|
server.SetLogger(log.With(logger, "module", "abci-server"))
|
||||||
defer server.Stop()
|
defer server.Stop()
|
||||||
|
|
||||||
// Connect to the socket
|
// Connect to the socket
|
||||||
client, err := abcicli.NewSocketClient("unix://test.sock", false)
|
client, err := abcicli.NewSocketClient("unix://test.sock", false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(cmn.Fmt("Error starting socket client: %v", err.Error()))
|
stdlog.Fatal(cmn.Fmt("Error starting socket client: %v", err.Error()))
|
||||||
}
|
}
|
||||||
|
client.SetLogger(log.With(logger, "module", "abci-client"))
|
||||||
client.Start()
|
client.Start()
|
||||||
defer client.Stop()
|
defer client.Stop()
|
||||||
|
|
||||||
|
@ -110,18 +115,20 @@ func dialerFunc(addr string, timeout time.Duration) (net.Conn, error) {
|
||||||
func testGRPCSync(t *testing.T, app *types.GRPCApplication) {
|
func testGRPCSync(t *testing.T, app *types.GRPCApplication) {
|
||||||
|
|
||||||
numDeliverTxs := 2000
|
numDeliverTxs := 2000
|
||||||
|
logger := log.NewTmLogger(os.Stdout)
|
||||||
|
|
||||||
// Start the listener
|
// Start the listener
|
||||||
server, err := server.NewGRPCServer("unix://test.sock", app)
|
server, err := server.NewGRPCServer("unix://test.sock", app)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(cmn.Fmt("Error starting GRPC server: %v", err.Error()))
|
stdlog.Fatal(cmn.Fmt("Error starting GRPC server: %v", err.Error()))
|
||||||
}
|
}
|
||||||
|
server.SetLogger(log.With(logger, "module", "abci-server"))
|
||||||
defer server.Stop()
|
defer server.Stop()
|
||||||
|
|
||||||
// Connect to the socket
|
// Connect to the socket
|
||||||
conn, err := grpc.Dial("unix://test.sock", grpc.WithInsecure(), grpc.WithDialer(dialerFunc))
|
conn, err := grpc.Dial("unix://test.sock", grpc.WithInsecure(), grpc.WithDialer(dialerFunc))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(cmn.Fmt("Error dialing GRPC server: %v", err.Error()))
|
stdlog.Fatal(cmn.Fmt("Error dialing GRPC server: %v", err.Error()))
|
||||||
}
|
}
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
|
|
|
@ -1,28 +1,35 @@
|
||||||
hash: 13c7dac029851e5177bf78ff26ce6ccd047360111795a9a65af4ba6a0b87f4b3
|
hash: 3918a6fe902116fbac5ac474580edf246bee125df6e63e3bd8378f068fa8f819
|
||||||
updated: 2017-04-21T18:38:50.4243289-04:00
|
updated: 2017-05-01T08:59:45.550273823Z
|
||||||
imports:
|
imports:
|
||||||
- name: github.com/btcsuite/btcd
|
- name: github.com/btcsuite/btcd
|
||||||
version: 583684b21bfbde9b5fc4403916fd7c807feb0289
|
version: 4b348c1d33373d672edd83fc576892d0e46686d2
|
||||||
subpackages:
|
subpackages:
|
||||||
- btcec
|
- btcec
|
||||||
|
- name: github.com/go-kit/kit
|
||||||
|
version: 8a2988aa81f699fc1e647c3c9dddce0113ef1bfb
|
||||||
|
subpackages:
|
||||||
|
- log
|
||||||
|
- log/level
|
||||||
|
- log/term
|
||||||
|
- name: github.com/go-logfmt/logfmt
|
||||||
|
version: 390ab7935ee28ec6b286364bba9b4dd6410cb3d5
|
||||||
- name: github.com/go-stack/stack
|
- name: github.com/go-stack/stack
|
||||||
version: 100eb0c0a9c5b306ca2fb4f165df21d80ada4b82
|
version: 100eb0c0a9c5b306ca2fb4f165df21d80ada4b82
|
||||||
- name: github.com/golang/protobuf
|
- name: github.com/golang/protobuf
|
||||||
version: 8ee79997227bf9b34611aee7946ae64735e6fd93
|
version: 18c9bb3261723cd5401db4d0c9fbc5c3b6c70fe8
|
||||||
subpackages:
|
subpackages:
|
||||||
- proto
|
- proto
|
||||||
|
- ptypes/any
|
||||||
- name: github.com/golang/snappy
|
- name: github.com/golang/snappy
|
||||||
version: d9eb7a3d35ec988b8585d4a0068e462c27d28380
|
version: 553a641470496b2327abcac10b36396bd98e45c9
|
||||||
- name: github.com/jmhodges/levigo
|
- name: github.com/jmhodges/levigo
|
||||||
version: c42d9e0ca023e2198120196f842701bb4c55d7b9
|
version: c42d9e0ca023e2198120196f842701bb4c55d7b9
|
||||||
- name: github.com/mattn/go-colorable
|
- name: github.com/kr/logfmt
|
||||||
version: d228849504861217f796da67fae4f6e347643f15
|
version: b84e30acd515aadc4b783ad4ff83aff3299bdfe0
|
||||||
- name: github.com/mattn/go-isatty
|
|
||||||
version: 30a891c33c7cde7b02a981314b4228ec99380cca
|
|
||||||
- name: github.com/pkg/errors
|
- name: github.com/pkg/errors
|
||||||
version: 645ef00459ed84a119197bfb8d8205042c6df63d
|
version: ff09b135c25aae272398c51a07235b90a75aa4f0
|
||||||
- name: github.com/syndtr/goleveldb
|
- name: github.com/syndtr/goleveldb
|
||||||
version: 23851d93a2292dcc56e71a18ec9e0624d84a0f65
|
version: 8c81ea47d4c41a385645e133e15510fc6a2a74b4
|
||||||
subpackages:
|
subpackages:
|
||||||
- leveldb
|
- leveldb
|
||||||
- leveldb/cache
|
- leveldb/cache
|
||||||
|
@ -42,31 +49,27 @@ imports:
|
||||||
- edwards25519
|
- edwards25519
|
||||||
- extra25519
|
- extra25519
|
||||||
- name: github.com/tendermint/go-crypto
|
- name: github.com/tendermint/go-crypto
|
||||||
version: 9b95da8fa4187f6799558d89b271dc8ab6485615
|
version: 197a2b270fd94ee03824b158e738fce62862d0b8
|
||||||
- name: github.com/tendermint/go-wire
|
- name: github.com/tendermint/go-wire
|
||||||
version: 334005c236d19c632fb5f073f9de3b0fab6a522b
|
version: b53add0b622662731985485f3a19be7f684660b8
|
||||||
subpackages:
|
subpackages:
|
||||||
- data
|
- data
|
||||||
- name: github.com/tendermint/log15
|
|
||||||
version: ae0f3d6450da9eac7074b439c8e1c3cabf0d5ce6
|
|
||||||
subpackages:
|
|
||||||
- term
|
|
||||||
- name: github.com/tendermint/merkleeyes
|
- name: github.com/tendermint/merkleeyes
|
||||||
version: 6fd69aa0871a4e685a5570aa7ab3d12e4068a722
|
version: d0aa363fd4e015e509038c3a0ec493bc62ee0b8a
|
||||||
subpackages:
|
subpackages:
|
||||||
- iavl
|
- iavl
|
||||||
- name: github.com/tendermint/tmlibs
|
- name: github.com/tendermint/tmlibs
|
||||||
version: df250b69416a35a943a6e2a92118667e9ef031d4
|
version: dc50d7d3c19771377fb4aa6e703354205050053a
|
||||||
subpackages:
|
subpackages:
|
||||||
- common
|
- common
|
||||||
- db
|
- db
|
||||||
- logger
|
- log
|
||||||
- merkle
|
- merkle
|
||||||
- process
|
- process
|
||||||
- name: github.com/urfave/cli
|
- name: github.com/urfave/cli
|
||||||
version: 0bdeddeeb0f650497d603c4ad7b20cfe685682f6
|
version: ab403a54a148f2d857920810291539e1f817ee7b
|
||||||
- name: golang.org/x/crypto
|
- name: golang.org/x/crypto
|
||||||
version: 7c6cc321c680f03b9ef0764448e780704f486b51
|
version: c7af5bf2638a1164f2eb5467c39c6cffbd13a02e
|
||||||
subpackages:
|
subpackages:
|
||||||
- nacl/secretbox
|
- nacl/secretbox
|
||||||
- openpgp/armor
|
- openpgp/armor
|
||||||
|
@ -75,7 +78,7 @@ imports:
|
||||||
- ripemd160
|
- ripemd160
|
||||||
- salsa20/salsa
|
- salsa20/salsa
|
||||||
- name: golang.org/x/net
|
- name: golang.org/x/net
|
||||||
version: 61557ac0112b576429a0df080e1c2cef5dfbb642
|
version: da118f7b8e5954f39d0d2130ab35d4bf0e3cb344
|
||||||
subpackages:
|
subpackages:
|
||||||
- context
|
- context
|
||||||
- http2
|
- http2
|
||||||
|
@ -84,26 +87,36 @@ imports:
|
||||||
- internal/timeseries
|
- internal/timeseries
|
||||||
- lex/httplex
|
- lex/httplex
|
||||||
- trace
|
- trace
|
||||||
- name: golang.org/x/sys
|
- name: golang.org/x/text
|
||||||
version: d75a52659825e75fff6158388dddc6a5b04f9ba5
|
version: 470f45bf29f4147d6fbd7dfd0a02a848e49f5bf4
|
||||||
subpackages:
|
subpackages:
|
||||||
- unix
|
- secure/bidirule
|
||||||
|
- transform
|
||||||
|
- unicode/bidi
|
||||||
|
- unicode/norm
|
||||||
|
- name: google.golang.org/genproto
|
||||||
|
version: 411e09b969b1170a9f0c467558eb4c4c110d9c77
|
||||||
|
subpackages:
|
||||||
|
- googleapis/rpc/status
|
||||||
- name: google.golang.org/grpc
|
- name: google.golang.org/grpc
|
||||||
version: cbcceb2942a489498cf22b2f918536e819d33f0a
|
version: 0eb507a2ca07f13baf499f89d66cc566bf644643
|
||||||
subpackages:
|
subpackages:
|
||||||
- codes
|
- codes
|
||||||
- credentials
|
- credentials
|
||||||
|
- grpclb/grpc_lb_v1
|
||||||
- grpclog
|
- grpclog
|
||||||
- internal
|
- internal
|
||||||
|
- keepalive
|
||||||
- metadata
|
- metadata
|
||||||
- naming
|
- naming
|
||||||
- peer
|
- peer
|
||||||
- stats
|
- stats
|
||||||
|
- status
|
||||||
- tap
|
- tap
|
||||||
- transport
|
- transport
|
||||||
testImports:
|
testImports:
|
||||||
- name: github.com/davecgh/go-spew
|
- name: github.com/davecgh/go-spew
|
||||||
version: 6d212800a42e8ab5c146b8ace3490ee17e5225f9
|
version: 04cdfd42973bb9c8589fd6a731800cf222fde1a9
|
||||||
subpackages:
|
subpackages:
|
||||||
- spew
|
- spew
|
||||||
- name: github.com/pmezard/go-difflib
|
- name: github.com/pmezard/go-difflib
|
||||||
|
@ -111,7 +124,7 @@ testImports:
|
||||||
subpackages:
|
subpackages:
|
||||||
- difflib
|
- difflib
|
||||||
- name: github.com/stretchr/testify
|
- name: github.com/stretchr/testify
|
||||||
version: 69483b4bd14f5845b5a1e55bca19e954e827f1d0
|
version: 4d4bfba8f1d1027c4fdbe371823030df51419987
|
||||||
subpackages:
|
subpackages:
|
||||||
- assert
|
- assert
|
||||||
- require
|
- require
|
||||||
|
|
|
@ -3,6 +3,7 @@ import:
|
||||||
- package: github.com/golang/protobuf
|
- package: github.com/golang/protobuf
|
||||||
subpackages:
|
subpackages:
|
||||||
- proto
|
- proto
|
||||||
|
- package: github.com/pkg/errors
|
||||||
- package: github.com/tendermint/go-crypto
|
- package: github.com/tendermint/go-crypto
|
||||||
version: develop
|
version: develop
|
||||||
- package: github.com/tendermint/go-wire
|
- package: github.com/tendermint/go-wire
|
||||||
|
@ -12,11 +13,11 @@ import:
|
||||||
subpackages:
|
subpackages:
|
||||||
- iavl
|
- iavl
|
||||||
- package: github.com/tendermint/tmlibs
|
- package: github.com/tendermint/tmlibs
|
||||||
version: develop
|
version: feature/new-logging
|
||||||
subpackages:
|
subpackages:
|
||||||
- common
|
- common
|
||||||
- db
|
- db
|
||||||
- logger
|
- log
|
||||||
- merkle
|
- merkle
|
||||||
- process
|
- process
|
||||||
- package: github.com/urfave/cli
|
- package: github.com/urfave/cli
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
package server
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/tendermint/tmlibs/logger"
|
|
||||||
)
|
|
||||||
|
|
||||||
var log = logger.New("module", "abci-server")
|
|
|
@ -94,15 +94,15 @@ func (s *SocketServer) acceptConnectionsRoutine() {
|
||||||
// semaphore <- struct{}{}
|
// semaphore <- struct{}{}
|
||||||
|
|
||||||
// Accept a connection
|
// Accept a connection
|
||||||
log.Notice("Waiting for new connection...")
|
s.Logger.Info("Waiting for new connection...")
|
||||||
conn, err := s.listener.Accept()
|
conn, err := s.listener.Accept()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !s.IsRunning() {
|
if !s.IsRunning() {
|
||||||
return // Ignore error from listener closing.
|
return // Ignore error from listener closing.
|
||||||
}
|
}
|
||||||
log.Crit("Failed to accept connection: " + err.Error())
|
s.Logger.Error("Failed to accept connection: " + err.Error())
|
||||||
} else {
|
} else {
|
||||||
log.Notice("Accepted a new connection")
|
s.Logger.Info("Accepted a new connection")
|
||||||
}
|
}
|
||||||
|
|
||||||
connID := s.addConn(conn)
|
connID := s.addConn(conn)
|
||||||
|
@ -119,18 +119,18 @@ func (s *SocketServer) acceptConnectionsRoutine() {
|
||||||
// Wait until signal to close connection
|
// Wait until signal to close connection
|
||||||
errClose := <-closeConn
|
errClose := <-closeConn
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
log.Warn("Connection was closed by client")
|
s.Logger.Error("Connection was closed by client")
|
||||||
} else if errClose != nil {
|
} else if errClose != nil {
|
||||||
log.Warn("Connection error", "error", errClose)
|
s.Logger.Error("Connection error", "error", errClose)
|
||||||
} else {
|
} else {
|
||||||
// never happens
|
// never happens
|
||||||
log.Warn("Connection was closed.")
|
s.Logger.Error("Connection was closed.")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close the connection
|
// Close the connection
|
||||||
err := s.rmConn(connID, conn)
|
err := s.rmConn(connID, conn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn("Error in closing connection", "error", err)
|
s.Logger.Error("Error in closing connection", "error", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// <-semaphore
|
// <-semaphore
|
||||||
|
|
|
@ -6,8 +6,9 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/tendermint/abci/client"
|
abcicli "github.com/tendermint/abci/client"
|
||||||
"github.com/tendermint/abci/types"
|
"github.com/tendermint/abci/types"
|
||||||
|
"github.com/tendermint/tmlibs/log"
|
||||||
"github.com/tendermint/tmlibs/process"
|
"github.com/tendermint/tmlibs/process"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -37,6 +38,8 @@ func startClient(abciType string) abcicli.Client {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("connecting to abci_app: " + err.Error())
|
panic("connecting to abci_app: " + err.Error())
|
||||||
}
|
}
|
||||||
|
logger := log.NewTmLogger(os.Stdout)
|
||||||
|
client.SetLogger(log.With(logger, "module", "abcicli"))
|
||||||
return client
|
return client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue