Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

refactor(protocol): impl fixed codec trait by proc macro #240

Merged
merged 11 commits into from
Apr 15, 2020

Conversation

KaoImin
Copy link

@KaoImin KaoImin commented Apr 2, 2020

What type of PR is this?
refactor

What this PR does / why we need it:

  • impl fixed codec trait by proc macro

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

@KaoImin KaoImin requested review from yejiayu and nolanxyg April 2, 2020 08:28
Copy link
Contributor

@nolanxyg nolanxyg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If i write:

#[derive(RlpFixedCodec)]
pub struct Test {
    pub a: String,
    pub b: Kind
}

#[derive(RlpFixedCodec)]
pub enum Kind {
    Good,
    Bad
}

Could this work ?

protocol/Cargo.toml Outdated Show resolved Hide resolved
@KaoImin
Copy link
Author

KaoImin commented Apr 2, 2020

If i write:

#[derive(RlpFixedCodec)]
pub struct Test {
    pub a: String,
    pub b: Kind
}

#[derive(RlpFixedCodec)]
pub enum Kind {
    Good,
    Bad
}

Could this work ?

This can not work. The RlpFixedCodec macro only support struct type.

}
}

impl FixedCodec for usize {
Copy link
Contributor

@yejiayu yejiayu Apr 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The usize length differently on 32-bit and 64-bit systems, so it is not recommended.

Delete this code.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have already fixed the length of usize as 64 bytes.

@KaoImin KaoImin force-pushed the fixed_codec branch 3 times, most recently from 245e26a to 6a1a4b0 Compare April 14, 2020 13:45
@KaoImin
Copy link
Author

KaoImin commented Apr 15, 2020

ping @yejiayu

@yejiayu yejiayu merged commit 0734799 into nervosnetwork:master Apr 15, 2020
@KaoImin KaoImin deleted the fixed_codec branch April 15, 2020 08:35
zeroqn pushed a commit to zeroqn/muta that referenced this pull request Apr 22, 2020
…rk#240)

* refactor: impl fixed codec trait by proc macro

* upfrade fixed codec derive version

* impl Fixedcodec for primitives types

* feat: impl FixedCodec for primitive types

* feat: impl FixedCodec for Bloom

* change: codec Hex

* refactor: encode and decode for Hex

* cargo clippy

* change: primitive codec

* temp

* feat: derive fixedcodec for transaction
zeroqn pushed a commit to zeroqn/muta that referenced this pull request Apr 22, 2020
…rk#240)

* refactor: impl fixed codec trait by proc macro

* upfrade fixed codec derive version

* impl Fixedcodec for primitives types

* feat: impl FixedCodec for primitive types

* feat: impl FixedCodec for Bloom

* change: codec Hex

* refactor: encode and decode for Hex

* cargo clippy

* change: primitive codec

* temp

* feat: derive fixedcodec for transaction
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants