diff --git a/backend/backend.go b/backend/backend.go index f92f650..51a7216 100644 --- a/backend/backend.go +++ b/backend/backend.go @@ -14,9 +14,10 @@ import "github.com/hlandau/madns/merr" import "github.com/hlandau/ncdns/util" import "sync" +// Provides an abstract zone file for the Namecoin .bit TLD. type Backend struct { //s *Server - nc namecoin.NamecoinConn + nc namecoin.Conn cache lru.Cache // items are of type *Domain cacheMutex sync.Mutex cfg Config @@ -26,6 +27,7 @@ const ( defaultMaxEntries = 100 ) +// Backend configuration. type Config struct { // Username and password to use for connecting to the Namecoin JSON-RPC interface. RPCUsername string diff --git a/namecoin/namecoin.go b/namecoin/namecoin.go index c4a870f..6cd7553 100644 --- a/namecoin/namecoin.go +++ b/namecoin/namecoin.go @@ -9,7 +9,7 @@ import "sync/atomic" import "fmt" // Used for generating IDs for JSON-RPC requests. -var idCounter int32 = 0 +var idCounter int32 func newID() int32 { return atomic.AddInt32(&idCounter, 1) @@ -17,7 +17,7 @@ func newID() int32 { // Used to query a Namecoin JSON-RPC interface. Initialize the struct with a // username, password, and address (hostname:port). -type NamecoinConn struct { +type Conn struct { Username string Password string Server string @@ -26,7 +26,7 @@ type NamecoinConn struct { // Query the Namecoin daemon for a Namecoin domain (e.g. d/example). // If the domain exists, returns the value stored in Namecoin, which should be JSON. // Note that this will return domain data even if the domain is expired. -func (nc *NamecoinConn) Query(name string) (v string, err error) { +func (nc *Conn) Query(name string) (v string, err error) { cmd, err := extratypes.NewNameShowCmd(newID(), name) if err != nil { //log.Info("NC NEWCMD ", err) @@ -54,10 +54,10 @@ func (nc *NamecoinConn) Query(name string) (v string, err error) { if nsr, ok := r.Result.(*extratypes.NameShowReply); ok { //log.Info("NC OK") return nsr.Value, nil - } else { - //log.Info("NC BADREPLY") - return "", fmt.Errorf("bad reply") } + + //log.Info("NC BADREPLY") + return "", fmt.Errorf("bad reply") } // © 2014 Hugo Landau GPLv3 or later