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
c4b7d4d3
Commit
c4b7d4d3
authored
Apr 08, 2015
by
zsfelfoldi
Committed by
zelig
Apr 19, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NatSpec cli option, resolver tests passing
parent
b46e1521
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
32 deletions
+45
-32
js.go
cmd/geth/js.go
+8
-4
main.go
cmd/geth/main.go
+1
-0
flags.go
cmd/utils/flags.go
+23
-20
resolver.go
common/resolver/resolver.go
+1
-0
resolver_test.go
common/resolver/resolver_test.go
+9
-8
backend.go
eth/backend.go
+3
-0
No files found.
cmd/geth/js.go
View file @
c4b7d4d3
...
...
@@ -143,10 +143,14 @@ var net = web3.net;
var
ds
,
_
=
docserver
.
New
(
utils
.
JSpathFlag
.
String
())
func
(
self
*
jsre
)
ConfirmTransaction
(
tx
string
)
bool
{
notice
:=
natspec
.
GetNotice
(
self
.
xeth
,
tx
,
ds
)
fmt
.
Println
(
notice
)
answer
,
_
:=
self
.
Prompt
(
"Confirm Transaction
\n
[y/n] "
)
return
strings
.
HasPrefix
(
strings
.
Trim
(
answer
,
" "
),
"y"
)
if
self
.
ethereum
.
NatSpec
{
notice
:=
natspec
.
GetNotice
(
self
.
xeth
,
tx
,
ds
)
fmt
.
Println
(
notice
)
answer
,
_
:=
self
.
Prompt
(
"Confirm Transaction
\n
[y/n] "
)
return
strings
.
HasPrefix
(
strings
.
Trim
(
answer
,
" "
),
"y"
)
}
else
{
return
true
}
}
func
(
self
*
jsre
)
UnlockAccount
(
addr
[]
byte
)
bool
{
...
...
cmd/geth/main.go
View file @
c4b7d4d3
...
...
@@ -231,6 +231,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
utils
.
MinerThreadsFlag
,
utils
.
MiningEnabledFlag
,
utils
.
NATFlag
,
utils
.
NatspecEnabledFlag
,
utils
.
NodeKeyFileFlag
,
utils
.
NodeKeyHexFlag
,
utils
.
RPCEnabledFlag
,
...
...
cmd/utils/flags.go
View file @
c4b7d4d3
...
...
@@ -93,6 +93,10 @@ var (
Name
:
"identity"
,
Usage
:
"node name"
,
}
NatspecEnabledFlag
=
cli
.
BoolFlag
{
Name
:
"natspec"
,
Usage
:
"Enable NatSpec confirmation notice"
,
}
// miner settings
MinerThreadsFlag
=
cli
.
IntFlag
{
...
...
@@ -252,26 +256,25 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
}
return
&
eth
.
Config
{
Name
:
common
.
MakeName
(
clientID
,
version
),
DataDir
:
ctx
.
GlobalString
(
DataDirFlag
.
Name
),
ProtocolVersion
:
ctx
.
GlobalInt
(
ProtocolVersionFlag
.
Name
),
BlockChainVersion
:
ctx
.
GlobalInt
(
BlockchainVersionFlag
.
Name
),
SkipBcVersionCheck
:
false
,
NetworkId
:
ctx
.
GlobalInt
(
NetworkIdFlag
.
Name
),
LogFile
:
ctx
.
GlobalString
(
LogFileFlag
.
Name
),
LogLevel
:
ctx
.
GlobalInt
(
LogLevelFlag
.
Name
),
LogJSON
:
ctx
.
GlobalString
(
LogJSONFlag
.
Name
),
Etherbase
:
ctx
.
GlobalString
(
EtherbaseFlag
.
Name
),
MinerThreads
:
ctx
.
GlobalInt
(
MinerThreadsFlag
.
Name
),
AccountManager
:
GetAccountManager
(
ctx
),
VmDebug
:
ctx
.
GlobalBool
(
VMDebugFlag
.
Name
),
MaxPeers
:
ctx
.
GlobalInt
(
MaxPeersFlag
.
Name
),
Port
:
ctx
.
GlobalString
(
ListenPortFlag
.
Name
),
NAT
:
GetNAT
(
ctx
),
NodeKey
:
GetNodeKey
(
ctx
),
Shh
:
true
,
Dial
:
true
,
BootNodes
:
ctx
.
GlobalString
(
BootnodesFlag
.
Name
),
Name
:
common
.
MakeName
(
clientID
,
version
),
DataDir
:
ctx
.
GlobalString
(
DataDirFlag
.
Name
),
ProtocolVersion
:
ctx
.
GlobalInt
(
ProtocolVersionFlag
.
Name
),
NetworkId
:
ctx
.
GlobalInt
(
NetworkIdFlag
.
Name
),
LogFile
:
ctx
.
GlobalString
(
LogFileFlag
.
Name
),
LogLevel
:
ctx
.
GlobalInt
(
LogLevelFlag
.
Name
),
LogJSON
:
ctx
.
GlobalString
(
LogJSONFlag
.
Name
),
Etherbase
:
ctx
.
GlobalString
(
EtherbaseFlag
.
Name
),
MinerThreads
:
ctx
.
GlobalInt
(
MinerThreadsFlag
.
Name
),
AccountManager
:
GetAccountManager
(
ctx
),
VmDebug
:
ctx
.
GlobalBool
(
VMDebugFlag
.
Name
),
MaxPeers
:
ctx
.
GlobalInt
(
MaxPeersFlag
.
Name
),
Port
:
ctx
.
GlobalString
(
ListenPortFlag
.
Name
),
NAT
:
GetNAT
(
ctx
),
NatSpec
:
ctx
.
GlobalBool
(
NatspecEnabledFlag
.
Name
),
NodeKey
:
GetNodeKey
(
ctx
),
Shh
:
true
,
Dial
:
true
,
BootNodes
:
ctx
.
GlobalString
(
BootnodesFlag
.
Name
),
}
}
...
...
common/resolver/resolver.go
View file @
c4b7d4d3
...
...
@@ -81,5 +81,6 @@ func storageAddress(varidx uint32, key []byte) string {
data
:=
make
([]
byte
,
64
)
binary
.
BigEndian
.
PutUint32
(
data
[
60
:
64
],
varidx
)
copy
(
data
[
0
:
32
],
key
[
0
:
32
])
//fmt.Printf("%x %v\n", key, common.Bytes2Hex(crypto.Sha3(data)))
return
"0x"
+
common
.
Bytes2Hex
(
crypto
.
Sha3
(
data
))
}
common/resolver/resolver_test.go
View file @
c4b7d4d3
...
...
@@ -14,7 +14,7 @@ type testBackend struct {
var
(
text
=
"test"
codehash
=
common
.
RightPadString
(
"1234"
,
64
)
codehash
=
"1234"
//
common.RightPadString("1234", 64)
hash
=
common
.
Bytes2Hex
(
crypto
.
Sha3
([]
byte
(
text
)))
url
=
"bzz://bzzhash/my/path/contr.act"
)
...
...
@@ -23,13 +23,13 @@ func NewTestBackend() *testBackend {
self
:=
&
testBackend
{}
self
.
contracts
=
make
(
map
[
string
](
map
[
string
]
string
))
self
.
contracts
[
HashRegContractAddress
]
=
make
(
map
[
string
]
string
)
key
:=
storageAddress
(
1
,
common
.
Hex2Bytes
(
codehash
))
self
.
contracts
[
HashRegContractAddress
][
key
]
=
hash
self
.
contracts
[
"0x"
+
HashRegContractAddress
]
=
make
(
map
[
string
]
string
)
key
:=
storageAddress
(
1
,
common
.
Hex2Bytes
Fixed
(
codehash
,
32
))
self
.
contracts
[
"0x"
+
HashRegContractAddress
][
key
]
=
"0x"
+
hash
self
.
contracts
[
URLHintContractAddress
]
=
make
(
map
[
string
]
string
)
key
=
storageAddress
(
1
,
common
.
Hex2Bytes
(
hash
))
self
.
contracts
[
URLHintContractAddress
][
key
]
=
url
self
.
contracts
[
"0x"
+
URLHintContractAddress
]
=
make
(
map
[
string
]
string
)
key
=
storageAddress
(
1
,
common
.
Hex2Bytes
Fixed
(
hash
,
32
))
self
.
contracts
[
"0x"
+
URLHintContractAddress
][
key
]
=
"0x"
+
common
.
Bytes2Hex
([]
byte
(
url
))
return
self
}
...
...
@@ -48,6 +48,7 @@ func TestKeyToContentHash(t *testing.T) {
res
:=
New
(
b
,
URLHintContractAddress
,
HashRegContractAddress
)
chash
:=
common
.
Hash
{}
copy
(
chash
[
:
],
common
.
Hex2BytesFixed
(
codehash
,
32
))
got
,
err
:=
res
.
KeyToContentHash
(
chash
)
if
err
!=
nil
{
t
.
Errorf
(
"expected no error, got %v"
,
err
)
...
...
@@ -62,7 +63,7 @@ func TestContentHashToUrl(t *testing.T) {
b
:=
NewTestBackend
()
res
:=
New
(
b
,
URLHintContractAddress
,
HashRegContractAddress
)
chash
:=
common
.
Hash
{}
copy
(
chash
[
:
],
common
.
Hex2Bytes
(
hash
))
copy
(
chash
[
:
],
common
.
Hex2Bytes
Fixed
(
hash
,
32
))
got
,
err
:=
res
.
ContentHashToUrl
(
chash
)
if
err
!=
nil
{
t
.
Errorf
(
"expected no error, got %v"
,
err
)
...
...
eth/backend.go
View file @
c4b7d4d3
...
...
@@ -50,6 +50,7 @@ type Config struct {
LogLevel
int
LogJSON
string
VmDebug
bool
NatSpec
bool
MaxPeers
int
Port
string
...
...
@@ -144,6 +145,7 @@ type Ethereum struct {
// logger logger.LogSystem
Mining
bool
NatSpec
bool
DataDir
string
etherbase
common
.
Address
clientVersion
string
...
...
@@ -205,6 +207,7 @@ func New(config *Config) (*Ethereum, error) {
clientVersion
:
config
.
Name
,
// TODO should separate from Name
ethVersionId
:
config
.
ProtocolVersion
,
netVersionId
:
config
.
NetworkId
,
NatSpec
:
config
.
NatSpec
,
}
eth
.
chainManager
=
core
.
NewChainManager
(
blockDb
,
stateDb
,
eth
.
EventMux
())
...
...
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