mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 05:06:43 +00:00
added net javascript API
This commit is contained in:
parent
13390cb78b
commit
557ebf9e8e
4 changed files with 50 additions and 2 deletions
|
|
@ -32,6 +32,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
"github.com/peterh/liner"
|
"github.com/peterh/liner"
|
||||||
"github.com/robertkrimen/otto"
|
"github.com/robertkrimen/otto"
|
||||||
|
"github.com/ethereum/go-ethereum/rpc/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
type prompter interface {
|
type prompter interface {
|
||||||
|
|
@ -122,7 +123,7 @@ func (js *jsre) apiBindings(ipcpath string) {
|
||||||
utils.Fatalf("Error requiring web3: %v", err)
|
utils.Fatalf("Error requiring web3: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = js.re.Compile("miner.js", re.Miner_JS)
|
err = js.re.Compile("miner.js", api.Miner_JS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf("Error loading miner.js: %v", err)
|
utils.Fatalf("Error loading miner.js: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
3
rpc/api/eth_js.go
Normal file
3
rpc/api/eth_js.go
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
package api
|
||||||
|
|
||||||
|
// JS api provided by web3.js
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package jsre
|
package api
|
||||||
|
|
||||||
const Miner_JS = `
|
const Miner_JS = `
|
||||||
web3.extend({
|
web3.extend({
|
||||||
44
rpc/api/net_js.go
Normal file
44
rpc/api/net_js.go
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
package api
|
||||||
|
|
||||||
|
const Net_JS = `
|
||||||
|
web3.extend({
|
||||||
|
property: 'miner',
|
||||||
|
methods:
|
||||||
|
[
|
||||||
|
new web3.extend.Method({
|
||||||
|
name: 'version',
|
||||||
|
call: 'net_version',
|
||||||
|
params: 0,
|
||||||
|
inputFormatter: [],
|
||||||
|
outputFormatter: web3.extend.formatters.formatOutputString
|
||||||
|
}),
|
||||||
|
new web3.extend.Method({
|
||||||
|
name: 'stop',
|
||||||
|
call: 'net_getPeerCount',
|
||||||
|
params: 0,
|
||||||
|
inputFormatter: [],
|
||||||
|
outputFormatter: web3.extend.formatters.formatOutputString
|
||||||
|
}),
|
||||||
|
new web3.extend.Method({
|
||||||
|
name: 'stop',
|
||||||
|
call: 'miner_stop',
|
||||||
|
params: 0,
|
||||||
|
inputFormatter: [],
|
||||||
|
outputFormatter: web3.extend.formatters.formatOutputBool
|
||||||
|
})
|
||||||
|
],
|
||||||
|
properties:
|
||||||
|
[
|
||||||
|
new web3.extend.Property({
|
||||||
|
name: 'listening',
|
||||||
|
getter: 'net_listening',
|
||||||
|
outputFormatter: web3.extend.formatters.formatOutputBool
|
||||||
|
}),
|
||||||
|
new web3.extend.Property({
|
||||||
|
name: 'peerCount',
|
||||||
|
getter: 'net_getPeerCount',
|
||||||
|
outputFormatter: web3.extend.utils.toDecimal
|
||||||
|
})
|
||||||
|
]
|
||||||
|
});
|
||||||
|
`
|
||||||
Loading…
Reference in a new issue