Skip to content

Commit

Permalink
removed computor index from qchain; added transfer txs filtering by s…
Browse files Browse the repository at this point in the history
…tart and end tick
  • Loading branch information
0xluk committed Mar 12, 2024
1 parent bcd2172 commit d8858e4
Show file tree
Hide file tree
Showing 14 changed files with 413 additions and 746 deletions.
836 changes: 315 additions & 521 deletions protobuff/archive.pb.go

Large diffs are not rendered by default.

85 changes: 0 additions & 85 deletions protobuff/archive.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 5 additions & 17 deletions protobuff/archive.proto
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ message QuorumDiff {
}

message QuorumTickStructure {
uint32 computor_index = 1;
uint32 epoch = 2;
uint32 tick_number = 3;
uint64 timestamp = 4;
Expand Down Expand Up @@ -128,11 +127,8 @@ message IdentityInfo {

message TransferTransactionsPerTick {
uint32 tick_number = 1;
Transactions transactions = 2;
}

message TransferTransactions {
repeated TransferTransactionsPerTick transfer_transactions_per_tick = 1;
string identity = 2;
Transactions transactions = 3;
}

message GetIdentityInfoRequest {
Expand Down Expand Up @@ -163,21 +159,14 @@ message GetSkippedTicksResponse {
repeated SkippedTicksInterval skipped_ticks = 1;
}

message GetTransferTransactionsRequest {
string identity = 1;
}

message GetTransferTransactionsResponse {
TransferTransactions transfer_transactions = 1;
}

message GetTransferTransactionsPerTickRequest {
string identity = 1;
uint32 tick_number = 2;
uint32 start_tick = 2;
uint32 end_tick = 3;
}

message GetTransferTransactionsPerTickResponse {
TransferTransactionsPerTick transfer_transactions_per_tick = 1;
repeated TransferTransactionsPerTick transfer_transactions_per_tick = 1;
}

message GetQChainHashRequest {
Expand All @@ -198,7 +187,6 @@ service ArchiveService {
rpc GetLastProcessedTick(GetLastProcessedTickRequest) returns (GetLastProcessedTickResponse);
rpc SendRawTransaction(SendRawTransactionRequest) returns (SendRawTransactionResponse);
rpc GetSkippedTicks(GetSkippedTicksRequest) returns (GetSkippedTicksResponse);
rpc GetTransferTransactions(GetTransferTransactionsRequest) returns (GetTransferTransactionsResponse);
rpc GetTransferTransactionsPerTick(GetTransferTransactionsPerTickRequest) returns (GetTransferTransactionsPerTickResponse);
rpc GetQChainHash(GetQChainHashRequest) returns (GetQChainHashResponse);
}
37 changes: 0 additions & 37 deletions protobuff/archive_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 1 addition & 12 deletions rpc/rpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,20 +187,9 @@ func (s *Server) GetSkippedTicks(ctx context.Context, req *protobuff.GetSkippedT
return &protobuff.GetSkippedTicksResponse{SkippedTicks: ticks.SkippedTicks}, nil
}

func (s *Server) GetTransferTransactions(ctx context.Context, req *protobuff.GetTransferTransactionsRequest) (*protobuff.GetTransferTransactionsResponse, error) {
txs, err := s.store.GetTransferTransactions(ctx, req.Identity)
if err != nil {
return nil, status.Errorf(codes.Internal, "getting transfer transactions: %v", err)
}

return &protobuff.GetTransferTransactionsResponse{TransferTransactions: txs}, nil
}
func (s *Server) GetTransferTransactionsPerTick(ctx context.Context, req *protobuff.GetTransferTransactionsPerTickRequest) (*protobuff.GetTransferTransactionsPerTickResponse, error) {
txs, err := s.store.GetTransferTransactionsPerTick(ctx, req.Identity, uint64(req.TickNumber))
txs, err := s.store.GetTransferTransactions(ctx, req.Identity, uint64(req.GetStartTick()), uint64(req.GetEndTick()))
if err != nil {
if errors.Cause(err) == store.ErrNotFound {
return nil, status.Errorf(codes.NotFound, "transfer transactions for specified identity, tick pair not found")
}
return nil, status.Errorf(codes.Internal, "getting transfer transactions: %v", err)
}

Expand Down
29 changes: 4 additions & 25 deletions store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,12 +347,11 @@ func (s *PebbleStore) PutTransferTransactionsPerTick(ctx context.Context, identi
return nil
}

func (s *PebbleStore) GetTransferTransactions(ctx context.Context, identity string) (*protobuff.TransferTransactions, error) {
func (s *PebbleStore) GetTransferTransactions(ctx context.Context, identity string, startTick, endTick uint64) ([]*protobuff.TransferTransactionsPerTick, error) {
partialKey := identityTransferTransactions(identity)
upperBound := append(partialKey, []byte(strconv.FormatUint(maxTickNumber, 10))...)
iter, err := s.db.NewIter(&pebble.IterOptions{
LowerBound: partialKey,
UpperBound: upperBound,
LowerBound: binary.BigEndian.AppendUint64(partialKey, startTick),
UpperBound: binary.BigEndian.AppendUint64(partialKey, endTick+1),
})
if err != nil {
return nil, errors.Wrap(err, "creating iter")
Expand All @@ -377,27 +376,7 @@ func (s *PebbleStore) GetTransferTransactions(ctx context.Context, identity stri
transferTxs = append(transferTxs, &perTick)
}

return &protobuff.TransferTransactions{TransferTransactionsPerTick: transferTxs}, nil
}

func (s *PebbleStore) GetTransferTransactionsPerTick(ctx context.Context, identity string, tickNumber uint64) (*protobuff.TransferTransactionsPerTick, error) {
key := identityTransferTransactionsPerTickKey(identity, tickNumber)
value, closer, err := s.db.Get(key)
if err != nil {
if errors.Is(err, pebble.ErrNotFound) {
return nil, ErrNotFound
}

return nil, errors.Wrap(err, "getting transfer tx per tick")
}
defer closer.Close()

var perTick protobuff.TransferTransactionsPerTick
if err := protojson.Unmarshal(value, &perTick); err != nil {
return nil, errors.Wrap(err, "unmarshalling transfer tx per tick to protobuff type")
}

return &perTick, nil
return transferTxs, nil
}

func (s *PebbleStore) PutQChainDigest(ctx context.Context, tickNumber uint64, digest []byte) error {
Expand Down
Loading

0 comments on commit d8858e4

Please sign in to comment.