created "Node"

This commit is contained in:
Jae Kwon
2014-07-09 18:33:44 -07:00
parent 237b3dc7ff
commit 1b59caf950
8 changed files with 121 additions and 18 deletions
+8
View File
@@ -95,6 +95,14 @@ func (na *NetAddress) Dial() (*Connection, error) {
return NewConnection(conn), nil
}
func (na *NetAddress) DialTimeout(timeout time.Duration) (*Connection, error) {
conn, err := net.DialTimeout("tcp", na.String(), timeout)
if err != nil {
return nil, err
}
return NewConnection(conn), nil
}
func (na *NetAddress) Routable() bool {
// TODO(oga) bitcoind doesn't include RFC3849 here, but should we?
return na.Valid() && !(na.RFC1918() || na.RFC3927() || na.RFC4862() ||
+4
View File
@@ -55,6 +55,10 @@ func (p *Peer) stop() {
}
}
func (p *Peer) IsOutgoing() bool {
return p.outgoing
}
func (p *Peer) LocalAddress() *NetAddress {
return p.conn.LocalAddress()
}
+3
View File
@@ -49,6 +49,9 @@ func NewSwitch(channels []ChannelDescriptor) *Switch {
return s
}
func (s *Switch) Start() {
}
func (s *Switch) Stop() {
log.Infof("Stopping switch")
if atomic.CompareAndSwapUint32(&s.stopped, 0, 1) {