Commit 6b6391c2 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent bd109559
// Copyright (C) 2017 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
// Copyright (C) 2017-2018 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
......@@ -40,9 +40,9 @@ func MsgType(msgCode uint16) reflect.Type {
}
// XXX or better translate to some other errors ?
// XXX here - not in proto.go - because else stringer will be confused
func (e *Error) Error() string {
// NOTE here, not in proto.go - because else stringer will be confused.
// XXX better translate to some other errors?
s := e.Code.String()
if e.Message != "" {
s += ": " + e.Message
......@@ -52,6 +52,7 @@ func (e *Error) Error() string {
// Set sets cluster state value to v.
//
// Use Set instead of direct assignment for ClusterState tracing to work.
//
// XXX move this to neo.clusterState wrapping proto.ClusterState?
......@@ -60,10 +61,11 @@ func (cs *ClusterState) Set(v ClusterState) {
traceClusterStateChanged(cs)
}
//const nodeTypeChar = "MSCA????" // keep in sync with NodeType constants
const nodeTypeChar = "SMCA" // XXX neo/py does this out of sync with NodeType constants
// node type -> character representing it.
const nodeTypeChar = "SMCA" // NOTE neo/py does this out of sync with NodeType constants.
// String returns string representation of a node uuid.
//
// It returns ex 'S1', 'M2', ...
func (nodeUUID NodeUUID) String() string {
if nodeUUID == 0 {
......@@ -133,6 +135,7 @@ func UUID(typ NodeType, num int32) NodeUUID {
// ----------------------------------------
// IdTimeNone represents None passed as identification time.
var IdTimeNone = IdTime(math.Inf(-1))
func (t IdTime) String() string {
......@@ -147,7 +150,7 @@ func (t IdTime) String() string {
// ----------------------------------------
// Addr converts network address string into NEO Address
// AddrString converts network address string into NEO Address.
//
// TODO make neo.Address just string without host:port split
func AddrString(network, addr string) (Address, error) {
......@@ -181,12 +184,12 @@ func AddrString(network, addr string) (Address, error) {
return Address{Host: host, Port: uint16(port)}, nil
}
// Addr converts net.Addr into NEO Address
// Addr converts net.Addr into NEO Address.
func Addr(addr net.Addr) (Address, error) {
return AddrString(addr.Network(), addr.String())
}
// String formats Address to networked address string
// String formats Address to networked address string.
func (addr Address) String() string {
// XXX in py if .Host == "" -> whole Address is assumed to be empty
......
......@@ -191,7 +191,7 @@ const (
type NodeType int32
const (
MASTER NodeType = iota
MASTER NodeType = iota
STORAGE
CLIENT
ADMIN
......
......@@ -275,7 +275,7 @@ func TestMsgMarshal(t *testing.T) {
}
}
// For all message types: same as testMsgMarshal but zero-values only
// For all message types: same as testMsgMarshal but zero-values only.
// this way we additionally lightly check encode / decode overflow behaviour for all types.
func TestMsgMarshalAllOverflowLightly(t *testing.T) {
for _, typ := range msgTypeRegistry {
......
......@@ -29,7 +29,7 @@ import (
"github.com/kylelemons/godebug/pretty"
)
// verify that message codes are the same in between py and go
// verify that message codes are the same in between py and go.
func TestMsgCodeVsPy(t *testing.T) {
goMsgRegistry := map[uint16]string{} // code -> packet name
for code, pktType := range msgTypeRegistry{
......
......@@ -135,8 +135,6 @@ type localImporter struct {
}
func (li *localImporter) Import(path string) (*types.Package, error) {
// xpath := strings.TrimPrefix(path, "../") // ../zodb -> zodb
// pkg := pkgMap[xpath]
pkg := pkgMap[path]
if pkg != nil {
return pkg, nil
......
......@@ -2,7 +2,7 @@
package proto
import "fmt"
import "strconv"
const _ErrorCode_name = "ACKNOT_READYOID_NOT_FOUNDTID_NOT_FOUNDOID_DOES_NOT_EXISTPROTOCOL_ERRORREPLICATION_ERRORCHECKING_ERRORBACKEND_NOT_IMPLEMENTEDNON_READABLE_CELLREAD_ONLY_ACCESSINCOMPLETE_TRANSACTION"
......@@ -10,7 +10,7 @@ var _ErrorCode_index = [...]uint8{0, 3, 12, 25, 38, 56, 70, 87, 101, 124, 141, 1
func (i ErrorCode) String() string {
if i >= ErrorCode(len(_ErrorCode_index)-1) {
return fmt.Sprintf("ErrorCode(%d)", i)
return "ErrorCode(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _ErrorCode_name[_ErrorCode_index[i]:_ErrorCode_index[i+1]]
}
......@@ -21,7 +21,7 @@ var _ClusterState_index = [...]uint8{0, 17, 33, 47, 62, 77, 86, 101}
func (i ClusterState) String() string {
if i < 0 || i >= ClusterState(len(_ClusterState_index)-1) {
return fmt.Sprintf("ClusterState(%d)", i)
return "ClusterState(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _ClusterState_name[_ClusterState_index[i]:_ClusterState_index[i+1]]
}
......@@ -32,7 +32,7 @@ var _NodeType_index = [...]uint8{0, 6, 13, 19, 24}
func (i NodeType) String() string {
if i < 0 || i >= NodeType(len(_NodeType_index)-1) {
return fmt.Sprintf("NodeType(%d)", i)
return "NodeType(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _NodeType_name[_NodeType_index[i]:_NodeType_index[i+1]]
}
......@@ -43,7 +43,7 @@ var _NodeState_index = [...]uint8{0, 7, 11, 18, 25}
func (i NodeState) String() string {
if i < 0 || i >= NodeState(len(_NodeState_index)-1) {
return fmt.Sprintf("NodeState(%d)", i)
return "NodeState(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _NodeState_name[_NodeState_index[i]:_NodeState_index[i+1]]
}
......@@ -54,7 +54,7 @@ var _CellState_index = [...]uint8{0, 10, 21, 28, 37, 46}
func (i CellState) String() string {
if i < 0 || i >= CellState(len(_CellState_index)-1) {
return fmt.Sprintf("CellState(%d)", i)
return "CellState(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _CellState_name[_CellState_index[i]:_CellState_index[i+1]]
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment