Last active
April 20, 2017 16:46
-
-
Save Warchant/b7049e2f0653bd30c78f06b283c30bf0 to your computer and use it in GitHub Desktop.
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
include "key.fbs"; | |
include "primitives.fbs"; | |
include "asset.fbs"; | |
namespace iroha; | |
table Account { | |
pubKey: PublicKey (required); // primary key for account | |
alias: string; | |
// for m-n multisignature scheme | |
// signatories.size() = n, useKeys = m | |
signatories: [PublicKey]; | |
useKeys: ushort = 1; | |
} | |
// message represents custom user data, related to account. User is able to store blobs in his account and access it by key. | |
// e.g., | |
//{ | |
// accPubKey: "account1", | |
// data: { | |
// key: "email", | |
// value: "bogdan@soramitsu.co.jp" | |
// } | |
//} | |
table Message { | |
accPubKey: PublicKey (required); | |
// values can be accessed by key for O(log(n)). Look at "Storing maps" section in flatbuffers docs | |
data: [KeyValueObject]; | |
} | |
root_type Account; |
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
include "primitives.fbs"; | |
namespace iroha; | |
table ComplexAsset { | |
// (ledger:domain:asset) = composite primary key for any asset | |
asset_name: string (key, required); // sorted; name should be unique inside a domain | |
domain_name: string (required); // domain should be unique inside a ledger | |
ledger_name: string (required); // unique worldwide | |
description: string; | |
// amount and precision should be encoded in properties | |
prop: [KeyValueObject]; // using this, you can create complex assets | |
logic: AssetLogic; | |
} | |
table AssetLogic { | |
add: Chaincode; | |
remove: Chaincode; | |
transfer: Chaincode; | |
} | |
// currency is a simple asset, like USD. | |
table Currency { | |
currency_name: string (required, key); | |
domain_name: string (required); | |
ledger_name: string (required); | |
description: string; | |
amount: ulong; | |
precision: ulong; | |
} | |
union AnyAsset { ComplexAsset, Currency } | |
table Asset { | |
asset: AnyAsset; | |
} | |
root_type Asset; |
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
include "asset.fbs"; | |
include "account.fbs"; | |
include "key.fbs"; | |
include "primitives.fbs"; | |
namespace iroha; | |
// we union only those objects. | |
// they share the same commands | |
union Object { Peer, Account, Chaincode } | |
table CmdAdd { | |
object: Object (required); | |
} | |
table CmdRemove { | |
object: Object (required); | |
} | |
// users are able to store custom data in their accounts | |
table CmdStore { | |
accPubKey: PublicKey (required); | |
data: [KeyValueObject] (required); | |
} | |
table CmdTransfer { | |
currency: Asset (required); | |
sender: PublicKey (required); | |
receiver: PublicKey (required); | |
} | |
////////////////////////////////////////// | |
/// Commands for Asset | |
// logically means asset summation | |
table CmdAddAsset { | |
accPubKey: PublicKey (required); | |
asset: [AnyAsset] (required); | |
} | |
// logically means asset negation | |
table CmdRemoveAsset { | |
accPubKey: PublicKey (required); | |
asset: [AnyAsset] (required); | |
} | |
// needed to implement correct permission model: | |
// user may have permission to add asset, but not to create and vice versa. | |
table CmdCreateAsset { | |
asset_name: string (required); | |
domain_name: string (required); | |
ledger_name: string (required); | |
description: string; | |
} | |
////////////////////////////////////////// | |
////////////////////////////////////////// | |
/// Commands for Chaincode | |
table CmdExecute { | |
code_name: string (required); | |
domain_name: string (required); | |
ledger_name: string (required); | |
} | |
// consider chaincode storage as key-value map | |
table CmdSetChaincode { | |
chaincode: Chaincode (required); | |
} | |
////////////////////////////////////////// | |
////////////////////////////////////////// | |
/// Commands for Peer | |
// set new peer trust (with specific value) | |
table CmdSetPeerTrust { | |
peerPubKey: PublicKey (required); | |
trust: double; | |
} | |
// change current trust to some delta | |
// example: delta=-5, trust=10 -> newTrust = 10-5 = 5 | |
table CmdChangePeerTrust { | |
peerPubKey: PublicKey (required); | |
delta: double; | |
} | |
table CmdSetPeerActive { | |
peerPubKey: PublicKey (required); | |
active: bool; | |
} | |
////////////////////////////////////////// | |
////////////////////////////////////////// | |
/// Commands for Account | |
table CmdAddSignatory { | |
account: PublicKey (required); | |
signatory: [PublicKey] (required); | |
} | |
table CmdSetAccountsUseKeys { | |
accounts: [PublicKey] (required); | |
useKeys: ushort; | |
} | |
////////////////////////////////////////// | |
union Command { | |
CmdAddAsset, | |
CmdRemoveAsset, | |
CmdCreateAsset, | |
CmdTransfer, | |
CmdAdd, | |
CmdRemove, | |
CmdExecute, | |
CmdStore, | |
CmdSetPeerTrust, | |
CmdChangePeerTrust, | |
CmdSetPeerActive, | |
CmdSetChaincode, | |
CmdSetAccountsUseKeys | |
} |
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
namespace iroha; | |
// another ledgers can use another algorithms | |
enum KeyAlgorithm: byte { ed25519 } | |
table PublicKey{ | |
algorithm: KeyAlgorithm = ed25519; | |
data: [ubyte] (required); | |
} |
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
include "transaction.fbs"; | |
include "commands.fbs"; | |
namespace iroha; | |
file_identifier "IROH"; | |
file_extension "iroha"; | |
table ConsensusEvent { | |
peerSignatures: [Signature]; | |
transactions: [Transaction]; | |
} | |
enum Code: ubyte {COMMIT, FAIL} // TODO: maybe more? | |
table TransactionResponse { | |
message: string; | |
code: Code; | |
transaction: Transaction; | |
} | |
table ReceiverConfirmation { | |
signature: Signature; | |
hash: [ubyte]; | |
} | |
table Response { | |
message: [Object]; | |
code: Code; | |
signature: Signature; | |
} | |
root_type ConsensusEvent; |
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
include "key.fbs"; | |
namespace iroha; | |
///////////////////////////////////// | |
enum ProgrammingLanguage: ubyte {Java8} | |
table Chaincode { | |
// (ledger:domain:chaincode) is a primary key | |
code_name: string (required, key); // sorted | |
domain_name: string (required); | |
ledger_name: string (required); | |
language: ProgrammingLanguage; | |
code: [ubyte]; // .class, whatever | |
} | |
///////////////////////////////////// | |
/// Key-Value object | |
table KeyValueObject { | |
key: string (key, required); // primary key, sorted | |
value: [ubyte]; // arbitrary data | |
} | |
///////////////////////////////////// | |
/// Permissions | |
table UserPermissionRoot { | |
ledger_add: bool; // ability to create new ledgers | |
ledger_remove: bool; // ability to remove ledgers | |
} | |
table UserPermissionLedger { | |
ledger_name: string (required, key); | |
domain_add: bool; // ability to add new domain | |
domain_remove: bool; // ability to remove existing domain | |
peer_add: bool; // ability to add new peer | |
peer_remove: bool; // ability to remove existing peer | |
user_add: bool; // ability to create new user account | |
user_remove: bool; // ability to remove user account | |
user_give_permission: bool; // ability to give permissions to user globally | |
} | |
table UserPermissionDomain { | |
// identify domain: | |
domain_name: string (key, required); // sorted | |
ledger_name: string (required); | |
user_give_permission: bool; // ability to give permissions to user in this domain | |
user_add: bool; // ability to add existing user to domain | |
user_remove: bool; // ability to remove existing user from domain | |
} | |
table UserPermissionAsset { | |
// identify asset by its primary key: | |
asset_name: string (key, required); // sorted | |
domain_name: string (required); | |
ledger_name: string (required); | |
transfer: bool; // ability to transfer an asset | |
add: bool; // ability to add some amount to account | |
remove: bool; // ability to remove some amount from account | |
create: bool; // ability to create new asset | |
} | |
union UserPermission {UserPermissionRoot, UserPermissionLedger, UserPermissionDomain, UserPermissionAsset} | |
///////////////////////////////////// | |
/// Peer | |
table Peer { | |
publicKey: PublicKey (required); // sorted; primary key. | |
ip: string; | |
trust: double; | |
active: bool; | |
join_network: bool; | |
join_validation: bool; | |
} | |
///////////////////////////////////// | |
table Signature { | |
publicKey: PublicKey; | |
signature: [ubyte]; // signature is sign(hash + timestamp) | |
timestamp: ulong; | |
} |
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
include "key.fbs"; | |
include "commands.fbs"; | |
include "primitives.fbs"; | |
namespace iroha; | |
table Transaction { | |
creatorPubKey: PublicKey (required); | |
command: Command; | |
signatures: [Signature]; | |
hash: [ubyte]; | |
attachment: Attachment; | |
} | |
table Attachment { | |
mime: string; | |
data: [ubyte]; | |
} | |
root_type Transaction; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
in
command.fbs
Is it needed?
Do you not need following that?
( https://gist.github.com/takemiyamakoto/81364b706e90c3f6cf99d355d5a69d79#gistcomment-2030182 )
Activate peer (
isActive
->true
)Stop peer (
isActive
->false
)