Skip to content

Commit

Permalink
Merge pull request #61 from qubic/main
Browse files Browse the repository at this point in the history
Update dev with changes from main
  • Loading branch information
LINCKODE authored Sep 25, 2024
2 parents 9bd17f7 + c13501b commit c16e899
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 27 deletions.
20 changes: 15 additions & 5 deletions rpc/rpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,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 @@ -578,6 +584,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 c16e899

Please sign in to comment.