Skip to content

Commit

Permalink
Merge branch 'dev' into compression
Browse files Browse the repository at this point in the history
# Conflicts:
#	protobuff/archive.pb.go
#	protobuff/archive_grpc.pb.go
  • Loading branch information
LINCKODE committed Sep 27, 2024
2 parents e271222 + c16e899 commit 6a46dfa
Show file tree
Hide file tree
Showing 7 changed files with 945 additions and 938 deletions.
1,638 changes: 817 additions & 821 deletions protobuff/archive.pb.go

Large diffs are not rendered by default.

84 changes: 42 additions & 42 deletions protobuff/archive.pb.gw.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion protobuff/archive.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
syntax = "proto3";

package qubic.archiver.archive.pb;
package org.qubic.archiver.proto;

option go_package = "github.com/qubic/go-archiver/protobuff/";
import "google/api/annotations.proto";
Expand Down
115 changes: 68 additions & 47 deletions protobuff/archive_grpc.pb.go

Large diffs are not rendered by default.

20 changes: 15 additions & 5 deletions rpc/rpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,21 @@ func NewServer(listenAddrGRPC, listenAddrHTTP string, syncThreshold int, chainTi
}

func getTransactionInfo(ctx context.Context, pebbleStore *store.PebbleStore, transactionId string, tickNumber uint32) (*TransactionInfo, error) {

txStatus, err := pebbleStore.GetTransactionStatus(ctx, transactionId)
tickData, err := pebbleStore.GetTickData(ctx, tickNumber)
if err != nil {
return nil, errors.Wrap(err, "getting transaction status")
return nil, errors.Wrap(err, "getting tick data")
}

tickData, err := pebbleStore.GetTickData(ctx, tickNumber)
txStatus, err := pebbleStore.GetTransactionStatus(ctx, transactionId)
if err != nil {
return nil, errors.Wrap(err, "getting tick data")
if errors.Is(err, store.ErrNotFound) {
return &TransactionInfo{
timestamp: tickData.Timestamp,
moneyFlew: false,
}, nil
}

return nil, errors.Wrap(err, "getting transaction status")
}

return &TransactionInfo{
Expand Down Expand Up @@ -642,6 +648,10 @@ func (s *Server) GetTransactionStatus(ctx context.Context, req *protobuff.GetTra
return nil, status.Errorf(codes.Internal, "getting tx status: %v", err)
}

if txStatus.MoneyFlew == false {
return &protobuff.GetTransactionStatusResponse{TransactionStatus: &protobuff.TransactionStatus{TxId: tx.TxId, MoneyFlew: false}}, nil
}

if tx.InputType == 1 && tx.InputSize == 1000 && tx.DestId == "EAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVWRF" {
moneyFlew, err := recomputeSendManyMoneyFlew(tx)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions rpc/v2_endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ func (s *Server) GetSendManyTransactionV2(ctx context.Context, req *protobuff.Ge
func (s *Server) GetIdentityTransfersInTickRangeV2(ctx context.Context, req *protobuff.GetTransferTransactionsPerTickRequestV2) (*protobuff.GetIdentityTransfersInTickRangeResponseV2, error) {
txs, err := s.store.GetTransferTransactions(ctx, req.Identity, uint64(req.GetStartTick()), uint64(req.GetEndTick()))
if err != nil {
return nil, status.Errorf(codes.Internal, "getting transfer transactions: %v", err)
return nil, status.Errorf(codes.Internal, "getting transfer transactions: %s", err.Error())
}

var totalTransactions []*protobuff.PerTickIdentityTransfers
Expand All @@ -330,7 +330,7 @@ func (s *Server) GetIdentityTransfersInTickRangeV2(ctx context.Context, req *pro
for _, transaction := range transactionsPerTick.Transactions {
transactionInfo, err := getTransactionInfo(ctx, s.store, transaction.TxId, transaction.TickNumber)
if err != nil {
return nil, status.Errorf(codes.Internal, "getting transaction info: %v", err)
return nil, status.Errorf(codes.Internal, "Got Err: %s when getting transaction info for tx id: %s", err.Error(), transaction.TxId)
}

if req.ScOnly == true && transaction.GetInputType() == 0 {
Expand Down
20 changes: 0 additions & 20 deletions store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,26 +300,6 @@ func (s *PebbleStore) GetLastProcessedTick(ctx context.Context) (*protobuff.Proc
}
defer closer.Close()

// handle old data format, to be removed in the future
if len(value) == 8 {
tickNumber := uint32(binary.LittleEndian.Uint64(value))
ticksPerEpoch, err := s.GetLastProcessedTicksPerEpoch(ctx)
if err != nil {
return nil, errors.Wrap(err, "getting last processed ticks per epoch")
}
var epoch uint32
for e, tick := range ticksPerEpoch {
if tick == tickNumber {
epoch = e
break
}
}
return &protobuff.ProcessedTick{
TickNumber: tickNumber,
Epoch: epoch,
}, nil
}

var lpt protobuff.ProcessedTick
if err := proto.Unmarshal(value, &lpt); err != nil {
return nil, errors.Wrap(err, "unmarshalling lpt to protobuff type")
Expand Down

0 comments on commit 6a46dfa

Please sign in to comment.