Comments (4)
The code like
pub fn execute(&self, context: &ExecutionContext) {
// narrow() notation is taken from CORBA
let service = context.get_service(CoreService::SERVICE_ID).narrow<CoreService>();
let validators = service.get_validators(context);
}
is fragile and depends on constants like SERVICE_ID
. In my humble opinion we needs something like rtti
then for each Service
associates its own service_id
.
It is also suggests that each service has only single instance in blockchain:
pub fn execute(&self, context: &ExecutionContext) {
let schema = context.create_schema::<Core>();
let anchoring_schema = context.create_schema::<AnchoringService>();
let globals = context.get_current_globals::<AnchoringService>();
let following_globals = context.get_following_globals::<AnchoringService>();
}
from exonum.
@alekseysidorov By SERVICE_ID
I did not mean an integer ID, but rather a vendor-provided GUID of the service (like, say, qualified package names work in Java; or resource naming in JNDI). But of course, something like
let core = context.get_service::<Core>();
would work too, if its implementable.
In your code, there is this notion of schemas again (including external ones). I don't quite get why they are there; it seems (at least to me) that accessing getter methods of services may do a better job, at least from the separation of concerns perspective and encapsulation. For example, one can imagine a case in which a getter method returns a constant value (i.e., does not access blockchain), or performs some manipulations with blockchain data before returning, etc.
Are schemas accessed explicitly for performance reasons? Note that even if we're talking about accessing a local schema, it could be hidden from the service developers by using something like
impl AnchoringService {
// could be generated automatically as a service skeleton
pub fn get_fee(&self) -> u64 {
// Execution context is injected into the service during transaction execution
AnchoringSchema::new(self.execution_context.view)
.get_actual_configuration().get_fee()
}
}
impl MsgAnchoringSignature {
pub fn execute(&self, service: &AnchoringService) {
let fee = service.get_fee();
// ...
}
}
from exonum.
Transaction execution is one of the most resource intensive tasks. I want to use abstractions with zero or close to it cost.
For example, comparison of guids slower than of numbers.
Construction of schema may be not zero cost, and I want to reduce this cost.
But I like the idea of separating schema into low-level interface with data tables and high-level interface with some getters and setters.
struct AnchoringBlockchain<'a> {
schema: &'a AnchoringSchema
}
impl AnchoringBlockchainInterface
{
pub fn get_fee(&self) -> u32 {
schema.get_actual_configuration().get_fee()
}
}
...
let iface = context.create_interface::<AnchoringBlockchainInterface>();
let fee = iface.get_fee();
from exonum.
Got it; I am proponent of clarity of code at the expense of speed (in reasonable margins) - that's probably why I'm not an expert Rust coder :) But I understand that the speed matters too. As for comparisons of guids specifically, an external service (stub) may be injected (using the guid) into the service a single time when the service is created, so this shouldn't probably be a problem. Probably.
from exonum.
Related Issues (20)
- Dependabot can't resolve your Rust dependency files
- Hash of the proof is not equal to the trusted hash of the index after committing new block with at least 50% probability HOT 13
- Dependabot can't resolve your Rust dependency files
- Propose message HOT 1
- exonum_merkledb crate uses rocksdb 0.13.0, is there a plan to upgrade to rocksdb 0.15.0 HOT 2
- Performance degradation on a long running network HOT 41
- Concerns About Actix For a Security Oriented Software Project HOT 5
- Accept extra args in exonum build HOT 4
- Errors when targeting webassembly HOT 4
- crates.io version of exonum contains multiple severe vulnerabilities HOT 3
- error: failed to run custom build command for `librocksdb-sys v6.20.3` HOT 1
- Can no longer compile Crypto Currency Advanced - weird error doesn't make sense to me HOT 2
- Support Asymmetric Encryption on exonum-crypto
- Weed Coin
- Windows support problem: Couldn't compile the test.
- actix-http error
- Creating a distributed network
- Please update linux dependencies in the Installation Guide
- error: failed to run custom build command for `exonum-proto v1.0.0` HOT 2
- failed to run custom build command for `protobuf-convert v0.4.0` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from exonum.