OSDN Git Service

Added blockchain struct.
[bytom/bytom.git] / protocol / bc / bc.proto
1 syntax = "proto3";
2
3 package bc;
4
5 message Hash {
6   fixed64 v0 = 1;
7   fixed64 v1 = 2;
8   fixed64 v2 = 3;
9   fixed64 v3 = 4;
10 }
11
12 message Program {
13   uint64 vm_version = 1;
14   bytes  code       = 2;
15 }
16
17 // This message type duplicates Hash, above. One alternative is to
18 // embed a Hash inside an AssetID. But it's useful for AssetID to be
19 // plain old data (without pointers). Another alternative is use Hash
20 // in any protobuf types where an AssetID is called for, but it's
21 // preferable to have type safety.
22 message AssetID {
23   fixed64 v0 = 1;
24   fixed64 v1 = 2;
25   fixed64 v2 = 3;
26   fixed64 v3 = 4;
27 }
28
29 message AssetAmount {
30   AssetID asset_id = 1;
31   uint64  amount   = 2;
32 }
33
34 message AssetDefinition {
35   Hash    initial_block_id = 1;
36   Program issuance_program = 2;
37   Hash    data             = 3;
38 }
39
40 message ValueSource {
41   Hash        ref      = 1;
42   AssetAmount value    = 2;
43   uint64      position = 3;
44 }
45
46 message ValueDestination {
47   Hash        ref      = 1;
48   AssetAmount value    = 2;
49   uint64      position = 3;
50 }
51
52 message BlockHeader {
53   uint64 version                   = 1;
54   uint64 height                    = 2;
55   Hash   previous_block_id         = 3;
56   uint64 timestamp_ms              = 4;
57   Hash   transactions_root         = 5;
58   Hash   assets_root               = 6;
59   bytes  next_consensus_program    = 7;
60   Hash   ext_hash                  = 8;
61
62   repeated bytes witness_arguments = 9;
63 }
64
65 message TxHeader {
66   uint64        version     = 1;
67   repeated Hash result_ids  = 2;
68   Hash          data        = 3;
69   uint64        min_time_ms = 4;
70   uint64        max_time_ms = 5;
71   Hash          ext_hash    = 6;
72 }
73
74 message Mux {
75   repeated ValueSource      sources              = 1; // issuances, spends, and muxes
76   Program                   program              = 2;
77   Hash                      ext_hash             = 3;
78   repeated ValueDestination witness_destinations = 4; // outputs, retirements, and muxes
79   repeated bytes            witness_arguments    = 5;
80 }
81
82 message Nonce {
83   Program        program             = 1;
84   Hash           time_range_id       = 2;
85   Hash           ext_hash            = 3;
86   repeated bytes witness_arguments   = 4;
87   Hash           witness_anchored_id = 5;
88 }
89
90 message Output {
91   ValueSource source          = 1;
92   Program     control_program = 2;
93   Hash        data            = 3;
94   Hash        ext_hash        = 4;
95   uint64      ordinal         = 5;
96 }
97
98 message Retirement {
99   ValueSource source   = 1;
100   Hash        data     = 2;
101   Hash        ext_hash = 3;
102   uint64      ordinal  = 4;
103 }
104
105 message TimeRange {
106   uint64    min_time_ms = 1;
107   uint64    max_time_ms = 2;
108   Hash      ext_hash    = 3;
109 }
110
111 message Issuance {
112   Hash             anchor_id                = 1;
113   AssetAmount      value                    = 2;
114   Hash             data                     = 3;
115   Hash             ext_hash                 = 4;
116   ValueDestination witness_destination      = 5;
117   AssetDefinition  witness_asset_definition = 6;
118   repeated bytes   witness_arguments        = 7;
119   Hash             witness_anchored_id      = 8;
120   uint64           ordinal                  = 9;
121 }
122
123 message Spend {
124   Hash             spent_output_id     = 1;
125   Hash             data                = 2;
126   Hash             ext_hash            = 3;
127   ValueDestination witness_destination = 4;
128   repeated bytes   witness_arguments   = 5;
129   Hash             witness_anchored_id = 6;
130   uint64           ordinal             = 7;
131 }