NatSpec cli option, resolver tests passing
This commit is contained in:
parent
b46e152171
commit
c4b7d4d3f7
@ -143,10 +143,14 @@ var net = web3.net;
|
|||||||
var ds, _ = docserver.New(utils.JSpathFlag.String())
|
var ds, _ = docserver.New(utils.JSpathFlag.String())
|
||||||
|
|
||||||
func (self *jsre) ConfirmTransaction(tx string) bool {
|
func (self *jsre) ConfirmTransaction(tx string) bool {
|
||||||
notice := natspec.GetNotice(self.xeth, tx, ds)
|
if self.ethereum.NatSpec {
|
||||||
fmt.Println(notice)
|
notice := natspec.GetNotice(self.xeth, tx, ds)
|
||||||
answer, _ := self.Prompt("Confirm Transaction\n[y/n] ")
|
fmt.Println(notice)
|
||||||
return strings.HasPrefix(strings.Trim(answer, " "), "y")
|
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 {
|
func (self *jsre) UnlockAccount(addr []byte) bool {
|
||||||
|
@ -231,6 +231,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
|
|||||||
utils.MinerThreadsFlag,
|
utils.MinerThreadsFlag,
|
||||||
utils.MiningEnabledFlag,
|
utils.MiningEnabledFlag,
|
||||||
utils.NATFlag,
|
utils.NATFlag,
|
||||||
|
utils.NatspecEnabledFlag,
|
||||||
utils.NodeKeyFileFlag,
|
utils.NodeKeyFileFlag,
|
||||||
utils.NodeKeyHexFlag,
|
utils.NodeKeyHexFlag,
|
||||||
utils.RPCEnabledFlag,
|
utils.RPCEnabledFlag,
|
||||||
|
@ -93,6 +93,10 @@ var (
|
|||||||
Name: "identity",
|
Name: "identity",
|
||||||
Usage: "node name",
|
Usage: "node name",
|
||||||
}
|
}
|
||||||
|
NatspecEnabledFlag = cli.BoolFlag{
|
||||||
|
Name: "natspec",
|
||||||
|
Usage: "Enable NatSpec confirmation notice",
|
||||||
|
}
|
||||||
|
|
||||||
// miner settings
|
// miner settings
|
||||||
MinerThreadsFlag = cli.IntFlag{
|
MinerThreadsFlag = cli.IntFlag{
|
||||||
@ -252,26 +256,25 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return ð.Config{
|
return ð.Config{
|
||||||
Name: common.MakeName(clientID, version),
|
Name: common.MakeName(clientID, version),
|
||||||
DataDir: ctx.GlobalString(DataDirFlag.Name),
|
DataDir: ctx.GlobalString(DataDirFlag.Name),
|
||||||
ProtocolVersion: ctx.GlobalInt(ProtocolVersionFlag.Name),
|
ProtocolVersion: ctx.GlobalInt(ProtocolVersionFlag.Name),
|
||||||
BlockChainVersion: ctx.GlobalInt(BlockchainVersionFlag.Name),
|
NetworkId: ctx.GlobalInt(NetworkIdFlag.Name),
|
||||||
SkipBcVersionCheck: false,
|
LogFile: ctx.GlobalString(LogFileFlag.Name),
|
||||||
NetworkId: ctx.GlobalInt(NetworkIdFlag.Name),
|
LogLevel: ctx.GlobalInt(LogLevelFlag.Name),
|
||||||
LogFile: ctx.GlobalString(LogFileFlag.Name),
|
LogJSON: ctx.GlobalString(LogJSONFlag.Name),
|
||||||
LogLevel: ctx.GlobalInt(LogLevelFlag.Name),
|
Etherbase: ctx.GlobalString(EtherbaseFlag.Name),
|
||||||
LogJSON: ctx.GlobalString(LogJSONFlag.Name),
|
MinerThreads: ctx.GlobalInt(MinerThreadsFlag.Name),
|
||||||
Etherbase: ctx.GlobalString(EtherbaseFlag.Name),
|
AccountManager: GetAccountManager(ctx),
|
||||||
MinerThreads: ctx.GlobalInt(MinerThreadsFlag.Name),
|
VmDebug: ctx.GlobalBool(VMDebugFlag.Name),
|
||||||
AccountManager: GetAccountManager(ctx),
|
MaxPeers: ctx.GlobalInt(MaxPeersFlag.Name),
|
||||||
VmDebug: ctx.GlobalBool(VMDebugFlag.Name),
|
Port: ctx.GlobalString(ListenPortFlag.Name),
|
||||||
MaxPeers: ctx.GlobalInt(MaxPeersFlag.Name),
|
NAT: GetNAT(ctx),
|
||||||
Port: ctx.GlobalString(ListenPortFlag.Name),
|
NatSpec: ctx.GlobalBool(NatspecEnabledFlag.Name),
|
||||||
NAT: GetNAT(ctx),
|
NodeKey: GetNodeKey(ctx),
|
||||||
NodeKey: GetNodeKey(ctx),
|
Shh: true,
|
||||||
Shh: true,
|
Dial: true,
|
||||||
Dial: true,
|
BootNodes: ctx.GlobalString(BootnodesFlag.Name),
|
||||||
BootNodes: ctx.GlobalString(BootnodesFlag.Name),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,5 +81,6 @@ func storageAddress(varidx uint32, key []byte) string {
|
|||||||
data := make([]byte, 64)
|
data := make([]byte, 64)
|
||||||
binary.BigEndian.PutUint32(data[60:64], varidx)
|
binary.BigEndian.PutUint32(data[60:64], varidx)
|
||||||
copy(data[0:32], key[0:32])
|
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))
|
return "0x" + common.Bytes2Hex(crypto.Sha3(data))
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ type testBackend struct {
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
text = "test"
|
text = "test"
|
||||||
codehash = common.RightPadString("1234", 64)
|
codehash = "1234" //common.RightPadString("1234", 64)
|
||||||
hash = common.Bytes2Hex(crypto.Sha3([]byte(text)))
|
hash = common.Bytes2Hex(crypto.Sha3([]byte(text)))
|
||||||
url = "bzz://bzzhash/my/path/contr.act"
|
url = "bzz://bzzhash/my/path/contr.act"
|
||||||
)
|
)
|
||||||
@ -23,13 +23,13 @@ func NewTestBackend() *testBackend {
|
|||||||
self := &testBackend{}
|
self := &testBackend{}
|
||||||
self.contracts = make(map[string](map[string]string))
|
self.contracts = make(map[string](map[string]string))
|
||||||
|
|
||||||
self.contracts[HashRegContractAddress] = make(map[string]string)
|
self.contracts["0x"+HashRegContractAddress] = make(map[string]string)
|
||||||
key := storageAddress(1, common.Hex2Bytes(codehash))
|
key := storageAddress(1, common.Hex2BytesFixed(codehash, 32))
|
||||||
self.contracts[HashRegContractAddress][key] = hash
|
self.contracts["0x"+HashRegContractAddress][key] = "0x" + hash
|
||||||
|
|
||||||
self.contracts[URLHintContractAddress] = make(map[string]string)
|
self.contracts["0x"+URLHintContractAddress] = make(map[string]string)
|
||||||
key = storageAddress(1, common.Hex2Bytes(hash))
|
key = storageAddress(1, common.Hex2BytesFixed(hash, 32))
|
||||||
self.contracts[URLHintContractAddress][key] = url
|
self.contracts["0x"+URLHintContractAddress][key] = "0x" + common.Bytes2Hex([]byte(url))
|
||||||
|
|
||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
@ -48,6 +48,7 @@ func TestKeyToContentHash(t *testing.T) {
|
|||||||
res := New(b, URLHintContractAddress, HashRegContractAddress)
|
res := New(b, URLHintContractAddress, HashRegContractAddress)
|
||||||
chash := common.Hash{}
|
chash := common.Hash{}
|
||||||
copy(chash[:], common.Hex2BytesFixed(codehash, 32))
|
copy(chash[:], common.Hex2BytesFixed(codehash, 32))
|
||||||
|
|
||||||
got, err := res.KeyToContentHash(chash)
|
got, err := res.KeyToContentHash(chash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("expected no error, got %v", err)
|
t.Errorf("expected no error, got %v", err)
|
||||||
@ -62,7 +63,7 @@ func TestContentHashToUrl(t *testing.T) {
|
|||||||
b := NewTestBackend()
|
b := NewTestBackend()
|
||||||
res := New(b, URLHintContractAddress, HashRegContractAddress)
|
res := New(b, URLHintContractAddress, HashRegContractAddress)
|
||||||
chash := common.Hash{}
|
chash := common.Hash{}
|
||||||
copy(chash[:], common.Hex2Bytes(hash))
|
copy(chash[:], common.Hex2BytesFixed(hash, 32))
|
||||||
got, err := res.ContentHashToUrl(chash)
|
got, err := res.ContentHashToUrl(chash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("expected no error, got %v", err)
|
t.Errorf("expected no error, got %v", err)
|
||||||
|
@ -50,6 +50,7 @@ type Config struct {
|
|||||||
LogLevel int
|
LogLevel int
|
||||||
LogJSON string
|
LogJSON string
|
||||||
VmDebug bool
|
VmDebug bool
|
||||||
|
NatSpec bool
|
||||||
|
|
||||||
MaxPeers int
|
MaxPeers int
|
||||||
Port string
|
Port string
|
||||||
@ -144,6 +145,7 @@ type Ethereum struct {
|
|||||||
// logger logger.LogSystem
|
// logger logger.LogSystem
|
||||||
|
|
||||||
Mining bool
|
Mining bool
|
||||||
|
NatSpec bool
|
||||||
DataDir string
|
DataDir string
|
||||||
etherbase common.Address
|
etherbase common.Address
|
||||||
clientVersion string
|
clientVersion string
|
||||||
@ -205,6 +207,7 @@ func New(config *Config) (*Ethereum, error) {
|
|||||||
clientVersion: config.Name, // TODO should separate from Name
|
clientVersion: config.Name, // TODO should separate from Name
|
||||||
ethVersionId: config.ProtocolVersion,
|
ethVersionId: config.ProtocolVersion,
|
||||||
netVersionId: config.NetworkId,
|
netVersionId: config.NetworkId,
|
||||||
|
NatSpec: config.NatSpec,
|
||||||
}
|
}
|
||||||
|
|
||||||
eth.chainManager = core.NewChainManager(blockDb, stateDb, eth.EventMux())
|
eth.chainManager = core.NewChainManager(blockDb, stateDb, eth.EventMux())
|
||||||
|
Loading…
Reference in New Issue
Block a user