-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cryptocurrency advanced protobuf [ECR-2296] (#1077)
- Loading branch information
Showing
12 changed files
with
233 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
extern crate exonum_build; | ||
|
||
use exonum_build::protobuf_generate; | ||
use std::env; | ||
|
||
fn main() { | ||
let exonum_protos = env::var("DEP_EXONUM_PROTOBUF_PROTOS").unwrap(); | ||
protobuf_generate( | ||
"src/proto", | ||
&["src/proto", &exonum_protos], | ||
"protobuf_mod.rs", | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
examples/cryptocurrency-advanced/backend/src/proto/cryptocurrency.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright 2018 The Exonum Team | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
syntax = "proto3"; | ||
|
||
package exonum.examples.cryptocurrency_advanced; | ||
|
||
import "helpers.proto"; | ||
|
||
/// Transfer `amount` of the currency from one wallet to another. | ||
message Transfer { | ||
// `PublicKey` of receiver's wallet. | ||
exonum.PublicKey to = 1; | ||
// Amount of currency to transfer. | ||
uint64 amount = 2; | ||
// Auxiliary number to guarantee non-idempotence of transactions. | ||
uint64 seed = 3; | ||
} | ||
|
||
// Issue `amount` of the currency to the `wallet`. | ||
message Issue { | ||
// Issued amount of currency. | ||
uint64 amount = 1; | ||
// Auxiliary number to guarantee non-idempotence of transactions. | ||
uint64 seed = 2; | ||
} | ||
|
||
// Create wallet with the given `name`. | ||
message CreateWallet { | ||
// Name of the new wallet. | ||
string name = 1; | ||
} | ||
|
||
// Wallet information stored in the database. | ||
message Wallet { | ||
// `PublicKey` of the wallet. | ||
exonum.PublicKey pub_key = 1; | ||
// Name of the wallet. | ||
string name = 2; | ||
// Current balance of the wallet. | ||
uint64 balance = 3; | ||
// Length of the transactions history. | ||
uint64 history_len = 4; | ||
// `Hash` of the transactions history. | ||
exonum.Hash history_hash = 5; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2018 The Exonum Team | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
//! Module of the rust-protobuf generated files. | ||
|
||
#![allow(bare_trait_objects)] | ||
#![allow(renamed_and_removed_lints)] | ||
|
||
pub use self::cryptocurrency::{CreateWallet, Issue, Transfer, Wallet}; | ||
|
||
include!(concat!(env!("OUT_DIR"), "/protobuf_mod.rs")); | ||
|
||
use exonum::encoding::protobuf::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.