Skip to content

Commit 344db5c

Browse files
authored
Merge pull request #4 from zoobc/mempool-tx-account
Mempool tx account
2 parents 4949b31 + e99a5b9 commit 344db5c

File tree

8 files changed

+147
-25
lines changed

8 files changed

+147
-25
lines changed

model/account.proto

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,26 @@ option go_package = "github.com/zoobc/zoobc-core/common/model";
66

77
// Account represent the transaction data structure stored in the database
88
message Account {
9-
bytes AccountID = 1;
9+
bytes ID = 1;
1010
int32 AccountType = 2;
11-
string Account = 3;
11+
string Address = 3;
1212
}
1313

1414
message GetAccountRequest {
1515
// Fetch Account by its ID
16-
uint32 AccountID = 1;
17-
// Fetch Account by its account name (note: this in case of zoobc account type is the public key)
18-
uint32 Account = 2;
16+
uint32 ID = 1;
17+
// Fetch Account by its account address (note: this in case of zoobc account type is the public key)
18+
uint32 Address = 2;
1919
}
2020

21-
message GetAccountResponse {
22-
repeated Account Account = 3;
21+
message GetAccountsRequest {
22+
// Fetch Accounts by its account type
23+
uint32 AccountType = 2;
24+
}
25+
26+
message GetAccountsResponse {
27+
// Number of accounts returned
28+
uint32 AccountSize = 1;
29+
// Accounts returned
30+
repeated Account Account = 2;
2331
}

model/accountBalance.proto

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
syntax="proto3";
2+
3+
package model;
4+
5+
option go_package = "github.com/zoobc/zoobc-core/common/model";
6+
7+
// AccountBalance represent the transaction data structure stored in the database
8+
message AccountBalance {
9+
bytes ID = 1;
10+
uint32 BlockHeight = 2;
11+
int64 SpendableBalance = 3;
12+
int64 Balance = 4;
13+
int64 PopRevenue = 5;
14+
}
15+
16+
message GetAccountBalanceRequest {
17+
// Fetch AccountBalance by its ID
18+
uint32 ID = 1;
19+
// Fetch AccountBalance by its Block height
20+
uint32 BlockHeight = 2;
21+
}
22+
23+
message GetAccountBalancesRequest {
24+
// Fetch AccountBalance by its balance (account balance < BalanceLowerThan)
25+
uint32 BalanceLowerThan = 1;
26+
// Fetch AccountBalance by its balance (account balance > BalanceHigherThan)
27+
uint32 BalanceHigherThan = 2;
28+
// Fetch AccountBalance by its spendablebalance (account spendablebalance < BalanceLowerThan)
29+
uint32 SpendableBalanceLowerThan = 3;
30+
// Fetch AccountBalance by its spendablebalance (account spendablebalance > BalanceHigherThan)
31+
uint32 SpendableBalanceHigherThan = 4;
32+
// Fetch AccountBalance by its spendablebalance (account spendablebalance < BalanceLowerThan)
33+
uint32 PopRevenueBalanceLowerThan = 5;
34+
// Fetch AccountBalance by its popRevenuebalance (account popRevenuebalance > BalanceHigherThan)
35+
uint32 PopRevenueBalanceHigherThan = 6;
36+
// Fetch AccountBalance by its Block height
37+
uint32 BlockHeight = 7;
38+
}
39+
40+
message GetAccountBalancesResponse {
41+
// Number of accounts returned
42+
uint32 AccountBalanceSize = 1;
43+
// AccountBalances returned
44+
repeated AccountBalance AccountBalance = 2;
45+
}

model/mempool.proto

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ package model;
55
option go_package = "github.com/zoobc/zoobc-core/common/model";
66

77
// Mempool represent the mempool data structure stored in the database
8-
message Mempool {
9-
bytes TransactionID = 1;
8+
message MempoolTransaction {
9+
bytes ID = 1;
1010
int32 SenderAccountType = 2;
1111
string SenderAccount = 3;
1212
int32 RecipientAccountType = 4;
@@ -22,18 +22,26 @@ message Mempool {
2222
// TransactionBody
2323
}
2424

25-
message GetMempoolsRequest {
25+
message GetMempoolTransactionRequest {
26+
// Fetch Mempool Transaction by its ID
27+
uint32 ID = 1;
28+
// Fetch Mempool Transaction by its signature
29+
uint32 Signature = 2;
30+
}
31+
32+
message GetMempoolTransactionsRequest {
2633
// Number of Mempool transactions to fetch
2734
uint32 MempoolSize = 1;
2835
// Fetch Mempool transactions from timestamp
2936
int64 From = 2;
3037
// Fetch Mempool transactions to timestamp
3138
int64 To = 3;
39+
3240
}
3341

34-
message GetMempoolsResponse {
42+
message GetMempoolTransactionsResponse {
3543
// Number of transactions returned
3644
uint32 MempoolSize = 1;
37-
// Mempool Transactions returned
38-
repeated Mempool MempoolTransactions = 3;
45+
// Mempool transactions returned
46+
repeated MempoolTransaction MempoolTransactions = 2;
3947
}

model/transaction.proto

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ option go_package = "github.com/zoobc/zoobc-core/common/model";
66

77
// Transaction represent the transaction data structure stored in the database
88
message Transaction {
9-
bytes TransactionID = 1;
9+
bytes ID = 1;
1010
int64 BlockID = 2;
1111
uint32 BlockHeight = 3;
1212
string SenderAccountID = 4;
@@ -21,18 +21,38 @@ message Transaction {
2121
// TransactionBody
2222
}
2323

24-
message GetTransactionsRequest {
24+
message GetTransactionRequest {
2525
// Fetch Transaction by its ID
26-
uint32 TransactionID = 1;
27-
// Fetch Transaction by its Block ID
28-
uint32 BlockID = 2;
29-
// Fetch Transaction by block Height
30-
int64 BlockHeight = 3;
26+
uint32 ID = 1;
27+
// Fetch Transaction by its signature
28+
uint32 Signature = 4;
29+
// Fetch Transaction by its hash
30+
uint32 TransactionHash = 5;
31+
}
32+
33+
message GetTransactionsRequest {
34+
// Fetch Transaction at block Height
35+
int64 BlockHeight = 1;
36+
// Fetch Transactions lower than block height
37+
int64 FromHeight = 2;
38+
// Fetch Transactions higher than block height
39+
int64 ToHeight = 3;
40+
// Fetch Transactions by sender
41+
string SenderAccountID = 4;
42+
// Fetch Transactions by recipient
43+
string RecipientAccountID = 5;
44+
// Fetch Transactions by transaction type
45+
uint32 TransactionType = 6;
46+
// Fetch Transactions lower than a given block timestamp (note: relative query will lookup the block table to get timestaps)
47+
int64 FromTimestamp = 7;
48+
// Fetch Transactions higher than a given block timestamp (note: relative query will lookup the block table to get timestaps)
49+
int64 ToTimestamp = 8;
50+
3151
}
3252

3353
message GetTransactionsResponse {
3454
// Number of transactions returned
3555
uint32 TransactionSize = 1;
36-
// Transaction returned
37-
repeated Transaction Transactions = 3;
56+
// Transaction transactions returned
57+
repeated Transaction Transactions = 2;
3858
}

service/account.proto

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,15 @@ import "model/account.proto";
99

1010
// AccountService represent request on db Account
1111
service AccountService {
12-
rpc GetAccounts(model.GetAccountRequest) returns (model.GetAccountResponse) {
12+
rpc GetAccounts(model.GetAccountsRequest) returns (model.GetAccountsResponse) {
1313
option (google.api.http) = {
14-
get: "/v1/account/GetAccount"
14+
get: "/v1/account/GetAccounts"
1515
};
1616
}
17+
18+
rpc GetAccount(model.GetAccountRequest) returns (model.Account) {
19+
option (google.api.http) = {
20+
get: "/v1/account/GetAccount"
21+
};
22+
}
1723
}

service/accountBalance.proto

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
syntax="proto3";
2+
3+
package service;
4+
5+
option go_package = "github.com/zoobc/zoobc-core/common/service";
6+
7+
import "google/api/annotations.proto";
8+
import "model/accountBalance.proto";
9+
10+
// AccountBalanceService represent request on db Account
11+
service AccountBalanceService {
12+
rpc GetAccountBalances(model.GetAccountBalancesRequest) returns (model.GetAccountBalancesResponse) {
13+
option (google.api.http) = {
14+
get: "/v1/account/GetAccountBalances"
15+
};
16+
}
17+
18+
rpc GetAccountBalance(model.GetAccountBalanceRequest) returns (model.AccountBalance) {
19+
option (google.api.http) = {
20+
get: "/v1/account/GetAccountBalance"
21+
};
22+
}
23+
}

service/mempool.proto

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,15 @@ import "model/mempool.proto";
99

1010
// MempoolService represent request on db Mempool
1111
service MempoolService {
12-
rpc GetMempoolTransactions(model.GetMempoolsRequest) returns (model.GetMempoolsResponse) {
12+
rpc GetMempoolTransactions(model.GetMempoolTransactionsRequest) returns (model.GetMempoolTransactionsResponse) {
1313
option (google.api.http) = {
1414
get: "/v1/mempool/GetMempoolTransactions"
1515
};
1616
}
17+
18+
rpc GetMempoolTransaction(model.GetMempoolTransactionRequest) returns (model.MempoolTransaction) {
19+
option (google.api.http) = {
20+
get: "/v1/mempool/GetMempoolTransaction"
21+
};
22+
}
1723
}

service/transaction.proto

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,10 @@ service TransactionService {
1414
get: "/v1/transaction/GetTransactions"
1515
};
1616
}
17+
18+
rpc GetTransaction(model.GetTransactionRequest) returns (model.Transaction) {
19+
option (google.api.http) = {
20+
get: "/v1/transaction/GetTransaction"
21+
};
22+
}
1723
}

0 commit comments

Comments
 (0)