46 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Protocol Buffer
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Protocol Buffer
		
	
	
	
	
	
syntax = "proto3";
 | 
						||
 | 
						||
package bdledger.api;
 | 
						||
 | 
						||
option go_package = "bdware.org/bdledger/pkg/api/grpc/proto";
 | 
						||
option java_package = "bdledger.api.grpc.common";
 | 
						||
option java_outer_classname = "CommonProto";
 | 
						||
option java_multiple_files = true;
 | 
						||
 | 
						||
 | 
						||
 | 
						||
/* 事务类型 */
 | 
						||
enum TransactionType {
 | 
						||
  RECORD = 0; // 通用数据记录
 | 
						||
  MESSAGE = 1; // 消息
 | 
						||
  CONTRACT_CREATION = 2; // 合约创建
 | 
						||
  CONTRACT_INVOCATION = 3; // 合约调用
 | 
						||
  CONTRACT_STATUS = 4; // 合约状态
 | 
						||
}
 | 
						||
 | 
						||
message Transaction {
 | 
						||
  bytes block_hash = 1;     // 事务所在的区块的哈希,当事务处于待确认状态时为`null`
 | 
						||
  uint32 index = 2;         // 事务在区块中的位置 index,当事务处于待确认状态时为`null`
 | 
						||
  bytes hash = 3;           // 事务的哈希
 | 
						||
  TransactionType type = 4; // 事务类型
 | 
						||
  bytes from = 5;           // 发送账户地址
 | 
						||
  uint64 nonce = 6;         // 这条事务之前发送者所发送的事务数量
 | 
						||
  bytes to = 7;             // 接收账户地址,或者调用的合约地址,或者`null`如为合约创建
 | 
						||
  bytes data = 8;           // 数据或合约代码
 | 
						||
  bytes v = 9;              // ECDSA recovery id
 | 
						||
  bytes r = 10;             // ECDSA signature r
 | 
						||
  bytes s = 11;             // ECDSA signature s
 | 
						||
}
 | 
						||
 | 
						||
message Block {
 | 
						||
  bytes hash = 1;                         // 区块的哈希,当区块处于待确认状态时为`null`
 | 
						||
  repeated bytes parent_hashes = 2;       // 父区块的哈希
 | 
						||
  repeated bytes witnesses = 3;           // 见证者账户地址
 | 
						||
  int64 timestamp = 4;                    // 区块产生时的 UNIX 时间戳,单位为秒
 | 
						||
  uint64 size = 5;                        // 区块大小的字节数
 | 
						||
  uint32 transaction_count = 6;           // 区块包含的事务数量
 | 
						||
  bytes transactions_root = 7;            // 区块的事务默克尔树根
 | 
						||
  repeated Transaction transactions = 8;  // 事务对象的数组,或为空
 | 
						||
  repeated bytes transaction_hashes = 9; // 20字节的交易哈希的数组,或为空
 | 
						||
}
 |