dncurrency/api/flatbuffers/nanoapi.fbs
cryptocode 9d9d377fce
IPC 2.0 (#2487)
* IPC 2.0

* Use nano::locked for confirmation subscriber vector

* Remove unused local

* Update toml tests, fix some const issues

* Some access permission improvements

* Comments and nano::locked improvements

* Guilherme review feedback: formatting, advanced cmake flags, disallow deny for roles

* Wesley feedback

* Try to please win build on CI

* Add generated file to git ignore

* install api/flatbuffers/* depending on platform

* correct path for api in MacOS app

* add api to docker image

Co-authored-by: Russel Waters <vaelstrom@gmail.com>
2020-02-21 00:02:44 +01:00

256 lines
6.4 KiB
Text
Executable file

/*
Flatbuffer schema for the Nano IPC API.
Please see https://google.github.io/flatbuffers/md__schemas.html for recommended schema evolution practices.
*/
namespace nanoapi;
/** Returns the voting weight for the given account */
table AccountWeight {
/** A nano_ address */
account: string (required);
}
/** Response to AccountWeight */
table AccountWeightResponse {
/** Voting weight as a decimal number*/
voting_weight: string (required);
}
/**
* Block subtype for state blocks.
* Note that the node makes no distinction between open and receive subtypes.
*/
enum BlockSubType: byte {
invalid = 0,
receive,
send,
change,
epoch
}
/** Block union */
union Block {
BlockState,
BlockOpen,
BlockReceive,
BlockSend,
BlockChange
}
table BlockOpen {
/** Hash of this block */
hash: string;
/** Account being opened */
account: string;
/** Hash of send block */
source: string;
/** Representative address */
representative: string;
/** Signature as a hex string */
signature: string;
/** Work is a hex string representing work. This is a string as the work value may not fit in native numeric types. */
work: string;
}
table BlockReceive {
/** Hash of this block */
hash: string;
/** Hash of previous block */
previous: string;
/** Source hash */
source: string;
/** Signature as a hex string */
signature: string;
/** Work is a hex string representing work. This is a string as the work value may not fit in native numeric types. */
work: string;
}
table BlockSend {
/** Hash of this block */
hash: string;
/** Hash of previous block */
previous: string;
/** Destination account */
destination: string;
/** Balance in raw */
balance: string;
/** Signature as a hex string */
signature: string;
/** Work is a hex string representing work. This is a string as the work value may not fit in native numeric types. */
work: string;
}
table BlockChange {
/** Hash of this block */
hash: string;
/** Hash of previous block */
previous: string;
/** Representative address */
representative: string;
/** Signature as a hex string */
signature: string;
/** Work is a hex string representing work. This is a string as the work value may not fit in native numeric types. */
work: string;
}
table BlockState {
/** Hash of this block */
hash: string;
/** Account as nano_ string */
account: string;
/** Hash of previous block */
previous: string;
/** Representative as nano_ string */
representative: string;
/** Balance in raw */
balance: string;
/** Link as a hex string */
link: string;
/** Link interpreted as a nano_ address */
link_as_account: string;
/** Signature as a hex string */
signature: string;
/** Work is a hex string representing work. This is a string as the work value may not fit in native numeric types. */
work: string;
/** Subtype of this state block */
subtype: BlockSubType;
}
/** Information about a block */
table BlockInfo {
block: Block;
}
/** Called by a service (usually an external process) to register itself */
table ServiceRegister {
service_name: string;
}
/** Request the node to send an EventServiceStop event to the given service */
table ServiceStop {
/** Name of service to stop. */
service_name: string (required);
/** If true, restart the service */
restart: bool = false;
}
/**
* Subscribe or unsubscribe to EventServiceStop events.
* The service must first have registered itself on the same session.
*/
table TopicServiceStop {
/** Set to true to unsubscribe */
unsubscribe: bool;
}
/** Sent to a service to request it to stop itself */
table EventServiceStop {
}
/**
* All subscriptions are acknowledged. Use the envelope's correlation id
* if you need to match the ack with the subscription.
*/
table EventAck {
}
/** Requested confirmation type */
enum TopicConfirmationTypeFilter : byte { all, active, active_quorum, active_confirmation_height, inactive }
/** Type of block confirmation */
enum TopicConfirmationType : byte { active_quorum, active_confirmation_height, inactive }
/** Subscribe or unsubscribe to block confirmations of type EventConfirmation */
table TopicConfirmation {
/** Set to true to unsubscribe */
unsubscribe: bool;
options: TopicConfirmationOptions;
}
table TopicConfirmationOptions {
confirmation_type_filter: TopicConfirmationTypeFilter = all;
all_local_accounts: bool;
accounts: [string];
include_block: bool = true;
include_election_info: bool = true;
}
/** Notification of block confirmation. */
table EventConfirmation {
confirmation_type: TopicConfirmationType;
account: string;
amount: string;
hash: string;
block: Block;
election_info: ElectionInfo;
}
table ElectionInfo {
duration: uint64;
time: uint64;
tally: string;
request_count: uint64;
block_count: uint64;
voter_count: uint64;
}
/** Error response. All fields are optional */
table Error {
/** Error code. May be negative or positive. */
code: int;
/** Error category code */
category: int;
/** Error message */
message: string;
}
/**
* A general purpose success response for messages that don't return a message.
* The response includes an optional message text.
*/
table Success {
message: string;
}
/** IsAlive request and response. Any node issues will be reported through an error in the envelope. */
table IsAlive {
}
/**
* A union is the idiomatic way in Flatbuffers to transmit messages of multiple types.
* All top-level message types (including response types) must be listed here.
* @warning To ensure compatibility, only append and deprecate message types.
*/
union Message {
Error,
Success,
IsAlive,
EventAck,
BlockInfo,
AccountWeight,
AccountWeightResponse,
TopicConfirmation,
EventConfirmation,
ServiceRegister,
ServiceStop,
TopicServiceStop,
EventServiceStop
}
/**
* All messages are wrapped in an envelope which contains information such as
* message type, credentials and correlation id. For responses, the message may be an Error.
*/
table Envelope {
/** Milliseconds since epoch when the message was sent. */
time: uint64;
/** An optional and arbitrary string used for authentication. The corresponding http header for api keys is "nano-api-key" */
credentials: string;
/** Correlation id is an optional and arbitrary string. The corresponding http header is "nano-correlation-id" */
correlation_id: string;
/** The contained message. A 'message_type' property will be automatically added to JSON messages. */
message: Message;
}
/** The Envelope is the type marshalled over IPC, and also serves as the top-level JSON type */
root_type Envelope;