Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Geth "Miner and DAG" management API's implemented (web3-eth-miner) #2660

Merged
merged 29 commits into from
Apr 16, 2019
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
42b4b6a
Miner core methods added
princesinha19 Apr 7, 2019
ac53f8d
web3-eth-miner implemented
princesinha19 Apr 7, 2019
37f09d2
Merge branch '1.0' into miner-methods
princesinha19 Apr 8, 2019
b0b08d9
web3-eth-miner documentation
princesinha19 Apr 8, 2019
1aff76c
requested changes
princesinha19 Apr 9, 2019
ffb12a2
updated package.json
princesinha19 Apr 9, 2019
2b9fe8b
Removed web3-eth dependency
princesinha19 Apr 12, 2019
a16c5d5
Removed web3-eth dependency
princesinha19 Apr 12, 2019
5840947
Name fix
princesinha19 Apr 15, 2019
5643414
dependency fix
princesinha19 Apr 15, 2019
d95cbc7
Merge branch '1.0' into miner-methods
nivida Apr 15, 2019
93f965e
Merge branch '1.0' into miner-documentation
nivida Apr 15, 2019
bbf0571
pipelibe fix
princesinha19 Apr 15, 2019
47a9e4d
Merge branch 'miner-methods' of https://github.com/princesinha18/web3…
princesinha19 Apr 15, 2019
97963f2
pipeline fix
princesinha19 Apr 15, 2019
17f94a6
Merge branch 'miner-documentation' of https://github.com/princesinha1…
princesinha19 Apr 15, 2019
f78836e
multiple blankline fix
princesinha19 Apr 15, 2019
569941c
pipeline fix
princesinha19 Apr 15, 2019
6fb1560
pipeline fix
princesinha19 Apr 15, 2019
e8776fd
pipeline fix
princesinha19 Apr 15, 2019
0fb9d63
Removed accounts dependency
princesinha19 Apr 15, 2019
aec127b
Revert "Merge branch 'miner-documentation' of https://github.com/prin…
princesinha19 Apr 15, 2019
4d0fdd7
Conflict resolved
princesinha19 Apr 15, 2019
bb825c0
Conflict resolved
princesinha19 Apr 15, 2019
7b3c50c
Conflict resolved
princesinha19 Apr 15, 2019
cc70dcb
rsolve conflict
princesinha19 Apr 15, 2019
51f2dd5
Merge branch '1.0' into miner-methods
princesinha19 Apr 15, 2019
462182b
resolve comflict
princesinha19 Apr 15, 2019
4ab586e
Merge branch '1.0' into miner-methods
nivida Apr 16, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/web3-core-method/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,10 @@ export PostMethod from './methods/shh/PostMethod';
export SetMaxMessageSizeMethod from './methods/shh/SetMaxMessageSizeMethod';
export SetMinPoWMethod from './methods/shh/SetMinPoWMethod';
export ShhVersionMethod from './methods/shh/ShhVersionMethod';

// Miner
export SetEtherBaseMethod from './methods/miner/SetEtherBaseMethod';
export SetExtraMethod from './methods/miner/SetExtraMethod';
export SetGasPriceMethod from './methods/miner/SetGasPriceMethod';
export StartMinerMethod from './methods/miner/StartMinerMethod';
export StopMinerMethod from './methods/miner/StopMinerMethod';
36 changes: 36 additions & 0 deletions packages/web3-core-method/src/methods/miner/SetEtherBaseMethod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
This file is part of web3.js.

web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file SetEtherBaseMethod.js
* @author Prince Sinha <[email protected]>
* @date 2019
*/

import AbstractMethod from '../../../lib/methods/AbstractMethod';

export default class SetEtherBaseMethod extends AbstractMethod {
/**
* @param {Utils} utils
* @param {Object} formatters
* @param {AbstractWeb3Module} moduleInstance
*
* @constructor
*/
constructor(utils, formatters, moduleInstance) {
super('miner_setEtherbase', 1, utils, formatters, moduleInstance);
}
}
36 changes: 36 additions & 0 deletions packages/web3-core-method/src/methods/miner/SetExtraMethod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
This file is part of web3.js.

web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file SetExtraMethod.js
* @author Prince Sinha <[email protected]>
* @date 2019
*/

import AbstractMethod from '../../../lib/methods/AbstractMethod';

export default class SetExtraMethod extends AbstractMethod {
/**
* @param {Utils} utils
* @param {Object} formatters
* @param {AbstractWeb3Module} moduleInstance
*
* @constructor
*/
constructor(utils, formatters, moduleInstance) {
super('miner_setExtra', 1, utils, formatters, moduleInstance);
}
}
36 changes: 36 additions & 0 deletions packages/web3-core-method/src/methods/miner/SetGasPriceMethod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
This file is part of web3.js.

web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file SetGasPriceMethod.js
* @author Prince Sinha <[email protected]>
* @date 2019
*/

import AbstractMethod from '../../../lib/methods/AbstractMethod';

export default class SetGasPriceMethod extends AbstractMethod {
/**
* @param {Utils} utils
* @param {Object} formatters
* @param {AbstractWeb3Module} moduleInstance
*
* @constructor
*/
constructor(utils, formatters, moduleInstance) {
super('miner_setGasPrice', 1, utils, formatters, moduleInstance);
}
}
36 changes: 36 additions & 0 deletions packages/web3-core-method/src/methods/miner/StartMinerMethod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
This file is part of web3.js.

web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file StartMinerMethod.js
* @author Prince Sinha <[email protected]>
* @date 2019
*/

import AbstractMethod from '../../../lib/methods/AbstractMethod';

