Commit 3a012847 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 2c0b400e
......@@ -450,6 +450,7 @@ class NodeManager(object):
logging.info('\n'.join(formatNodeList(
map(Node.asTuple, self._node_set), ' * ')))
# node_type -> node_klass
@apply
def NODE_TYPE_MAPPING():
def setmethod(cls, attr, value):
......
......@@ -588,7 +588,7 @@ HandlerSwitcher
ServerConnection <Connection
KEEP_ALICE = Connection.KEEP_ALIVE + 5
KEEP_ALIVE = Connection.KEEP_ALIVE + 5
server = True
# main worker class for handling data exchanging
......@@ -676,3 +676,22 @@ RecoveryManager < MasterHandler
# operational. )
VerificationManager < BaseServiceHandler
...
--------
Node
.state
.address
.uuid
.manager # -> NodeManager
.connection
._identified
NodeManager
[]Node
{} address -> Node
{} uuid -> Node
{} type -> set<Node>
{} state -> set<Node>
......@@ -15,6 +15,7 @@
package neo
import (
"context"
"errors"
"io"
"net"
......@@ -411,11 +412,41 @@ func (c *Conn) Close() error {
}
// for convinience: Dial/Listen
// Connect to address on named network and wrap the connection as NodeLink
// TODO +tls.Config
func Dial(ctx context.Context, network, address string) (*NodeLink, error) {
d := net.Dialer{}
peerConn, err := d.DialContext(ctx, network, address)
if err != nil {
return nil, err
}
return NewNodeLink(peerConn, LinkClient), nil
}
// like net.Listener but Accept returns net.Conn wrapped in NodeLink
type Listener struct {
net.Listener
}
func (l *Listener) Accept() (*NodeLink, error) {
peerConn, err := l.Listener.Accept()
if err != nil {
return nil, err
}
return NewNodeLink(peerConn, LinkServer), nil
}
// TODO +tls.Config +ctx
func Listen(network, laddr string) (*Listener, error) {
l, err := net.Listen(network, laddr)
if err != nil {
return nil, err
}
return &Listener{l}, nil
}
// TODO
//func Dial(ctx context.Context, network, address string) (*NodeLink, error) // + tls.Config
//func Listen(network, laddr string) (net.Listener, error) // + tls.Config
// ln.Accept -> will return net.Conn wrapped in NodeLink
......
......@@ -169,7 +169,7 @@ type RequestIdentification struct {
ProtocolVersion uint32 // TODO py.PProtocol upon decoding checks for != PROTOCOL_VERSION
NodeType NodeType // XXX name
UUID UUID
Address
Address // where requesting node is also accepting connectios
Name string
IdTimestamp Float64
}
......
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