libs/common: Refactor libs/common 5 (#4240)

* libs/common: Refactor libs/common 5

- move mathematical functions and types out of `libs/common` to math pkg
- move net functions out of `libs/common` to net pkg
- move string functions out of `libs/common` to strings pkg
- move async functions out of `libs/common` to async pkg
- move bit functions out of `libs/common` to bits pkg
- move cmap functions out of `libs/common` to cmap pkg
- move os functions out of `libs/common` to os pkg

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>

* fix testing issues

* fix tests

closes #41417

woooooooooooooooooo kill the cmn pkg

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>

* add changelog entry

* fix goimport issues

* run gofmt
This commit is contained in:
Marko
2019-12-12 09:33:27 +01:00
committed by GitHub
parent 7e02211246
commit 7b52f51700
83 changed files with 293 additions and 471 deletions

View File

@@ -10,7 +10,7 @@ import (
"google.golang.org/grpc"
"github.com/tendermint/tendermint/abci/types"
cmn "github.com/tendermint/tendermint/libs/common"
tmnet "github.com/tendermint/tendermint/libs/net"
"github.com/tendermint/tendermint/libs/service"
)
@@ -41,7 +41,7 @@ func NewGRPCClient(addr string, mustConnect bool) *grpcClient {
}
func dialerFunc(ctx context.Context, addr string) (net.Conn, error) {
return cmn.Connect(addr)
return tmnet.Connect(addr)
}
func (cli *grpcClient) OnStart() error {

View File

@@ -12,7 +12,7 @@ import (
"time"
"github.com/tendermint/tendermint/abci/types"
cmn "github.com/tendermint/tendermint/libs/common"
tmnet "github.com/tendermint/tendermint/libs/net"
"github.com/tendermint/tendermint/libs/service"
"github.com/tendermint/tendermint/libs/timer"
)
@@ -62,7 +62,7 @@ func (cli *socketClient) OnStart() error {
var conn net.Conn
RETRY_LOOP:
for {
conn, err = cmn.Connect(cli.addr)
conn, err = tmnet.Connect(cli.addr)
if err != nil {
if cli.mustConnect {
return err

View File

@@ -11,8 +11,8 @@ import (
"github.com/spf13/cobra"
cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/libs/log"
tmos "github.com/tendermint/tendermint/libs/os"
abcicli "github.com/tendermint/tendermint/abci/client"
"github.com/tendermint/tendermint/abci/example/code"
@@ -640,7 +640,7 @@ func cmdCounter(cmd *cobra.Command, args []string) error {
}
// Stop upon receiving SIGTERM or CTRL-C.
cmn.TrapSignal(logger, func() {
tmos.TrapSignal(logger, func() {
// Cleanup
srv.Stop()
})
@@ -672,7 +672,7 @@ func cmdKVStore(cmd *cobra.Command, args []string) error {
}
// Stop upon receiving SIGTERM or CTRL-C.
cmn.TrapSignal(logger, func() {
tmos.TrapSignal(logger, func() {
// Cleanup
srv.Stop()
})

View File

@@ -13,8 +13,8 @@ import (
"golang.org/x/net/context"
cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/libs/log"
tmnet "github.com/tendermint/tendermint/libs/net"
abcicli "github.com/tendermint/tendermint/abci/client"
"github.com/tendermint/tendermint/abci/example/code"
@@ -108,7 +108,7 @@ func testStream(t *testing.T, app types.Application) {
// test grpc
func dialerFunc(ctx context.Context, addr string) (net.Conn, error) {
return cmn.Connect(addr)
return tmnet.Connect(addr)
}
func testGRPCSync(t *testing.T, app types.ABCIApplicationServer) {

View File

@@ -6,7 +6,7 @@ import (
"google.golang.org/grpc"
"github.com/tendermint/tendermint/abci/types"
cmn "github.com/tendermint/tendermint/libs/common"
tmnet "github.com/tendermint/tendermint/libs/net"
"github.com/tendermint/tendermint/libs/service"
)
@@ -23,7 +23,7 @@ type GRPCServer struct {
// NewGRPCServer returns a new gRPC ABCI server
func NewGRPCServer(protoAddr string, app types.ABCIApplicationServer) service.Service {
proto, addr := cmn.ProtocolAndAddress(protoAddr)
proto, addr := tmnet.ProtocolAndAddress(protoAddr)
s := &GRPCServer{
proto: proto,
addr: addr,

View File

@@ -8,7 +8,7 @@ import (
"sync"
"github.com/tendermint/tendermint/abci/types"
cmn "github.com/tendermint/tendermint/libs/common"
tmnet "github.com/tendermint/tendermint/libs/net"
"github.com/tendermint/tendermint/libs/service"
)
@@ -30,7 +30,7 @@ type SocketServer struct {
}
func NewSocketServer(protoAddr string, app types.Application) service.Service {
proto, addr := cmn.ProtocolAndAddress(protoAddr)
proto, addr := tmnet.ProtocolAndAddress(protoAddr)
s := &SocketServer{
proto: proto,
addr: addr,

View File

@@ -6,12 +6,12 @@ import (
"log"
"github.com/tendermint/tendermint/abci/types"
cmn "github.com/tendermint/tendermint/libs/common"
tmnet "github.com/tendermint/tendermint/libs/net"
)
func main() {
conn, err := cmn.Connect("unix://test.sock")
conn, err := tmnet.Connect("unix://test.sock")
if err != nil {
log.Fatal(err.Error())
}

View File

@@ -8,12 +8,12 @@ import (
"reflect"
"github.com/tendermint/tendermint/abci/types"
cmn "github.com/tendermint/tendermint/libs/common"
tmnet "github.com/tendermint/tendermint/libs/net"
)
func main() {
conn, err := cmn.Connect("unix://test.sock")
conn, err := tmnet.Connect("unix://test.sock")
if err != nil {
log.Fatal(err.Error())
}