Skip to content

Commit

Permalink
Renamed 'skymsg' to 'dms'.
Browse files Browse the repository at this point in the history
  • Loading branch information
林志宇 committed May 30, 2019
1 parent b34f98b commit 39c9dfd
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 33 deletions.
4 changes: 2 additions & 2 deletions cmd/messaging-server/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package commands
import (
"bufio"
"encoding/json"
"github.com/skycoin/skywire/pkg/skymsg"
"github.com/skycoin/skywire/pkg/dms"
"io"
"log"
"log/syslog"
Expand Down Expand Up @@ -71,7 +71,7 @@ var rootCmd = &cobra.Command{
}()

// Start
srv := skymsg.NewServer(conf.PubKey, conf.SecKey, conf.PublicAddress, client.NewHTTP(conf.Discovery))
srv := dms.NewServer(conf.PubKey, conf.SecKey, conf.PublicAddress, client.NewHTTP(conf.Discovery))
log.Fatal(srv.ListenAndServe(conf.LocalAddress))
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/skywire-cli/commands/node/transports.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ var (
)

func init() {
addTpCmd.Flags().StringVar(&transportType, "type", "skymsg", "type of transport to add")
addTpCmd.Flags().StringVar(&transportType, "type", "dms", "type of transport to add")
addTpCmd.Flags().BoolVar(&public, "public", true, "whether to make the transport public")
addTpCmd.Flags().DurationVarP(&timeout, "timeout", "t", 0, "if specified, sets an operation timeout")
}
Expand Down
9 changes: 2 additions & 7 deletions pkg/skymsg/channel.go → pkg/dms/channel.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package skymsg
package dms

import (
"bytes"
Expand Down Expand Up @@ -124,10 +124,6 @@ func (c *Channel) Read(p []byte) (n int, err error) {
switch f.Type() {
case FwdType:
return c.bufRead(f.Pay(), p)
//if len(p) >= f.PayLen() {
// return copy(p, f.Pay()), nil
//}
//return 0, io.ErrShortBuffer
case CloseType:
c.close()
return 0, io.ErrClosedPipe
Expand Down Expand Up @@ -164,7 +160,6 @@ func (c *Channel) Write(p []byte) (int, error) {
func (c *Channel) Close() error {
if c.close() {
_ = writeFrame(c.Conn, MakeFrame(CloseType, c.id, []byte{0}))
return nil
}
return io.ErrClosedPipe
return nil
}
1 change: 1 addition & 0 deletions pkg/dms/channel_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package dms
8 changes: 4 additions & 4 deletions pkg/skymsg/client.go → pkg/dms/client.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package skymsg
package dms

import (
"context"
Expand Down Expand Up @@ -33,11 +33,11 @@ var (
// Link from a client's perspective.
type Link struct {
log *logging.Logger
net.Conn // conn to skymsg server
net.Conn // conn to dms server
local cipher.PubKey // local client's pk
remoteSrv cipher.PubKey // skymsg server's public key
remoteSrv cipher.PubKey // dms server's public key
nextID uint16 // next unused channel ID
chans [math.MaxUint16]*Channel // channels to skymsg clients
chans [math.MaxUint16]*Channel // channels to dms clients
mx sync.RWMutex
wg sync.WaitGroup
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/skymsg/frame.go → pkg/dms/frame.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package skymsg
package dms

import (
"encoding/binary"
Expand All @@ -9,7 +9,7 @@ import (
)

const (
TpType = "skymsg"
TpType = "dms"

hsTimeout = time.Second * 10
readBufLen = 10
Expand Down
1 change: 1 addition & 0 deletions pkg/dms/frame_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package dms
2 changes: 1 addition & 1 deletion pkg/skymsg/server.go → pkg/dms/server.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package skymsg
package dms

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion pkg/skymsg/server_test.go → pkg/dms/server_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package skymsg
package dms

import (
"context"
Expand Down
8 changes: 4 additions & 4 deletions pkg/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"context"
"errors"
"fmt"
"github.com/skycoin/skywire/pkg/skymsg"
"github.com/skycoin/skywire/pkg/dms"
"io"
"net"
"net/rpc"
Expand Down Expand Up @@ -79,7 +79,7 @@ type PacketRouter interface {
type Node struct {
config *Config
router PacketRouter
messenger *skymsg.Client
messenger *dms.Client
tm *transport.Manager
rt routing.Table
executer appExecuter
Expand Down Expand Up @@ -116,7 +116,7 @@ func NewNode(config *Config) (*Node, error) {
return nil, fmt.Errorf("invalid Messaging config: %s", err)
}

node.messenger = skymsg.NewClient(mConfig.PubKey, mConfig.SecKey, mConfig.Discovery)
node.messenger = dms.NewClient(mConfig.PubKey, mConfig.SecKey, mConfig.Discovery)
node.messenger.SetLogger(node.Logger.PackageLogger("dms"))

trDiscovery, err := config.TransportDiscovery()
Expand Down Expand Up @@ -199,7 +199,7 @@ func (node *Node) Start() error {
ctx := context.Background()
err := node.messenger.InitiateLinks(ctx, node.config.Messaging.ServerCount)
if err != nil {
return fmt.Errorf("skymsg: %s", err)
return fmt.Errorf("dms: %s", err)
}
node.logger.Info("Connected to messaging servers")

Expand Down
4 changes: 2 additions & 2 deletions pkg/node/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"encoding/json"
"errors"
"github.com/skycoin/skywire/pkg/skymsg"
"github.com/skycoin/skywire/pkg/dms"
"net"
"os"
"os/exec"
Expand Down Expand Up @@ -75,7 +75,7 @@ func TestNodeStartClose(t *testing.T) {
node := &Node{config: &Config{}, router: r, executer: executer, appsConf: conf,
startedApps: map[string]*appBind{}, logger: logging.MustGetLogger("test")}
mConf := &messaging.Config{PubKey: cipher.PubKey{}, SecKey: cipher.SecKey{}, Discovery: client.NewMock()}
node.messenger = skymsg.NewClient(mConf.PubKey, mConf.SecKey, mConf.Discovery)
node.messenger = dms.NewClient(mConf.PubKey, mConf.SecKey, mConf.Discovery)
var err error

tmConf := &transport.ManagerConfig{PubKey: cipher.PubKey{}, DiscoveryClient: transport.NewDiscoveryMock()}
Expand Down
2 changes: 1 addition & 1 deletion pkg/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ func (r *Router) setupProto(ctx context.Context) (*setup.Protocol, transport.Tra
}

// TODO(evanlinjin): need string constant for tp type.
tr, err := r.tm.CreateTransport(ctx, r.config.SetupNodes[0], "skymsg", false)
tr, err := r.tm.CreateTransport(ctx, r.config.SetupNodes[0], "dms", false)
if err != nil {
return nil, nil, fmt.Errorf("transport: %s", err)
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/setup/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/skycoin/skywire/pkg/skymsg"
"github.com/skycoin/skywire/pkg/dms"
"log"
"time"

Expand All @@ -31,7 +31,7 @@ type Node struct {
Logger *logging.Logger

tm *transport.Manager
messenger *skymsg.Client
messenger *dms.Client
srvCount int
metrics metrics.Recorder
}
Expand All @@ -45,7 +45,7 @@ func NewNode(conf *Config, metrics metrics.Recorder) (*Node, error) {
if lvl, err := logging.LevelFromString(conf.LogLevel); err == nil {
logger.SetLevel(lvl)
}
messenger := skymsg.NewClient(pk, sk, mClient.NewHTTP(conf.Messaging.Discovery))
messenger := dms.NewClient(pk, sk, mClient.NewHTTP(conf.Messaging.Discovery))
messenger.SetLogger(logger.PackageLogger("messenger"))

trDiscovery, err := trClient.NewHTTP(conf.TransportDiscovery, pk, sk)
Expand Down Expand Up @@ -227,7 +227,7 @@ func (sn *Node) serveTransport(tr transport.Transport) error {
}

func (sn *Node) connectLoop(on cipher.PubKey, ld *LoopData) (noiseRes []byte, err error) {
tr, err := sn.tm.CreateTransport(context.Background(), on, skymsg.TpType, false)
tr, err := sn.tm.CreateTransport(context.Background(), on, dms.TpType, false)
if err != nil {
err = fmt.Errorf("transport: %s", err)
return
Expand All @@ -245,7 +245,7 @@ func (sn *Node) connectLoop(on cipher.PubKey, ld *LoopData) (noiseRes []byte, er
}

func (sn *Node) closeLoop(on cipher.PubKey, ld *LoopData) error {
tr, err := sn.tm.CreateTransport(context.Background(), on, skymsg.TpType, false)
tr, err := sn.tm.CreateTransport(context.Background(), on, dms.TpType, false)
if err != nil {
return fmt.Errorf("transport: %s", err)
}
Expand All @@ -261,7 +261,7 @@ func (sn *Node) closeLoop(on cipher.PubKey, ld *LoopData) error {
}

func (sn *Node) setupRule(pubKey cipher.PubKey, rule routing.Rule) (routeID routing.RouteID, err error) {
tr, err := sn.tm.CreateTransport(context.Background(), pubKey, skymsg.TpType, false)
tr, err := sn.tm.CreateTransport(context.Background(), pubKey, dms.TpType, false)
if err != nil {
err = fmt.Errorf("transport: %s", err)
return
Expand Down
1 change: 0 additions & 1 deletion pkg/skymsg/channel_test.go

This file was deleted.

1 change: 0 additions & 1 deletion pkg/skymsg/frame_test.go

This file was deleted.

0 comments on commit 39c9dfd

Please sign in to comment.