-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[contract-client] refactor #7978
[contract-client] refactor #7978
Conversation
It looks like @niklasad1 signed our Contributor License Agreement. 👍 Many thanks, Parity Technologies CLA Bot |
use_contract!(registry, "Registry", "res/registrar.json"); | ||
|
||
// This need to be documented why it is concatenated with the hash | ||
const MAGIC_CONST: &'static str = "A"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's meant to be an "A" record as in DNS
|
||
/// Syncronous contract interface. | ||
/// Should execute transaction using current blockchain state. | ||
pub trait ContractClient: Send + Sync { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the reason for the split between the traits.
Add a type Call: IntoFuture<Item=Bytes,Error=String>
.
One implementation can use Result
and another uses Box<Future>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and is this trait actually used anywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it is not used anywhere but ideally this should be used ethcore
which is synchronous if I'm not mistaken!
This seems backwards. The light client by nature serves contract call requests asynchronously (as it has to go to the network), while full nodes don't even have a futures-based API for doing so. |
|
6477508
to
caf05af
Compare
Ok, maybe I misunderstood Marek then but at least the |
I agree and disagree 😄 as long as trait contains the |
@niklasad1, #7038 is almost complete and needs final review before merge. I hope I would not block you for a long time. |
31eed4f
to
80fe4a7
Compare
@niklasad1 or even rename the |
@rphmeier Because the crate should encapsulate the registrar with a uniform interface for client and it makes sense? Yepp, naming is one of the hardest problems in CS ⚡ |
@niklasad1 sounds fine to me |
9f62221
to
fdd2068
Compare
fdd2068
to
c0cb49a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Synchronous
variant is not really used anywhere Is that expected?
Also in some places we could use more concrete types than Box<Future...>
, but that's a minor thing, probably an improvement we can do in future.
Yes, that is correct. The intention was to use
Ok, do you want me create an issue for that? |
@niklasad1 don't bother, it's not a hot code anyway, just good that it will be possible in future. |
c0cb49a
to
ebfea3e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@@ -0,0 +1,61 @@ | |||
use futures::{Future, future, IntoFuture}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing license header.
registrar/src/registrar.rs
Outdated
|
||
use_contract!(registry, "Registry", "res/registrar.json"); | ||
|
||
// Maps a domain name to IPv4 address |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maps a domain name to an Ethereum address
* Intoduced separate traits for asyncronous and syncronous contract clients * Removed registrar from ethcore::client * s/ContractClient/AsyncContractClient
* Use an associated type in the trait to determine syncronous or asyncronous communication * Export the types from contract-client crate * Document that "A" in the hash correspons to a DNS A Record A.K.A Address Record
ebfea3e
to
cd9e303
Compare
Hi,
This is a step toward closing #7821 but after realizing that it requires major refactoring in
ethcore
we decided to skip that because it also dependent on #7038.Thus, the PR provides the following:
contract-client
that is meant handle interactions to the registrar contract instead of having multiple interfaces and moves this functionality fromhash-fetch