export default class StartMinerMethod extends AbstractMethod {
/**
* @param {Utils} utils
* @param {Object} formatters
* @param {AbstractWeb3Module} moduleInstance
*
* @constructor
*/
constructor(utils, formatters, moduleInstance) {
super('miner_start', 1, utils, formatters, moduleInstance);
}
}
36 changes: 36 additions & 0 deletions packages/web3-core-method/src/methods/miner/StopMinerMethod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
This file is part of web3.js.

web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file StopMinerMethod.js
* @author Prince Sinha <[email protected]>
* @date 2019
*/

import AbstractMethod from '../../../lib/methods/AbstractMethod';

export default class StopMinerMethod extends AbstractMethod {
/**
* @param {Utils} utils
* @param {Object} formatters
* @param {AbstractWeb3Module} moduleInstance
*
* @constructor
*/
constructor(utils, formatters, moduleInstance) {
super('miner_stop', 0, utils, formatters, moduleInstance);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {formatters} from 'web3-core-helpers';
import AbstractMethod from '../../../../lib/methods/AbstractMethod';
import SetEtherBaseMethod from '../../../../src/methods/miner/SetEtherBaseMethod';

// Mocks
jest.mock('web3-core-helpers');

/**
* SetEtherBaseMethod test
*/
describe('SetEtherBaseMethodTest', () => {
let method;

beforeEach(() => {
method = new SetEtherBaseMethod(null, formatters, {});
});

it('constructor check', () => {
expect(method).toBeInstanceOf(AbstractMethod);

expect(method.rpcMethod).toEqual('miner_setEtherbase');

expect(method.parametersAmount).toEqual(1);

expect(method.utils).toEqual(null);

expect(method.formatters).toEqual(formatters);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {formatters} from 'web3-core-helpers';
import AbstractMethod from '../../../../lib/methods/AbstractMethod';
import SetExtraMethod from '../../../../src/methods/miner/SetExtraMethod';

// Mocks
jest.mock('web3-core-helpers');

/**
* SetExtraMethod test
*/
describe('SetExtraMethodTest', () => {
let method;

beforeEach(() => {
method = new SetExtraMethod(null, formatters, {});
});

it('constructor check', () => {
expect(method).toBeInstanceOf(AbstractMethod);

expect(method.rpcMethod).toEqual('miner_setExtra');

expect(method.parametersAmount).toEqual(1);

expect(method.utils).toEqual(null);

expect(method.formatters).toEqual(formatters);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {formatters} from 'web3-core-helpers';
import AbstractMethod from '../../../../lib/methods/AbstractMethod';
import SetGasPriceMethod from '../../../../src/methods/miner/SetGasPriceMethod';

// Mocks
jest.mock('web3-core-helpers');

/**
* SetGasPriceMethod test
*/
describe('SetGasPriceMethodTest', () => {
let method;

beforeEach(() => {
method = new SetGasPriceMethod(null, formatters, {});
});

it('constructor check', () => {
expect(method).toBeInstanceOf(AbstractMethod);

expect(method.rpcMethod).toEqual('miner_setGasPrice');

expect(method.parametersAmount).toEqual(1);

expect(method.utils).toEqual(null);

expect(method.formatters).toEqual(formatters);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {formatters} from 'web3-core-helpers';
import AbstractMethod from '../../../../lib/methods/AbstractMethod';
import StartMinerMethod from '../../../../src/methods/miner/StartMinerMethod';

// Mocks
jest.mock('web3-core-helpers');

/**
* StartMinerMethod test
*/
describe('StartMinerMethodTest', () => {
let method;

beforeEach(() => {
method = new StartMinerMethod(null, formatters, {});
});

it('constructor check', () => {
expect(method).toBeInstanceOf(AbstractMethod);

expect(method.rpcMethod).toEqual('miner_start');

expect(method.parametersAmount).toEqual(1);

expect(method.utils).toEqual(null);

expect(method.formatters).toEqual(formatters);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {formatters} from 'web3-core-helpers';
import AbstractMethod from '../../../../lib/methods/AbstractMethod';
import StopMinerMethod from '../../../../src/methods/miner/StopMinerMethod';

// Mocks
jest.mock('web3-core-helpers');

/**
* StopMinerMethod test
*/
describe('StopMinerMethodTest', () => {
let method;

beforeEach(() => {
method = new StopMinerMethod(null, formatters, {});
});

it('constructor check', () => {
expect(method).toBeInstanceOf(AbstractMethod);

expect(method.rpcMethod).toEqual('miner_stop');

expect(method.parametersAmount).toEqual(0);

expect(method.utils).toEqual(null);

expect(method.formatters).toEqual(formatters);
});
});
2 changes: 2 additions & 0 deletions packages/web3-core/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,5 @@ export interface Log {
blockHash: string;
blockNumber: number;
}

export type Hex = string | number;
31 changes: 31 additions & 0 deletions packages/web3-eth-miner/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# web3-eth-miner

This is a sub package of [web3.js][repo]

This is the miner package to be used in the `web3-eth` package.
Please read the [documentation][docs] for more.

## Installation

```bash
npm install web3-eth-miner
```

## Usage

```js
import {Miner} from 'web3-eth-miner';

const miner = new Miner(
'http://127.0.0.1:8546',
null,
options
);
```

## Types

All the typescript typings are placed in the types folder.

[docs]: http://web3js.readthedocs.io/en/1.0/
[repo]: https://github.com/ethereum/web3.js
3 changes: 3 additions & 0 deletions packages/web3-eth-miner/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const jestConfig = require('../../jest.config');

module.exports = jestConfig();
Loading