mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
swarm/api: correct bzz.resolve functionality - amended
This commit is contained in:
parent
48db835e94
commit
d4b7b1d110
2 changed files with 1 additions and 46 deletions
|
|
@ -1,45 +0,0 @@
|
||||||
// Copyright 2016 The go-ethereum Authors
|
|
||||||
// This file is part of the go-ethereum library.
|
|
||||||
//
|
|
||||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The go-ethereum library is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public License
|
|
||||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
|
|
||||||
package api
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/ethereum/go-ethereum/logger/glog"
|
|
||||||
"github.com/ethereum/go-ethereum/logger"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Implements an RPC service
|
|
||||||
type Ens struct {
|
|
||||||
api *Api
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewEns(api *Api) *Ens {
|
|
||||||
return &Ens{api}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resolves ENS domains to contentHashes.
|
|
||||||
// Could use swarm Api.Resolve if we wanted bzz.resolve both domains and hashes.
|
|
||||||
func (self *Ens) Resolve(domain string) (string, error) {
|
|
||||||
contentHash, err := self.api.dns.Resolve(domain)
|
|
||||||
if err != nil {
|
|
||||||
err = ErrResolve(err)
|
|
||||||
glog.V(logger.Warn).Infof("DNS error : %v", err)
|
|
||||||
}
|
|
||||||
glog.V(logger.Detail).Infof("host lookup: %v -> %v", err)
|
|
||||||
return contentHash.Hex(), err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -236,7 +236,7 @@ func (self *Swarm) APIs() []rpc.API {
|
||||||
{
|
{
|
||||||
Namespace: "bzz",
|
Namespace: "bzz",
|
||||||
Version: "0.1",
|
Version: "0.1",
|
||||||
Service: api.NewEns(self.api),
|
Service: self.dns,
|
||||||
Public: true,
|
Public: true,
|
||||||
},
|
},
|
||||||
// admin APIs
|
// admin APIs
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue