aboutsummaryrefslogtreecommitdiffstats
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/debug/api.go11
-rw-r--r--internal/ethapi/api.go35
-rw-r--r--internal/ethapi/backend.go5
-rw-r--r--internal/ethapi/tracer.go2
-rw-r--r--internal/web3ext/web3ext.go144
5 files changed, 118 insertions, 79 deletions
diff --git a/internal/debug/api.go b/internal/debug/api.go
index 8b7693f6a..3547b0564 100644
--- a/internal/debug/api.go
+++ b/internal/debug/api.go
@@ -176,6 +176,17 @@ func (*HandlerT) Stacks() string {
return string(buf)
}
+// FreeOSMemory returns unused memory to the OS.
+func (*HandlerT) FreeOSMemory() {
+ debug.FreeOSMemory()
+}
+
+// SetGCPercent sets the garbage collection target percentage. It returns the previous
+// setting. A negative value disables GC.
+func (*HandlerT) SetGCPercent(v int) int {
+ return debug.SetGCPercent(v)
+}
+
func writeProfile(name, file string) error {
p := pprof.Lookup(name)
log.Info("Writing profile records", "count", p.Count(), "type", name, "dump", file)
diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go
index 7874b7101..0775749e7 100644
--- a/internal/ethapi/api.go
+++ b/internal/ethapi/api.go
@@ -230,22 +230,45 @@ func (s *PrivateAccountAPI) ListAccounts() []common.Address {
type rawWallet struct {
URL string `json:"url"`
Status string `json:"status"`
- Accounts []accounts.Account `json:"accounts"`
+ Failure string `json:"failure,omitempty"`
+ Accounts []accounts.Account `json:"accounts,omitempty"`
}
// ListWallets will return a list of wallets this node manages.
func (s *PrivateAccountAPI) ListWallets() []rawWallet {
wallets := make([]rawWallet, 0) // return [] instead of nil if empty
for _, wallet := range s.am.Wallets() {
- wallets = append(wallets, rawWallet{
+ status, failure := wallet.Status()
+
+ raw := rawWallet{
URL: wallet.URL().String(),
- Status: wallet.Status(),
+ Status: status,
Accounts: wallet.Accounts(),
- })
+ }
+ if failure != nil {
+ raw.Failure = failure.Error()
+ }
+ wallets = append(wallets, raw)
}
return wallets
}
+// OpenWallet initiates a hardware wallet opening procedure, establishing a USB
+// connection and attempting to authenticate via the provided passphrase. Note,
+// the method may return an extra challenge requiring a second open (e.g. the
+// Trezor PIN matrix challenge).
+func (s *PrivateAccountAPI) OpenWallet(url string, passphrase *string) error {
+ wallet, err := s.am.Wallet(url)
+ if err != nil {
+ return err
+ }
+ pass := ""
+ if passphrase != nil {
+ pass = *passphrase
+ }
+ return wallet.Open(pass)
+}
+
// DeriveAccount requests a HD wallet to derive a new account, optionally pinning
// it for later reuse.
func (s *PrivateAccountAPI) DeriveAccount(url string, path string, pin *bool) (accounts.Account, error) {
@@ -612,7 +635,8 @@ func (s *PublicBlockChainAPI) doCall(ctx context.Context, args CallArgs, blockNr
// Setup the gas pool (also for unmetered requests)
// and apply the message.
gp := new(core.GasPool).AddGas(math.MaxBig256)
- res, gas, err := core.ApplyMessage(evm, msg, gp)
+ // TODO utilize failed flag to help gas estimation
+ res, gas, _, err := core.ApplyMessage(evm, msg, gp)
if err := vmError(); err != nil {
return nil, common.Big0, err
}
@@ -1241,7 +1265,6 @@ func (s *PublicTransactionPoolAPI) Resend(ctx context.Context, sendArgs SendTxAr
if err != nil {
return common.Hash{}, err
}
- s.b.RemoveTx(p.Hash())
if err = s.b.SendTx(ctx, signedTx); err != nil {
return common.Hash{}, err
}
diff --git a/internal/ethapi/backend.go b/internal/ethapi/backend.go
index d122b7915..368fa4872 100644
--- a/internal/ethapi/backend.go
+++ b/internal/ethapi/backend.go
@@ -53,15 +53,18 @@ type Backend interface {
GetReceipts(ctx context.Context, blockHash common.Hash) (types.Receipts, error)
GetTd(blockHash common.Hash) *big.Int
GetEVM(ctx context.Context, msg core.Message, state *state.StateDB, header *types.Header, vmCfg vm.Config) (*vm.EVM, func() error, error)
+ SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription
+ SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription
+ SubscribeChainSideEvent(ch chan<- core.ChainSideEvent) event.Subscription
// TxPool API
SendTx(ctx context.Context, signedTx *types.Transaction) error
- RemoveTx(txHash common.Hash)
GetPoolTransactions() (types.Transactions, error)
GetPoolTransaction(txHash common.Hash) *types.Transaction
GetPoolNonce(ctx context.Context, addr common.Address) (uint64, error)
Stats() (pending int, queued int)
TxPoolContent() (map[common.Address]types.Transactions, map[common.Address]types.Transactions)
+ SubscribeTxPreEvent(chan<- core.TxPreEvent) event.Subscription
ChainConfig() *params.ChainConfig
CurrentBlock() *types.Block
diff --git a/internal/ethapi/tracer.go b/internal/ethapi/tracer.go
index fc66839ea..051626527 100644
--- a/internal/ethapi/tracer.go
+++ b/internal/ethapi/tracer.go
@@ -346,7 +346,7 @@ func (jst *JavascriptTracer) CaptureState(env *vm.EVM, pc uint64, op vm.OpCode,
}
// CaptureEnd is called after the call finishes
-func (jst *JavascriptTracer) CaptureEnd(output []byte, gasUsed uint64, t time.Duration) error {
+func (jst *JavascriptTracer) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error) error {
//TODO! @Arachnid please figure out of there's anything we can use this method for
return nil
}
diff --git a/internal/web3ext/web3ext.go b/internal/web3ext/web3ext.go
index 44fabd6ab..215eae701 100644
--- a/internal/web3ext/web3ext.go
+++ b/internal/web3ext/web3ext.go
@@ -34,58 +34,56 @@ var Modules = map[string]string{
const Chequebook_JS = `
web3._extend({
- property: 'chequebook',
- methods:
- [
- new web3._extend.Method({
- name: 'deposit',
- call: 'chequebook_deposit',
- params: 1,
- inputFormatter: [null]
- }),
- new web3._extend.Property({
+ property: 'chequebook',
+ methods: [
+ new web3._extend.Method({
+ name: 'deposit',
+ call: 'chequebook_deposit',
+ params: 1,
+ inputFormatter: [null]
+ }),
+ new web3._extend.Property({
name: 'balance',
getter: 'chequebook_balance',
- outputFormatter: web3._extend.utils.toDecimal
- }),
- new web3._extend.Method({
- name: 'cash',
- call: 'chequebook_cash',
- params: 1,
- inputFormatter: [null]
- }),
- new web3._extend.Method({
- name: 'issue',
- call: 'chequebook_issue',
- params: 2,
- inputFormatter: [null, null]
- }),
- ]
+ outputFormatter: web3._extend.utils.toDecimal
+ }),
+ new web3._extend.Method({
+ name: 'cash',
+ call: 'chequebook_cash',
+ params: 1,
+ inputFormatter: [null]
+ }),
+ new web3._extend.Method({
+ name: 'issue',
+ call: 'chequebook_issue',
+ params: 2,
+ inputFormatter: [null, null]
+ }),
+ ]
});
`
const Clique_JS = `
web3._extend({
- property: 'clique',
- methods:
- [
+ property: 'clique',
+ methods: [
new web3._extend.Method({
name: 'getSnapshot',
call: 'clique_getSnapshot',
params: 1,
- inputFormatter: [null]
+ inputFormatter: [null]
}),
new web3._extend.Method({
name: 'getSnapshotAtHash',
call: 'clique_getSnapshotAtHash',
params: 1
}),
- new web3._extend.Method({
- name: 'getSigners',
- call: 'clique_getSigners',
- params: 1,
- inputFormatter: [null]
- }),
+ new web3._extend.Method({
+ name: 'getSigners',
+ call: 'clique_getSigners',
+ params: 1,
+ inputFormatter: [null]
+ }),
new web3._extend.Method({
name: 'getSignersAtHash',
call: 'clique_getSignersAtHash',
@@ -100,10 +98,9 @@ web3._extend({
name: 'discard',
call: 'clique_discard',
params: 1
- })
- ],
- properties:
- [
+ }),
+ ],
+ properties: [
new web3._extend.Property({
name: 'proposals',
getter: 'clique_proposals'
@@ -115,8 +112,7 @@ web3._extend({
const Admin_JS = `
web3._extend({
property: 'admin',
- methods:
- [
+ methods: [
new web3._extend.Method({
name: 'addPeer',
call: 'admin_addPeer',
@@ -162,10 +158,9 @@ web3._extend({
new web3._extend.Method({
name: 'stopWS',
call: 'admin_stopWS'
- })
+ }),
],
- properties:
- [
+ properties: [
new web3._extend.Property({
name: 'nodeInfo',
getter: 'admin_nodeInfo'
@@ -177,7 +172,7 @@ web3._extend({
new web3._extend.Property({
name: 'datadir',
getter: 'admin_datadir'
- })
+ }),
]
});
`
@@ -185,8 +180,7 @@ web3._extend({
const Debug_JS = `
web3._extend({
property: 'debug',
- methods:
- [
+ methods: [
new web3._extend.Method({
name: 'printBlock',
call: 'debug_printBlock',
@@ -269,6 +263,16 @@ web3._extend({
outputFormatter: console.log
}),
new web3._extend.Method({
+ name: 'freeOSMemory',
+ call: 'debug_freeOSMemory',
+ params: 0,
+ }),
+ new web3._extend.Method({
+ name: 'setGCPercent',
+ call: 'debug_setGCPercent',
+ params: 1,
+ }),
+ new web3._extend.Method({
name: 'memStats',
call: 'debug_memStats',
params: 0,
@@ -358,8 +362,7 @@ web3._extend({
const Eth_JS = `
web3._extend({
property: 'eth',
- methods:
- [
+ methods: [
new web3._extend.Method({
name: 'sign',
call: 'eth_sign',
@@ -396,10 +399,9 @@ web3._extend({
},
params: 2,
inputFormatter: [web3._extend.formatters.inputBlockNumberFormatter, web3._extend.utils.toHex]
- })
+ }),
],
- properties:
- [
+ properties: [
new web3._extend.Property({
name: 'pendingTransactions',
getter: 'eth_pendingTransactions',
@@ -411,7 +413,7 @@ web3._extend({
}
return formatted;
}
- })
+ }),
]
});
`
@@ -419,8 +421,7 @@ web3._extend({
const Miner_JS = `
web3._extend({
property: 'miner',
- methods:
- [
+ methods: [
new web3._extend.Method({
name: 'start',
call: 'miner_start',
@@ -451,7 +452,7 @@ web3._extend({
new web3._extend.Method({
name: 'getHashrate',
call: 'miner_getHashrate'
- })
+ }),
],
properties: []
});
@@ -461,12 +462,11 @@ const Net_JS = `
web3._extend({
property: 'net',
methods: [],
- properties:
- [
+ properties: [
new web3._extend.Property({
name: 'version',
getter: 'net_version'
- })
+ }),
]
});
`
@@ -474,8 +474,7 @@ web3._extend({
const Personal_JS = `
web3._extend({
property: 'personal',
- methods:
- [
+ methods: [
new web3._extend.Method({
name: 'importRawKey',
call: 'personal_importRawKey',
@@ -493,17 +492,21 @@ web3._extend({
params: 2
}),
new web3._extend.Method({
+ name: 'openWallet',
+ call: 'personal_openWallet',
+ params: 2
+ }),
+ new web3._extend.Method({
name: 'deriveAccount',
call: 'personal_deriveAccount',
params: 3
- })
+ }),
],
- properties:
- [
+ properties: [
new web3._extend.Property({
name: 'listWallets',
getter: 'personal_listWallets'
- })
+ }),
]
})
`
@@ -512,12 +515,11 @@ const RPC_JS = `
web3._extend({
property: 'rpc',
methods: [],
- properties:
- [
+ properties: [
new web3._extend.Property({
name: 'modules',
getter: 'rpc_modules'
- })
+ }),
]
});
`
@@ -628,7 +630,7 @@ web3._extend({
name: 'newMessageFilter',
call: 'shh_newMessageFilter',
params: 1
- })
+ }),
],
properties:
[
@@ -664,7 +666,7 @@ web3._extend({
name: 'listmounts',
call: 'swarmfs_listmounts',
params: 0
- })
+ }),
]
});
`
@@ -691,7 +693,7 @@ web3._extend({
status.queued = web3._extend.utils.toDecimal(status.queued);
return status;
}
- })
+ }),
]
});
`