Comments (6)
On the other hand, this whole issue might be a case of premature optimization(?)
I think its probably better to handle it now rather than to leave for future. Its clear that some tidying up is needed and we might need to try different things before coming up with a good approach.
Possible way that came to my mind.
-
Define our own serialization/deserialzsation logic and use serde to link them as you mentioned.
-
Its better to make stuffs binary and compact(?), I have seen other projects using
bitcoin consensus
type encoding with little modification (mostly endian-ness). Should we have something like that? Canserde
already handle that? then we might not need to write our own. -
Writing our own might have added benefit of having future flexibility so better optimization can be done. We have to cover basic data types and then can export it to higher level structures as traits. Will be some work. But might make sense to get it done.
Also it seems rust-bitcoin already have core compatible encoding here https://github.com/rust-bitcoin/rust-bitcoin/blob/master/src/consensus/encode.rs, maybe something that we can directly use? We just need to implement the traits for our structs.
from teleport-transactions.
To further the discussion in this regard, I have made a trial encoding with rust-bitcoin here https://github.com/mojoX911/teleport-transactions/blob/cffba4d20c37f4a78af13eb5fc49bb44286e42b9/src/messages.rs#L96-L143.
It works, and there is a test here https://github.com/mojoX911/teleport-transactions/blob/cffba4d20c37f4a78af13eb5fc49bb44286e42b9/src/messages.rs#L286-L321
This can be done for other network messages also. Which will effectively compact the message size, and also will let us handle
allowed method logic more elegantly than string comparison as discussed #23 (comment).
Before proceeding further in this approach I would like to have agreement on using consensus encoding trait of rust-bitcoin for this purpose.
To me it seems easier than hand crafting our own encoding method, as all the primitive types are already covered in rust-bitcoin.
from teleport-transactions.
Using rust-bitcoin's already-existing function is a good idea. Your code looks good I think.
However see my comment in #23 (comment). Using bytes instead of strings doesnt make the allowed method logic more elegant, and also doesnt make use rust's compiler for error checking, only using enums does that. So the two goals are orthogonal.
from teleport-transactions.
@chris-belcher agreed. I misunderstood the goal in #23 . Updated the PR as per your comment.
And that I think allows us to remove method
flag from messages all together.
I will start working on the encoding of remaining structures.
from teleport-transactions.
One thing we could consider is moving away from json serialization entirely and making everything be binary?
There is a serde_cbor crate for serializing data in resource constrained environments. That way we could move to a more efficient serialization format without abandoning the benefits of serde
.
from teleport-transactions.
serde_cbor
seems like almost exactly what we want I think(?)
from teleport-transactions.
Related Issues (20)
- Add multiple debug message levels HOT 1
- Create better way of controlling acceptable protocol methods HOT 4
- Dedicated Maker Taker structure HOT 4
- Move integration tests to their own directory HOT 4
- Outputs to stdout gone when running maker HOT 1
- Incoming/Outgoing SwapCoins incorrectly use Hash256
- [QnA] How about RON for Wallet data encoding? HOT 1
- Implement PTLC scripts HOT 12
- ECDSA-2P resources HOT 7
- CI failure at grcov 0.8.3
- Implement normal spend from wallet HOT 1
- teleport attempts to use jsonrpc 2.0 despite it not being supported by Core HOT 14
- Non-hardcoded configuration - use `configure_me`?
- Payjoin - bip78 crate HOT 9
- Implement JSON RPC Interface HOT 1
- Troubleshooting the connection between taker and maker HOT 2
- better test script
- No download-offers subroutine HOT 6
- Creating a secp256k1 context singleton
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 teleport-transactions.