Deduplicate registrar contract & calling logic (#11110)

* Rename RegistryInfo -> RegistryInfoDeprecated

* Add BlockId parameter to Registrar::get_address and RegistrarClient::call_contract

* Remove RegistrarClient::Call (use async for now); add RegistrarClient::get_address

* Remove Registrar type in favour of naked trait

* Use CallContract trait bound instead of separate call_contract method

* Make RegistrarClient::get_address and URLHint::resolve synchronous

* RegistrarClient::get_address: return check if address is zero

* Modify RegistryInfo::registry_address to take &str

* return Result from RegistryInfo::registry_address

* Replace RegistryInfo with RegistrarClient

- Modifed RegistrarClient::registrar_address to return Option
- Removed BlockChainClient::registrar_address

* Fix other build configs

* Fix unit test builds

* Remove local RegistrarClient type from run::execute_impl

* Remove registrar.json from ethcore

* Formatting/line breaks

* Update RegistrarClient docs, remove explicit lifetime

* Weak ref to ethcore client from hash fetch client

* Fix unit tests
This commit is contained in:
Toby Dimmick
2019-10-03 14:15:25 +01:00
committed by David
parent 0c0f965354
commit 79a17dedd0
34 changed files with 266 additions and 227 deletions

View File

@@ -22,7 +22,8 @@ use std::{
use account_state::state::StateInfo;
use blockchain::BlockProvider;
use bytes::Bytes;
use call_contract::{CallContract, RegistryInfo};
use call_contract::CallContract;
use registrar::RegistrarClient;
use common_types::{
basic_account::BasicAccount,
block_status::BlockStatus,
@@ -218,8 +219,10 @@ pub trait BadBlocks {
/// Blockchain database client. Owns and manages a blockchain and a block queue.
pub trait BlockChainClient : Sync + Send + AccountData + BlockChain + CallContract + RegistryInfo + ImportBlock
+ IoClient + BadBlocks {
pub trait BlockChainClient:
Sync + Send + AccountData + BlockChain + CallContract + RegistrarClient
+ ImportBlock + IoClient + BadBlocks
{
/// Look up the block number for the given block ID.
fn block_number(&self, id: BlockId) -> Option<BlockNumber>;
@@ -393,9 +396,6 @@ pub trait BlockChainClient : Sync + Send + AccountData + BlockChain + CallContra
/// Schedule state-altering transaction to be executed on the next pending block.
fn transact_contract(&self, address: Address, data: Bytes) -> Result<(), transaction::Error>;
/// Get the address of the registry itself.
fn registrar_address(&self) -> Option<Address>;
}
/// resets the blockchain