mirror of
https://github.com/embarklabs/web3.js.git
synced 2026-09-01 15:11:14 +00:00
txpool and debug module method names improved, types tests updated and with the web3-eth-debug documentation started
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
.. _eth-admin:
|
||||
|
||||
.. include:: include_announcement.rst
|
||||
|
||||
=================
|
||||
Web3 Debug Module
|
||||
=================
|
||||
|
||||
|
||||
The ``web3-eth-debug`` package allows you to interact with the Ethereum node's debug methods.
|
||||
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
import Web3 from 'web3';
|
||||
import {Debug} from 'web3-eth-debug';
|
||||
|
||||
// "Web3.givenProvider" will be set if in an Ethereum supported browser.
|
||||
const admin = new Debug(Web3.givenProvider || 'ws://some.local-or-remote.node:8546', null, options);
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
|
||||
.. include:: include_package-core.rst
|
||||
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
setBackTraceAt
|
||||
=========
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
debug.setBackTraceAt(location, [callback])
|
||||
|
||||
Sets the logging backtrace location.
|
||||
|
||||
----------
|
||||
Parameters
|
||||
----------
|
||||
|
||||
1. ``location`` - ``String``: The location is specified as ``<filename>:<line>``.
|
||||
2. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second.
|
||||
|
||||
-------
|
||||
Returns
|
||||
-------
|
||||
|
||||
``Promise<String>`` - True if peer added successfully.
|
||||
|
||||
-------
|
||||
Example
|
||||
-------
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
admin.setBackTraceAt("filename.go:200").then(console.log);
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
|
||||
blockProfile
|
||||
=====================
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
debug.blockProfile([, callback])
|
||||
|
||||
Turns on block profiling for the given duration and writes profile data to disk. It uses a profile rate of 1 for most accurate information.
|
||||
If a different rate is desired, set the rate and write the profile manually using ``debug.writeBlockProfile``.
|
||||
|
||||
----------
|
||||
Parameters
|
||||
----------
|
||||
|
||||
|
||||
1. ``file`` - ``String``
|
||||
1. ``seconds`` - ``Number``
|
||||
2. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second.
|
||||
|
||||
|
||||
-------
|
||||
Returns
|
||||
-------
|
||||
|
||||
|
||||
``Promise<string>`` - The path.
|
||||
|
||||
|
||||
-------
|
||||
Example
|
||||
-------
|
||||
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
admin.getDataDirectory()
|
||||
.then(console.log);
|
||||
> "/home/ubuntu/.ethereum"
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
@@ -30,7 +30,7 @@ The ``web3-eth-txpool`` package gives you access to several non-standard RPC met
|
||||
|
||||
.. _txpool-content:
|
||||
|
||||
content
|
||||
getContent
|
||||
=========
|
||||
|
||||
.. code-block:: javascript
|
||||
@@ -144,12 +144,12 @@ Example
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
|
||||
inspect
|
||||
getInspection
|
||||
=====================
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
txPool.getInspect([, callback])
|
||||
txPool.getInspection([, callback])
|
||||
|
||||
The property can be queried to list a textual summary of all the transactions currently pending for inclusion in the next block(s), as well as the ones that are being scheduled for future executions.
|
||||
The RPC method used is ``txpool_inspect``.
|
||||
@@ -179,7 +179,7 @@ Example
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
txPool.getInspect().then(console.log);
|
||||
txPool.getInspection().then(console.log);
|
||||
> {
|
||||
pending: {
|
||||
0x26588a9301b0428d95e6fc3a5024fce8bec12d51: {
|
||||
@@ -234,7 +234,7 @@ Example
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
|
||||
status
|
||||
getStatus
|
||||
=====================
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
Vendored
+1
-1
@@ -235,7 +235,7 @@ export interface NodeInfo {
|
||||
}
|
||||
|
||||
export interface PeerInfo {
|
||||
caps: Array<string>;
|
||||
caps: string[];
|
||||
id: string;
|
||||
name: string;
|
||||
network: {
|
||||
|
||||
@@ -169,7 +169,10 @@ export default class Account {
|
||||
cipher.final()
|
||||
]);
|
||||
|
||||
const mac = keccak256(Buffer.concat([derivedKey.slice(16, 32), Buffer.from(ciphertext, 'hex')])).replace('0x', '');
|
||||
const mac = keccak256(Buffer.concat([derivedKey.slice(16, 32), Buffer.from(ciphertext, 'hex')])).replace(
|
||||
'0x',
|
||||
''
|
||||
);
|
||||
|
||||
return {
|
||||
version: 3,
|
||||
|
||||
@@ -46,10 +46,10 @@ admin.getNodeInfo(
|
||||
(error: Error, result: NodeInfo) => {}
|
||||
);
|
||||
|
||||
// $ExpectType Promise<any[]>
|
||||
// $ExpectType Promise<PeerInfo[]>
|
||||
admin.getPeers();
|
||||
|
||||
// $ExpectType Promise<any[]>
|
||||
// $ExpectType Promise<PeerInfo[]>
|
||||
admin.getPeers(
|
||||
(error: Error, result: any[]) => {}
|
||||
);
|
||||
|
||||
@@ -23,7 +23,16 @@ describe('SendContractMethodTest', () => {
|
||||
new AllEventsLogDecoder();
|
||||
allEventsLogDecoderMock = AllEventsLogDecoder.mock.instances[0];
|
||||
|
||||
sendContractMethod = new SendContractMethod({}, formatters, {}, {}, {}, {}, allEventsLogDecoderMock, abiModelMock);
|
||||
sendContractMethod = new SendContractMethod(
|
||||
{},
|
||||
formatters,
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
allEventsLogDecoderMock,
|
||||
abiModelMock
|
||||
);
|
||||
});
|
||||
|
||||
it('constructor check', () => {
|
||||
|
||||
@@ -60,18 +60,18 @@ export default class MethodFactory extends AbstractMethodFactory {
|
||||
super(utils, formatters);
|
||||
|
||||
this.methods = {
|
||||
backTraceAt: BackTraceAtMethod,
|
||||
setBackTraceAt: BackTraceAtMethod,
|
||||
blockProfile: BlockProfileMethod,
|
||||
cpuProfile: CpuProfileMethod,
|
||||
dumpBlock: DumpBlockMethod,
|
||||
gcStats: GcStatsMethod,
|
||||
getGCStats: GcStatsMethod,
|
||||
getBlockRlp: GetBlockRlpMethod,
|
||||
goTrace: GoTraceMethod,
|
||||
memStats: MemStatsMethod,
|
||||
seedHash: SeedHashMethod,
|
||||
getMemStats: MemStatsMethod,
|
||||
getSeedHash: SeedHashMethod,
|
||||
setBlockProfileRate: SetBlockProfileRateMethod,
|
||||
setHead: SetHeadMethod,
|
||||
stacks: StacksMethod,
|
||||
getStacks: StacksMethod,
|
||||
startCPUProfile: StartCpuProfileMethod,
|
||||
startGoTrace: StartGoTraceMethod,
|
||||
stopCPUProfile: StopCpuProfileMethod,
|
||||
@@ -81,8 +81,8 @@ export default class MethodFactory extends AbstractMethodFactory {
|
||||
traceBlockFromFile: TraceBlockFromFileMethod,
|
||||
traceBlock: TraceBlockMethod,
|
||||
traceTransaction: TraceTransactionMethod,
|
||||
verbosity: VerbosityMethod,
|
||||
vmodule: VmoduleMethod,
|
||||
setVerbosity: VerbosityMethod,
|
||||
setVerbosityPattern: VmoduleMethod,
|
||||
writeBlockProfile: WriteBlockProfileMethod,
|
||||
writeMemProfile: WriteMemProfileMethod
|
||||
};
|
||||
|
||||
+10
-10
@@ -24,7 +24,7 @@ import * as net from 'net';
|
||||
export class Debug extends AbstractWeb3Module {
|
||||
constructor(provider: provider, net?: net.Socket|null, options?: Web3ModuleOptions);
|
||||
|
||||
backTraceAt(
|
||||
setBackTraceAt(
|
||||
filename: string,
|
||||
callback?: (error: Error, result: any) => void
|
||||
): Promise<any>;
|
||||
@@ -46,7 +46,7 @@ export class Debug extends AbstractWeb3Module {
|
||||
callback?: (error: Error, result: any) => void
|
||||
): Promise<any>;
|
||||
|
||||
gcStats(
|
||||
getGCStats(
|
||||
callback?: (error: Error, result: Stats) => void
|
||||
): Promise<Stats>;
|
||||
|
||||
@@ -61,20 +61,20 @@ export class Debug extends AbstractWeb3Module {
|
||||
callback?: (error: Error, result: any) => void
|
||||
): Promise<any>;
|
||||
|
||||
memStats(callback?: (error: Error, result: any) => void): Promise<any>;
|
||||
getMemStats(callback?: (error: Error, result: any) => void): Promise<any>;
|
||||
|
||||
seedHash(
|
||||
getSeedHash(
|
||||
blockNumber: number,
|
||||
callback?: (error: Error, result: string) => void
|
||||
): Promise<string>;
|
||||
|
||||
setHead(
|
||||
blockNumber: number,
|
||||
setBlockProfileRate(
|
||||
rate: number,
|
||||
callback?: (error: Error, result: any) => void
|
||||
): Promise<any>;
|
||||
|
||||
setBlockProfileRate(
|
||||
rate: number,
|
||||
setHead(
|
||||
blockNumber: number,
|
||||
callback?: (error: Error, result: any) => void
|
||||
): Promise<any>;
|
||||
|
||||
@@ -124,12 +124,12 @@ export class Debug extends AbstractWeb3Module {
|
||||
callback?: (error: Error, result: TraceTransaction) => void
|
||||
): Promise<TraceTransaction>;
|
||||
|
||||
verbosity(
|
||||
setVerbosity(
|
||||
level: number,
|
||||
callback?: (error: Error, result: any) => void
|
||||
): Promise<any>;
|
||||
|
||||
vmodule(
|
||||
setVerbosityPattern(
|
||||
input: string,
|
||||
callback?: (error: Error, result: any) => void
|
||||
): Promise<any>;
|
||||
|
||||
@@ -22,10 +22,10 @@ import {Debug, Stats, TraceTransaction} from 'web3-eth-debug';
|
||||
const debug = new Debug('http://localhost:8545');
|
||||
|
||||
// $ExpectType Promise<any>
|
||||
debug.backTraceAt("server.go:443");
|
||||
debug.setBackTraceAt("server.go:443");
|
||||
|
||||
// $ExpectType Promise<any>
|
||||
debug.backTraceAt("server.go:443", (error: Error, result: any) => {});
|
||||
debug.setBackTraceAt("server.go:443", (error: Error, result: any) => {});
|
||||
|
||||
// $ExpectType Promise<any>
|
||||
debug.blockProfile("", 600);
|
||||
@@ -46,10 +46,10 @@ debug.dumpBlock(10);
|
||||
debug.dumpBlock(10, (error: Error, result: string) => {});
|
||||
|
||||
// $ExpectType Promise<Stats>
|
||||
debug.gcStats();
|
||||
debug.getGCStats();
|
||||
|
||||
// $ExpectType Promise<Stats>
|
||||
debug.gcStats((error: Error, result: Stats) => {});
|
||||
debug.getGCStats((error: Error, result: Stats) => {});
|
||||
|
||||
// $ExpectType Promise<string>
|
||||
debug.getBlockRlp(10);
|
||||
@@ -64,16 +64,16 @@ debug.goTrace("", 600);
|
||||
debug.goTrace("", 600, (error: Error, result: any) => {});
|
||||
|
||||
// $ExpectType Promise<any>
|
||||
debug.memStats();
|
||||
debug.getMemStats();
|
||||
|
||||
// $ExpectType Promise<any>
|
||||
debug.memStats((error: Error, result: any) => {});
|
||||
debug.getMemStats((error: Error, result: any) => {});
|
||||
|
||||
// $ExpectType Promise<string>
|
||||
debug.seedHash(1);
|
||||
debug.getSeedHash(1);
|
||||
|
||||
// $ExpectType Promise<string>
|
||||
debug.seedHash(1, (error: Error, result: string) => {});
|
||||
debug.getSeedHash(1, (error: Error, result: string) => {});
|
||||
|
||||
// $ExpectType Promise<any>
|
||||
debug.setHead(1);
|
||||
@@ -186,16 +186,16 @@ debug.traceTransaction(
|
||||
);
|
||||
|
||||
// $ExpectType Promise<any>
|
||||
debug.verbosity(5);
|
||||
debug.setVerbosity(5);
|
||||
|
||||
// $ExpectType Promise<any>
|
||||
debug.verbosity(5, (error: Error, result: any) => {});
|
||||
debug.setVerbosity(5, (error: Error, result: any) => {});
|
||||
|
||||
// $ExpectType Promise<any>
|
||||
debug.vmodule("eth/*=6");
|
||||
debug.setVerbosityPattern("eth/*=6");
|
||||
|
||||
// $ExpectType Promise<any>
|
||||
debug.vmodule("eth/*=6", (error: Error, result: any) => {});
|
||||
debug.setVerbosityPattern("eth/*=6", (error: Error, result: any) => {});
|
||||
|
||||
// $ExpectType Promise<any>
|
||||
debug.writeBlockProfile("");
|
||||
|
||||
@@ -34,7 +34,7 @@ export default class MethodFactory extends AbstractMethodFactory {
|
||||
|
||||
this.methods = {
|
||||
getContent: ContentMethod,
|
||||
getInspect: InspectMethod,
|
||||
getInspection: InspectMethod,
|
||||
getStatus: StatusMethod
|
||||
};
|
||||
}
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ export class Txpool extends AbstractWeb3Module {
|
||||
|
||||
getContent(callback?: (error: Error, result: TxPoolContent) => void): Promise<TxPoolContent>;
|
||||
|
||||
getInspect(callback?: (error: Error, result: TxPoolInspect) => void): Promise<TxPoolInspect>;
|
||||
getInspection(callback?: (error: Error, result: TxPoolInspect) => void): Promise<TxPoolInspect>;
|
||||
|
||||
getStatus(callback?: (error: Error, result: TxPoolStatus) => void): Promise<TxPoolStatus>;
|
||||
}
|
||||
|
||||
@@ -23,19 +23,19 @@ import {Content} from 'web3-core';
|
||||
const txpool = new Txpool('http://localhost:8545');
|
||||
|
||||
// $ExpectType Promise<Content>
|
||||
txpool.content();
|
||||
txpool.getContent();
|
||||
|
||||
// $ExpectType Promise<Content>
|
||||
txpool.content((error: Error, result: Content) => {});
|
||||
txpool.getContent((error: Error, result: Content) => {});
|
||||
|
||||
// $ExpectType Promise<Content>
|
||||
txpool.inspect();
|
||||
txpool.getInspection();
|
||||
|
||||
// $ExpectType Promise<Content>
|
||||
txpool.inspect((error: Error, result: Content) => {});
|
||||
txpool.getInspection((error: Error, result: Content) => {});
|
||||
|
||||
// $ExpectType Promise<Content>
|
||||
txpool.status();
|
||||
txpool.getStatus();
|
||||
|
||||
// $ExpectType Promise<Content>
|
||||
txpool.status((error: Error, result: Content) => {});
|
||||
txpool.getStatus((error: Error, result: Content) => {});
|
||||
|
||||
Reference in New Issue
Block a user