mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-26 15:22:15 +00:00
common -> cmn
This commit is contained in:
parent
a33b75fe8b
commit
9745f07bee
@ -5,11 +5,11 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/tendermint/abci/types"
|
"github.com/tendermint/abci/types"
|
||||||
common "github.com/tendermint/go-common"
|
cmn "github.com/tendermint/go-common"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Client interface {
|
type Client interface {
|
||||||
common.Service
|
cmn.Service
|
||||||
|
|
||||||
SetResponseCallback(Callback)
|
SetResponseCallback(Callback)
|
||||||
Error() error
|
Error() error
|
||||||
|
@ -10,13 +10,13 @@ import (
|
|||||||
grpc "google.golang.org/grpc"
|
grpc "google.golang.org/grpc"
|
||||||
|
|
||||||
"github.com/tendermint/abci/types"
|
"github.com/tendermint/abci/types"
|
||||||
common "github.com/tendermint/go-common"
|
cmn "github.com/tendermint/go-common"
|
||||||
)
|
)
|
||||||
|
|
||||||
// A stripped copy of the remoteClient that makes
|
// A stripped copy of the remoteClient that makes
|
||||||
// synchronous calls using grpc
|
// synchronous calls using grpc
|
||||||
type grpcClient struct {
|
type grpcClient struct {
|
||||||
common.BaseService
|
cmn.BaseService
|
||||||
mustConnect bool
|
mustConnect bool
|
||||||
|
|
||||||
client types.ABCIApplicationClient
|
client types.ABCIApplicationClient
|
||||||
@ -32,13 +32,13 @@ func NewGRPCClient(addr string, mustConnect bool) (*grpcClient, error) {
|
|||||||
addr: addr,
|
addr: addr,
|
||||||
mustConnect: mustConnect,
|
mustConnect: mustConnect,
|
||||||
}
|
}
|
||||||
cli.BaseService = *common.NewBaseService(nil, "grpcClient", cli)
|
cli.BaseService = *cmn.NewBaseService(nil, "grpcClient", cli)
|
||||||
_, err := cli.Start() // Just start it, it's confusing for callers to remember to start.
|
_, err := cli.Start() // Just start it, it's confusing for callers to remember to start.
|
||||||
return cli, err
|
return cli, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func dialerFunc(addr string, timeout time.Duration) (net.Conn, error) {
|
func dialerFunc(addr string, timeout time.Duration) (net.Conn, error) {
|
||||||
return common.Connect(addr)
|
return cmn.Connect(addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *grpcClient) OnStart() error {
|
func (cli *grpcClient) OnStart() error {
|
||||||
|
@ -4,11 +4,11 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
types "github.com/tendermint/abci/types"
|
types "github.com/tendermint/abci/types"
|
||||||
common "github.com/tendermint/go-common"
|
cmn "github.com/tendermint/go-common"
|
||||||
)
|
)
|
||||||
|
|
||||||
type localClient struct {
|
type localClient struct {
|
||||||
common.BaseService
|
cmn.BaseService
|
||||||
mtx *sync.Mutex
|
mtx *sync.Mutex
|
||||||
types.Application
|
types.Application
|
||||||
Callback
|
Callback
|
||||||
@ -22,7 +22,7 @@ func NewLocalClient(mtx *sync.Mutex, app types.Application) *localClient {
|
|||||||
mtx: mtx,
|
mtx: mtx,
|
||||||
Application: app,
|
Application: app,
|
||||||
}
|
}
|
||||||
cli.BaseService = *common.NewBaseService(log, "localClient", cli)
|
cli.BaseService = *cmn.NewBaseService(log, "localClient", cli)
|
||||||
return cli
|
return cli
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/tendermint/abci/types"
|
"github.com/tendermint/abci/types"
|
||||||
common "github.com/tendermint/go-common"
|
cmn "github.com/tendermint/go-common"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -27,10 +27,10 @@ const flushThrottleMS = 20 // Don't wait longer than...
|
|||||||
// the application in general is not meant to be interfaced
|
// the application in general is not meant to be interfaced
|
||||||
// with concurrent callers.
|
// with concurrent callers.
|
||||||
type socketClient struct {
|
type socketClient struct {
|
||||||
common.BaseService
|
cmn.BaseService
|
||||||
|
|
||||||
reqQueue chan *ReqRes
|
reqQueue chan *ReqRes
|
||||||
flushTimer *common.ThrottleTimer
|
flushTimer *cmn.ThrottleTimer
|
||||||
mustConnect bool
|
mustConnect bool
|
||||||
|
|
||||||
mtx sync.Mutex
|
mtx sync.Mutex
|
||||||
@ -45,14 +45,14 @@ type socketClient struct {
|
|||||||
func NewSocketClient(addr string, mustConnect bool) (*socketClient, error) {
|
func NewSocketClient(addr string, mustConnect bool) (*socketClient, error) {
|
||||||
cli := &socketClient{
|
cli := &socketClient{
|
||||||
reqQueue: make(chan *ReqRes, reqQueueSize),
|
reqQueue: make(chan *ReqRes, reqQueueSize),
|
||||||
flushTimer: common.NewThrottleTimer("socketClient", flushThrottleMS),
|
flushTimer: cmn.NewThrottleTimer("socketClient", flushThrottleMS),
|
||||||
mustConnect: mustConnect,
|
mustConnect: mustConnect,
|
||||||
|
|
||||||
addr: addr,
|
addr: addr,
|
||||||
reqSent: list.New(),
|
reqSent: list.New(),
|
||||||
resCb: nil,
|
resCb: nil,
|
||||||
}
|
}
|
||||||
cli.BaseService = *common.NewBaseService(nil, "socketClient", cli)
|
cli.BaseService = *cmn.NewBaseService(nil, "socketClient", cli)
|
||||||
|
|
||||||
_, err := cli.Start() // Just start it, it's confusing for callers to remember to start.
|
_, err := cli.Start() // Just start it, it's confusing for callers to remember to start.
|
||||||
return cli, err
|
return cli, err
|
||||||
@ -65,7 +65,7 @@ func (cli *socketClient) OnStart() error {
|
|||||||
var conn net.Conn
|
var conn net.Conn
|
||||||
RETRY_LOOP:
|
RETRY_LOOP:
|
||||||
for {
|
for {
|
||||||
conn, err = common.Connect(cli.addr)
|
conn, err = cmn.Connect(cli.addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if cli.mustConnect {
|
if cli.mustConnect {
|
||||||
return err
|
return err
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
|
|
||||||
"github.com/tendermint/abci/example/counter"
|
"github.com/tendermint/abci/example/counter"
|
||||||
"github.com/tendermint/abci/server"
|
"github.com/tendermint/abci/server"
|
||||||
common "github.com/tendermint/go-common"
|
cmn "github.com/tendermint/go-common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -24,7 +24,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Wait forever
|
// Wait forever
|
||||||
common.TrapSignal(func() {
|
cmn.TrapSignal(func() {
|
||||||
// Cleanup
|
// Cleanup
|
||||||
srv.Stop()
|
srv.Stop()
|
||||||
})
|
})
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
"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"
|
||||||
common "github.com/tendermint/go-common"
|
cmn "github.com/tendermint/go-common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -32,7 +32,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Wait forever
|
// Wait forever
|
||||||
common.TrapSignal(func() {
|
cmn.TrapSignal(func() {
|
||||||
// Cleanup
|
// Cleanup
|
||||||
srv.Stop()
|
srv.Stop()
|
||||||
})
|
})
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
|
|
||||||
"github.com/tendermint/abci/server"
|
"github.com/tendermint/abci/server"
|
||||||
"github.com/tendermint/abci/types"
|
"github.com/tendermint/abci/types"
|
||||||
common "github.com/tendermint/go-common"
|
cmn "github.com/tendermint/go-common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -23,7 +23,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Wait forever
|
// Wait forever
|
||||||
common.TrapSignal(func() {
|
cmn.TrapSignal(func() {
|
||||||
// Cleanup
|
// Cleanup
|
||||||
srv.Stop()
|
srv.Stop()
|
||||||
})
|
})
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/tendermint/abci/types"
|
"github.com/tendermint/abci/types"
|
||||||
common "github.com/tendermint/go-common"
|
cmn "github.com/tendermint/go-common"
|
||||||
"github.com/tendermint/go-crypto"
|
"github.com/tendermint/go-crypto"
|
||||||
"github.com/tendermint/go-wire"
|
"github.com/tendermint/go-wire"
|
||||||
)
|
)
|
||||||
@ -109,7 +109,7 @@ func TestValSetChanges(t *testing.T) {
|
|||||||
vals := make([]*types.Validator, total)
|
vals := make([]*types.Validator, total)
|
||||||
for i := 0; i < total; i++ {
|
for i := 0; i < total; i++ {
|
||||||
pubkey := crypto.GenPrivKeyEd25519FromSecret([]byte(fmt.Sprintf("test%d", i))).PubKey().Bytes()
|
pubkey := crypto.GenPrivKeyEd25519FromSecret([]byte(fmt.Sprintf("test%d", i))).PubKey().Bytes()
|
||||||
power := common.RandInt()
|
power := cmn.RandInt()
|
||||||
vals[i] = &types.Validator{pubkey, uint64(power)}
|
vals[i] = &types.Validator{pubkey, uint64(power)}
|
||||||
}
|
}
|
||||||
// iniitalize with the first nInit
|
// iniitalize with the first nInit
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/tendermint/abci/types"
|
"github.com/tendermint/abci/types"
|
||||||
common "github.com/tendermint/go-common"
|
cmn "github.com/tendermint/go-common"
|
||||||
dbm "github.com/tendermint/go-db"
|
dbm "github.com/tendermint/go-db"
|
||||||
"github.com/tendermint/go-merkle"
|
"github.com/tendermint/go-merkle"
|
||||||
"github.com/tendermint/go-wire"
|
"github.com/tendermint/go-wire"
|
||||||
@ -150,7 +150,7 @@ func SaveLastBlock(db dbm.DB, lastBlock LastBlockInfo) {
|
|||||||
wire.WriteBinary(lastBlock, buf, n, err)
|
wire.WriteBinary(lastBlock, buf, n, err)
|
||||||
if *err != nil {
|
if *err != nil {
|
||||||
// TODO
|
// TODO
|
||||||
common.PanicCrisis(*err)
|
cmn.PanicCrisis(*err)
|
||||||
}
|
}
|
||||||
db.Set(lastBlockKey, buf.Bytes())
|
db.Set(lastBlockKey, buf.Bytes())
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ import (
|
|||||||
nilapp "github.com/tendermint/abci/example/nil"
|
nilapp "github.com/tendermint/abci/example/nil"
|
||||||
"github.com/tendermint/abci/server"
|
"github.com/tendermint/abci/server"
|
||||||
"github.com/tendermint/abci/types"
|
"github.com/tendermint/abci/types"
|
||||||
common "github.com/tendermint/go-common"
|
cmn "github.com/tendermint/go-common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDummy(t *testing.T) {
|
func TestDummy(t *testing.T) {
|
||||||
@ -105,7 +105,7 @@ func testStream(t *testing.T, app types.Application) {
|
|||||||
// test grpc
|
// test grpc
|
||||||
|
|
||||||
func dialerFunc(addr string, timeout time.Duration) (net.Conn, error) {
|
func dialerFunc(addr string, timeout time.Duration) (net.Conn, error) {
|
||||||
return common.Connect(addr)
|
return cmn.Connect(addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testGRPCSync(t *testing.T, app *types.GRPCApplication) {
|
func testGRPCSync(t *testing.T, app *types.GRPCApplication) {
|
||||||
|
@ -7,13 +7,13 @@ import (
|
|||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
|
||||||
"github.com/tendermint/abci/types"
|
"github.com/tendermint/abci/types"
|
||||||
common "github.com/tendermint/go-common"
|
cmn "github.com/tendermint/go-common"
|
||||||
)
|
)
|
||||||
|
|
||||||
// var maxNumberConnections = 2
|
// var maxNumberConnections = 2
|
||||||
|
|
||||||
type GRPCServer struct {
|
type GRPCServer struct {
|
||||||
common.BaseService
|
cmn.BaseService
|
||||||
|
|
||||||
proto string
|
proto string
|
||||||
addr string
|
addr string
|
||||||
@ -23,7 +23,7 @@ type GRPCServer struct {
|
|||||||
app types.ABCIApplicationServer
|
app types.ABCIApplicationServer
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGRPCServer(protoAddr string, app types.ABCIApplicationServer) (common.Service, error) {
|
func NewGRPCServer(protoAddr string, app types.ABCIApplicationServer) (cmn.Service, error) {
|
||||||
parts := strings.SplitN(protoAddr, "://", 2)
|
parts := strings.SplitN(protoAddr, "://", 2)
|
||||||
proto, addr := parts[0], parts[1]
|
proto, addr := parts[0], parts[1]
|
||||||
s := &GRPCServer{
|
s := &GRPCServer{
|
||||||
@ -32,7 +32,7 @@ func NewGRPCServer(protoAddr string, app types.ABCIApplicationServer) (common.Se
|
|||||||
listener: nil,
|
listener: nil,
|
||||||
app: app,
|
app: app,
|
||||||
}
|
}
|
||||||
s.BaseService = *common.NewBaseService(nil, "ABCIServer", s)
|
s.BaseService = *cmn.NewBaseService(nil, "ABCIServer", s)
|
||||||
_, err := s.Start() // Just start it
|
_, err := s.Start() // Just start it
|
||||||
return s, err
|
return s, err
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,11 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/tendermint/abci/types"
|
"github.com/tendermint/abci/types"
|
||||||
common "github.com/tendermint/go-common"
|
cmn "github.com/tendermint/go-common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewServer(protoAddr, transport string, app types.Application) (common.Service, error) {
|
func NewServer(protoAddr, transport string, app types.Application) (cmn.Service, error) {
|
||||||
var s common.Service
|
var s cmn.Service
|
||||||
var err error
|
var err error
|
||||||
switch transport {
|
switch transport {
|
||||||
case "socket":
|
case "socket":
|
||||||
|
@ -9,13 +9,13 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/tendermint/abci/types"
|
"github.com/tendermint/abci/types"
|
||||||
common "github.com/tendermint/go-common"
|
cmn "github.com/tendermint/go-common"
|
||||||
)
|
)
|
||||||
|
|
||||||
// var maxNumberConnections = 2
|
// var maxNumberConnections = 2
|
||||||
|
|
||||||
type SocketServer struct {
|
type SocketServer struct {
|
||||||
common.BaseService
|
cmn.BaseService
|
||||||
|
|
||||||
proto string
|
proto string
|
||||||
addr string
|
addr string
|
||||||
@ -29,7 +29,7 @@ type SocketServer struct {
|
|||||||
app types.Application
|
app types.Application
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSocketServer(protoAddr string, app types.Application) (common.Service, error) {
|
func NewSocketServer(protoAddr string, app types.Application) (cmn.Service, error) {
|
||||||
parts := strings.SplitN(protoAddr, "://", 2)
|
parts := strings.SplitN(protoAddr, "://", 2)
|
||||||
proto, addr := parts[0], parts[1]
|
proto, addr := parts[0], parts[1]
|
||||||
s := &SocketServer{
|
s := &SocketServer{
|
||||||
@ -39,7 +39,7 @@ func NewSocketServer(protoAddr string, app types.Application) (common.Service, e
|
|||||||
app: app,
|
app: app,
|
||||||
conns: make(map[int]net.Conn),
|
conns: make(map[int]net.Conn),
|
||||||
}
|
}
|
||||||
s.BaseService = *common.NewBaseService(nil, "ABCIServer", s)
|
s.BaseService = *cmn.NewBaseService(nil, "ABCIServer", s)
|
||||||
_, err := s.Start() // Just start it
|
_, err := s.Start() // Just start it
|
||||||
return s, err
|
return s, err
|
||||||
}
|
}
|
||||||
|
@ -6,12 +6,12 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/tendermint/abci/types"
|
"github.com/tendermint/abci/types"
|
||||||
common "github.com/tendermint/go-common"
|
cmn "github.com/tendermint/go-common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
conn, err := common.Connect("unix://test.sock")
|
conn, err := cmn.Connect("unix://test.sock")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err.Error())
|
log.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
|
@ -8,12 +8,12 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"github.com/tendermint/abci/types"
|
"github.com/tendermint/abci/types"
|
||||||
common "github.com/tendermint/go-common"
|
cmn "github.com/tendermint/go-common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
conn, err := common.Connect("unix://test.sock")
|
conn, err := cmn.Connect("unix://test.sock")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err.Error())
|
log.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user