Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
97a60286
Commit
97a60286
authored
Mar 31, 2015
by
zelig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add common/resolver skeleton
parent
45676382
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
0 deletions
+62
-0
resolver.go
common/resolver/resolver.go
+45
-0
resolver_test.go
common/resolver/resolver_test.go
+17
-0
No files found.
common/resolver/resolver.go
0 → 100644
View file @
97a60286
package
resolver
import
(
"fmt"
"net/url"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/xeth"
)
/*
Resolver implements the Ethereum DNS mapping
NameReg : Domain Name (or Code hash of Contract) -> Content Hash
UrlHint : Content Hash -> Url Hint
*/
const
(
urlHintContractAddress
=
"urlhint"
nameRegContractAddress
=
"nameReg"
)
type
Resolver
struct
{
xeth
*
xeth
.
XEth
}
func
(
self
*
Resolver
)
NameToContentHash
(
name
string
)
(
hash
common
.
Hash
,
err
error
)
{
// look up in nameReg
copy
(
hash
[
:
],
[]
byte
(
name
)[
:
32
])
return
}
func
(
self
*
Resolver
)
ContentHashToUrl
(
hash
common
.
Hash
)
(
uri
*
url
.
URL
,
err
error
)
{
// look up in nameReg
rawurl
:=
fmt
.
Sprintf
(
"bzz://%x/my/path/mycontract.sud"
,
hash
[
:
])
// mime type?
return
url
.
Parse
(
rawurl
)
}
func
(
self
*
Resolver
)
NameToUrl
(
name
string
)
(
uri
*
url
.
URL
,
err
error
)
{
// look up in urlHint
hash
,
err
:=
self
.
NameToContentHash
(
name
)
if
err
!=
nil
{
return
}
return
self
.
ContentHashToUrl
(
hash
)
}
common/resolver/resolver_test.go
0 → 100644
View file @
97a60286
package
resolver
import
(
"testing"
)
func
TestNameToContentHash
(
t
*
testing
.
T
)
{
}
func
TestContentHashToUrl
(
t
*
testing
.
T
)
{
}
func
TestNameToUrl
(
t
*
testing
.
T
)
{
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment