Comments (6)
Ok, I made changes to use lifetimes but I think your changes are better. If there's only one parameter for the function then we shouldn't need lifetimes anymore. Here are the changes I was going to make for your reference, they were just straight from the documentation. https://github.com/Drops-of-Diamond/diamond_drops/compare/notary...ltfschoen:notary?expand=1
let mut sid: &mut [u8; 32] = &mut [0; 32];
u256_to_bytes32(&self.shard_id, &mut sid);
...
let mut p: &mut [u8; 32] = &mut [0; 32];
u256_to_bytes32(&self.period, &mut p);
...
fn u256_to_bytes32<'a>(u256: &'a ethereum_types::U256, dst: &'a mut [u8; 32]) -> &'a [u8; 32] {
for i in 0..32 {
dst[i] = u256.byte(i);
}
dst
}
...
let mut sid_bytes: &mut [u8; 32] = &mut [0; 32];
u256_to_bytes32(&sid, &mut sid_bytes);
...
let mut period_bytes: &mut [u8; 32] = &mut [0; 32];
u256_to_bytes32(&period, &mut period_bytes);
from diamond_drops.
One improvement that I think it needs is to return dst, and not actually take dst as an input parameter.
from diamond_drops.
Yeah, if I can figure out a way to do that with the Rust ownership and lifetime rules I'll change it.
from diamond_drops.
Yeh I'll create a PR
Reference: https://doc.rust-lang.org/book/second-edition/ch10-03-lifetime-syntax.html
from diamond_drops.
Ok I've just pushed an update to make this return the bytes array instead of requiring two inputs. Further improvements are welcome
from diamond_drops.
Looks good now. I'll close this for now.
from diamond_drops.
Related Issues (20)
- Add support to open UML diagram in different browsers and OSs other than Mac HOT 9
- Debugging with lldb doesn't work for me
- `cli` in cargo run -- mode --help and cargo run -- --help is misleading
- cargo run -- mode --help doesn't work HOT 1
- Fix OS compatibility issues with building Clap on Windows so the build succeeds HOT 5
- Use PyO3 for importing from Python HOT 1
- Better integration of the error-chain crate HOT 1
- Handle unused imports and variables before a production release
- Serialization for when blobs are larger than a collation. Not a high priority for now.
- P2P message layer HOT 1
- Separate protocol / SMC handler functionality from node functionality in different crates
- Node main function is not designed or written well HOT 4
- Fix run tasks to include output e.g. for make docs and make uml HOT 1
- Serialize a blob into an existing collation body. HOT 13
- Write benchmarks for existing code, e.g. blob serialization HOT 3
- remove lint unused_doc_comment HOT 3
- Add a changelog (use the release history)
- Merge changes to master to update the GitHub website
- Implement Gossipsub for sharding p2p HOT 2
- Data spec for sharding visualization
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 diamond_drops.