Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

Commit

Permalink
Add default returns for eth_coinbase, eth_hashrate json rpc calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Bhargavasomu committed Jan 7, 2019
1 parent 38c97c8 commit 9d932b2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
8 changes: 8 additions & 0 deletions tests/core/json-rpc/test_ipc.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ async def mock_event_bus_interaction(bus):
build_request('eth_mining'),
{'result': False, 'id': 3, 'jsonrpc': '2.0'},
),
(
build_request('eth_coinbase'),
{'result': '0x0000000000000000000000000000000000000000', 'id': 3, 'jsonrpc': '2.0'},
),
(
build_request('eth_hashrate'),
{'result': '0x0', 'id': 3, 'jsonrpc': '2.0'},
),
(
build_request('web3_clientVersion'),
{'result': construct_trinity_client_identifier(), 'id': 3, 'jsonrpc': '2.0'},
Expand Down
10 changes: 7 additions & 3 deletions trinity/rpc/modules/eth.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,10 @@ async def call(self, txn_dict: Dict[str, Any], at_block: Union[str, int]) -> str
result = self._chain.get_transaction_result(transaction, header)
return encode_hex(result)

async def coinbase(self) -> Hash32:
raise NotImplementedError()
async def coinbase(self) -> str:
# Trinity doesn't support mining yet and hence coinbase_address is default (ZERO_ADDRESS)
coinbase_address = ZERO_ADDRESS
return encode_hex(coinbase_address)

@format_params(identity, to_int_if_hex)
async def estimateGas(self, txn_dict: Dict[str, Any], at_block: Union[str, int]) -> str:
Expand Down Expand Up @@ -263,7 +265,9 @@ async def getUncleByBlockNumberAndIndex(self,
return header_to_dict(uncle)

async def hashrate(self) -> str:
raise NotImplementedError()
# Trinity doesn't support mining yet and hence hashrate is default (0)
hashrate = 0
return hex(hashrate)

async def mining(self) -> bool:
return False
Expand Down

0 comments on commit 9d932b2

Please # to comment.