protobuf3-solidity – protobuf3稠度区块链毕设代写

区块链毕设代写本文提供国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,protobuf3-solidity – protobuf3稠度区块链毕设代写 是一篇很好的国外资料

protobuf3-solidity

protobuf3-solidity - protobuf3稠度

A protobuf3 code generator plugin for Solidity. Decode and encode protobuf messages in your Solidity contract! Leverages the protobuf3-solidity-lib codec library.

Serialization rules are stricter than default protobuf3 rules, and are specified in ADR-027. The resulting serialization is bijective (one-to-one), rather than the usual non-deterministic and malleable serialization used in most protobuf parsers. This makes it suitable for canonical serialization in blockchain applications.

Usage

Use as a protoc plugin:

protoc --plugin protoc-gen-sol --sol_out [license=<license string>:]<output directory> <proto files>

Examples:

# Output foo.proto.sol in current directory protoc --plugin protoc-gen-sol --sol_out . foo.proto  # Generate Solidity file with Apache-2.0 license identifier protoc --plugin protoc-gen-sol --sol_out license=Apache-2.0:. foo.proto

Feature support

The below protobuf file shows all supported features of this plugin.

syntax = "proto3";  enum OtherEnum {   UNSPECIFIED = 0;   ONE = 1;   TWO = 2; };  message OtherMessage {   uint64 other_field = 1; }  message Message {   int32 optional_int32 = 1;   int64 optional_int64 = 2;   uint32 optional_uint32 = 3;   uint64 optional_uint64 = 4;   sint32 optional_sint32 = 5;   sint64 optional_sint64 = 6;   fixed32 optional_fixed32 = 7;   fixed64 optional_fixed64 = 8;   sfixed32 optional_sfixed32 = 9;   sfixed64 optional_sfixed64 = 10;   bool optional_bool = 11;   string optional_string = 12;   bytes optional_bytes = 13;   OtherEnum optional_enum = 14;   OtherMessage optional_message = 15;    repeated int32 repeated_int32 = 16 [packed = true];   repeated int64 repeated_int64 = 17 [packed = true];   repeated uint32 repeated_uint32 = 18 [packed = true];   repeated uint64 repeated_uint64 = 19 [packed = true];   repeated sint32 repeated_sint32 = 20 [packed = true];   repeated sint64 repeated_sint64 = 21 [packed = true];   repeated fixed32 repeated_fixed32 = 22 [packed = true];   repeated fixed64 repeated_fixed64 = 23 [packed = true];   repeated sfixed32 repeated_sfixed32 = 24 [packed = true];   repeated sfixed64 repeated_sfixed64 = 25 [packed = true];   repeated bool repeated_bool = 26 [packed = true];   repeated OtherEnum repeated_enum = 27 [packed = true];   repeated OtherMessage repeated_message = 28; }

Rules to keep in mind:

  1. Enum values must start at 0 and increment by 1.
  2. Field numbers must start at 1 and increment by 1.
  3. Repeated numeric types must currently explicitly specify [packed = true].

Unsupported features:

  1. repeated string and bytes – Solidity does not support arrays of string or bytes. Workaround: wrap the field in a message.
  2. nested enum or message definitions – All enum and message definitions must be top-level.
  3. float and double – Solidity does not support floating-point numbers.
  4. package – Currently unsupported.
  5. import – Currently unsupported, undefined behavior.
  6. multiple files – Currently unsupported, undefined behavior.
  7. oneof – Solidity does not support unions.
  8. map – Maps are forbidden as per ADR-027.

Building from source

Requires Go >= 1.14.

Build:

make

Test:

make test-protoc

#7


protobuf3的可靠性

一个protobuf3代码生成器插件。解码和编码协议中的协议信息!利用protobuf3 solidity lib编解码器库。

序列化规则比默认protobuf3规则更严格,并在ADR-027中指定。结果的序列化是双对象的(一对一),而不是大多数protobuf解析器中使用的不确定性和可塑性序列化。这使得它适合于区块链blockchain应用程序中的规范序列化。

用作protoc插件:

使用情况

示例:

protoc --plugin protoc-gen-sol --sol_out [license=<license string>:]<output directory> <proto files>

下面的protobuf文件显示了此插件支持的所有功能。

# Output foo.proto.sol in current directory protoc --plugin protoc-gen-sol --sol_out . foo.proto  # Generate Solidity file with Apache-2.0 license identifier protoc --plugin protoc-gen-sol --sol_out license=Apache-2.0:. foo.proto

功能支持

要记住的规则:

syntax = "proto3";  enum OtherEnum {   UNSPECIFIED = 0;   ONE = 1;   TWO = 2; };  message OtherMessage {   uint64 other_field = 1; }  message Message {   int32 optional_int32 = 1;   int64 optional_int64 = 2;   uint32 optional_uint32 = 3;   uint64 optional_uint64 = 4;   sint32 optional_sint32 = 5;   sint64 optional_sint64 = 6;   fixed32 optional_fixed32 = 7;   fixed64 optional_fixed64 = 8;   sfixed32 optional_sfixed32 = 9;   sfixed64 optional_sfixed64 = 10;   bool optional_bool = 11;   string optional_string = 12;   bytes optional_bytes = 13;   OtherEnum optional_enum = 14;   OtherMessage optional_message = 15;    repeated int32 repeated_int32 = 16 [packed = true];   repeated int64 repeated_int64 = 17 [packed = true];   repeated uint32 repeated_uint32 = 18 [packed = true];   repeated uint64 repeated_uint64 = 19 [packed = true];   repeated sint32 repeated_sint32 = 20 [packed = true];   repeated sint64 repeated_sint64 = 21 [packed = true];   repeated fixed32 repeated_fixed32 = 22 [packed = true];   repeated fixed64 repeated_fixed64 = 23 [packed = true];   repeated sfixed32 repeated_sfixed32 = 24 [packed = true];   repeated sfixed64 repeated_sfixed64 = 25 [packed = true];   repeated bool repeated_bool = 26 [packed = true];   repeated OtherEnum repeated_enum = 27 [packed = true];   repeated OtherMessage repeated_message = 28; }

不支持的功能:

  1. 枚举值必须从0开始并递增1。
  2. 字段号必须从1开始并递增1。
  3. 重复的数字类型当前必须显式指定[packad=true]。

需要Go&gt;=1.14。

  1. 重复的字符串和字节-Solidity不支持字符串或字节数组。解决方法:将字段包装在消息中。
  2. 嵌套枚举或消息定义-所有枚举和消息定义都必须是顶级的。float和double-Solidity不支持浮点数。
  3. 软件包-当前不受支持。
  4. 导入-当前不支持、未定义的行为。
  5. 多个文件-当前不支持、未定义的行为。
  6. one-Solidity不支持联合。
  7. 根据ADR-027,禁止使用地图。在
  8. map – Maps are forbidden as per ADR-027.

从源代码构建

构建:

测试:

make

Test:

make test-protoc

#7

部分转自网络,侵权联系删除区块链源码网

www.interchains.cc

https://www.interchains.cc/17141.html

区块链毕设网(www.interchains.cc)全网最靠谱的原创区块链毕设代做网站 部分资料来自网络,侵权联系删除! 最全最大的区块链源码站 !
区块链知识分享网, 以太坊dapp资源网, 区块链教程, fabric教程下载, 区块链书籍下载, 区块链资料下载, 区块链视频教程下载, 区块链基础教程, 区块链入门教程, 区块链资源 » protobuf3-solidity – protobuf3稠度区块链毕设代写

提供最优质的资源集合

立即查看 了解详情