diff --git a/app/appmessage/rpc_get_accepting_block_of_tx.go b/app/appmessage/rpc_get_accepting_block_of_tx.go index 767b49e34..97bb39c10 100644 --- a/app/appmessage/rpc_get_accepting_block_of_tx.go +++ b/app/appmessage/rpc_get_accepting_block_of_tx.go @@ -4,7 +4,8 @@ package appmessage // its respective RPC message type GetAcceptingBlockOfTxRequestMessage struct { baseMessage - TxID string + TxID string + IncludeTransactions bool } // Command returns the protocol command string for the message diff --git a/app/appmessage/rpc_get_accepting_blockhashes_of_txs.go b/app/appmessage/rpc_get_accepting_blockhashes_of_txs.go index 31883eddb..8b08ab346 100644 --- a/app/appmessage/rpc_get_accepting_blockhashes_of_txs.go +++ b/app/appmessage/rpc_get_accepting_blockhashes_of_txs.go @@ -3,8 +3,8 @@ package appmessage // TxIDBlockHashPair is an appmessage corresponding to // its respective RPC message type TxIDBlockHashPair struct { - TxID string - Hash string + TxID string + Hash string } // GetAcceptingBlockHashesOfTxsRequestMessage is an appmessage corresponding to diff --git a/app/appmessage/rpc_get_accepting_blocks_of_txs.go b/app/appmessage/rpc_get_accepting_blocks_of_txs.go index 22cb24bda..480677b03 100644 --- a/app/appmessage/rpc_get_accepting_blocks_of_txs.go +++ b/app/appmessage/rpc_get_accepting_blocks_of_txs.go @@ -3,15 +3,16 @@ package appmessage // TxIDBlockPair is an appmessage corresponding to // its respective RPC message type TxIDBlockPair struct { - TxID string - Block RPCBlock + TxID string + Block *RPCBlock } // GetAcceptingBlocksOfTxsRequestMessage is an appmessage corresponding to // its respective RPC message type GetAcceptingBlocksOfTxsRequestMessage struct { baseMessage - TxIDs []string + TxIDs []string + IncludeTransactions bool } // Command returns the protocol command string for the message diff --git a/app/rpc/rpchandlers/get_accepting_block_of_tx.go b/app/rpc/rpchandlers/get_accepting_block_of_tx.go new file mode 100644 index 000000000..69fcee351 --- /dev/null +++ b/app/rpc/rpchandlers/get_accepting_block_of_tx.go @@ -0,0 +1,64 @@ +package rpchandlers + +import ( + "github.com/kaspanet/kaspad/app/appmessage" + "github.com/kaspanet/kaspad/app/rpc/rpccontext" + "github.com/kaspanet/kaspad/domain/consensus/model/externalapi" + "github.com/kaspanet/kaspad/domain/consensus/utils/consensushashing" + "github.com/kaspanet/kaspad/infrastructure/network/netadapter/router" + + "github.com/pkg/errors" +) + +// HandleGetAcceptingBlockOfTx handles the respectively named RPC command +func HandleGetAcceptingBlockOfTx(context *rpccontext.Context, _ *router.Router, request appmessage.Message) (appmessage.Message, error) { + if !context.Config.TXIndex { + errorMessage := &appmessage.GetAcceptingBlockHashOfTxResponseMessage{} + errorMessage.Error = appmessage.RPCErrorf("Method unavailable when kaspad is run without --txindex") + return errorMessage, nil + } + + getAcceptingBlockHashOfTxRequest := request.(*appmessage.GetAcceptingBlockOfTxRequestMessage) + + domainTxID, err := externalapi.NewDomainTransactionIDFromString(getAcceptingBlockHashOfTxRequest.TxID) + if err != nil { + rpcError := &appmessage.RPCError{} + if !errors.As(err, &rpcError) { + return nil, err + } + errorMessage := &appmessage.GetAcceptingBlockOfTxResponseMessage{} + errorMessage.Error = rpcError + return errorMessage, nil + } + + acceptingBlock, found, err := context.TXIndex.TXAcceptingBlock(domainTxID) + if err != nil { + rpcError := &appmessage.RPCError{} + if !errors.As(err, &rpcError) { + return nil, err + } + errorMessage := &appmessage.GetAcceptingBlockOfTxResponseMessage{} + errorMessage.Error = rpcError + return errorMessage, nil + } + if !found { + errorMessage := &appmessage.GetAcceptingBlockOfTxResponseMessage{} + errorMessage.Error = appmessage.RPCErrorf("Could not find accepting block in the txindex database for txID: %s", domainTxID.String()) + return errorMessage, nil + } + + rpcAcceptingBlock := appmessage.DomainBlockToRPCBlock(acceptingBlock) + err = context.PopulateBlockWithVerboseData(rpcAcceptingBlock, acceptingBlock.Header, acceptingBlock, getAcceptingBlockHashOfTxRequest.IncludeTransactions) + if err != nil { + if errors.Is(err, rpccontext.ErrBuildBlockVerboseDataInvalidBlock) { + errorMessage := &appmessage.GetAcceptingBlockOfTxResponseMessage{} + errorMessage.Error = appmessage.RPCErrorf("Block %s is invalid", consensushashing.BlockHash(acceptingBlock).String()) + return errorMessage, nil + } + return nil, err + } + + response := appmessage.NewGetAcceptingBlockOfTxResponse(rpcAcceptingBlock) + + return response, nil +} diff --git a/app/rpc/rpchandlers/get_accepting_block_hash_of_tx.go b/app/rpc/rpchandlers/get_accepting_blockhash_of_tx.go similarity index 92% rename from app/rpc/rpchandlers/get_accepting_block_hash_of_tx.go rename to app/rpc/rpchandlers/get_accepting_blockhash_of_tx.go index 3c6349386..f9497f342 100644 --- a/app/rpc/rpchandlers/get_accepting_block_hash_of_tx.go +++ b/app/rpc/rpchandlers/get_accepting_blockhash_of_tx.go @@ -25,7 +25,7 @@ func HandleGetAcceptingBlockHashOfTx(context *rpccontext.Context, _ *router.Rout if !errors.As(err, &rpcError) { return nil, err } - errorMessage := &appmessage.GetUTXOsByAddressesResponseMessage{} + errorMessage := &appmessage.GetAcceptingBlockHashOfTxResponseMessage{} errorMessage.Error = rpcError return errorMessage, nil } @@ -36,7 +36,7 @@ func HandleGetAcceptingBlockHashOfTx(context *rpccontext.Context, _ *router.Rout if !errors.As(err, &rpcError) { return nil, err } - errorMessage := &appmessage.GetUTXOsByAddressesResponseMessage{} + errorMessage := &appmessage.GetAcceptingBlockHashOfTxResponseMessage{} errorMessage.Error = rpcError return errorMessage, nil } diff --git a/app/rpc/rpchandlers/get_accepting_blockhashes_of_txs.go b/app/rpc/rpchandlers/get_accepting_blockhashes_of_txs.go new file mode 100644 index 000000000..46b3331d6 --- /dev/null +++ b/app/rpc/rpchandlers/get_accepting_blockhashes_of_txs.go @@ -0,0 +1,57 @@ +package rpchandlers + +import ( + "github.com/kaspanet/kaspad/app/appmessage" + "github.com/kaspanet/kaspad/app/rpc/rpccontext" + "github.com/kaspanet/kaspad/domain/consensus/model/externalapi" + "github.com/kaspanet/kaspad/infrastructure/network/netadapter/router" + + "github.com/pkg/errors" +) + +// HandleGetAcceptingBlockHashesOfTxs handles the respectively named RPC command +func HandleGetAcceptingBlockHashesOfTxs(context *rpccontext.Context, _ *router.Router, request appmessage.Message) (appmessage.Message, error) { + var err error + + if !context.Config.TXIndex { + errorMessage := &appmessage.GetAcceptingBlockHashesOfTxsResponseMessage{} + errorMessage.Error = appmessage.RPCErrorf("Method unavailable when kaspad is run without --txindex") + return errorMessage, nil + } + + getAcceptingBlockHashesOfTxsRequest := request.(*appmessage.GetAcceptingBlockHashesOfTxsRequestMessage) + + domainTxIDs := make([]*externalapi.DomainTransactionID, len(getAcceptingBlockHashesOfTxsRequest.TxIDs)) + for i := range domainTxIDs { + domainTxIDs[i], err = externalapi.NewDomainTransactionIDFromString(getAcceptingBlockHashesOfTxsRequest.TxIDs[i]) + if err != nil { + errorMessage := &appmessage.GetAcceptingBlockHashesOfTxsResponseMessage{} + errorMessage.Error = appmessage.RPCErrorf("error parsing txID: %s", getAcceptingBlockHashesOfTxsRequest.TxIDs[i]) + return errorMessage, nil + } + } + acceptingBlockHashes, _, err := context.TXIndex.TXAcceptingBlockHashes(domainTxIDs) + if err != nil { + rpcError := &appmessage.RPCError{} + if !errors.As(err, &rpcError) { + return nil, err + } + errorMessage := &appmessage.GetUTXOsByAddressesResponseMessage{} + errorMessage.Error = rpcError + return errorMessage, nil + } + + txIDBlockHashpairs := make([]*appmessage.TxIDBlockHashPair, len(acceptingBlockHashes)) + i := 0 + for txID, blockHash := range acceptingBlockHashes { + txIDBlockHashpairs[i] = &appmessage.TxIDBlockHashPair{ + TxID: txID.String(), + Hash: blockHash.String(), + } + i++ + } + + response := appmessage.NewGetAcceptingBlockHashesOfTxsResponse(txIDBlockHashpairs) + + return response, nil +} diff --git a/app/rpc/rpchandlers/get_accepting_blocks_of_txs.go b/app/rpc/rpchandlers/get_accepting_blocks_of_txs.go new file mode 100644 index 000000000..f45076b79 --- /dev/null +++ b/app/rpc/rpchandlers/get_accepting_blocks_of_txs.go @@ -0,0 +1,68 @@ +package rpchandlers + +import ( + "github.com/kaspanet/kaspad/app/appmessage" + "github.com/kaspanet/kaspad/app/rpc/rpccontext" + "github.com/kaspanet/kaspad/domain/consensus/model/externalapi" + "github.com/kaspanet/kaspad/domain/consensus/utils/consensushashing" + "github.com/kaspanet/kaspad/infrastructure/network/netadapter/router" + + "github.com/pkg/errors" +) + +// HandleGetAcceptingBlocksOfTx handles the respectively named RPC command +func HandleGetAcceptingBlocksOfTx(context *rpccontext.Context, _ *router.Router, request appmessage.Message) (appmessage.Message, error) { + var err error + + if !context.Config.TXIndex { + errorMessage := &appmessage.GetAcceptingBlocksOfTxsResponseMessage{} + errorMessage.Error = appmessage.RPCErrorf("Method unavailable when kaspad is run without --txindex") + return errorMessage, nil + } + + getAcceptingBlocksOfTxsRequest := request.(*appmessage.GetAcceptingBlocksOfTxsRequestMessage) + + domainTxIDs := make([]*externalapi.DomainTransactionID, len(getAcceptingBlocksOfTxsRequest.TxIDs)) + for i := range domainTxIDs { + domainTxIDs[i], err = externalapi.NewDomainTransactionIDFromString(getAcceptingBlocksOfTxsRequest.TxIDs[i]) + if err != nil { + errorMessage := &appmessage.GetAcceptingBlocksOfTxsResponseMessage{} + errorMessage.Error = appmessage.RPCErrorf("error parsing txID: %s, %s", getAcceptingBlocksOfTxsRequest.TxIDs[i], err.Error()) + return errorMessage, nil + } + } + acceptingBlockHashes, _, err := context.TXIndex.TXAcceptingBlocks(domainTxIDs) + if err != nil { + rpcError := &appmessage.RPCError{} + if !errors.As(err, &rpcError) { + return nil, err + } + errorMessage := &appmessage.GetUTXOsByAddressesResponseMessage{} + errorMessage.Error = rpcError + return errorMessage, nil + } + + txIDBlockPairs := make([]*appmessage.TxIDBlockPair, len(acceptingBlockHashes)) + i := 0 + for txID, acceptingBlock := range acceptingBlockHashes { + rpcAcceptingBlock := appmessage.DomainBlockToRPCBlock(acceptingBlock) + err = context.PopulateBlockWithVerboseData(rpcAcceptingBlock, acceptingBlock.Header, acceptingBlock, getAcceptingBlocksOfTxsRequest.IncludeTransactions) + if err != nil { + if errors.Is(err, rpccontext.ErrBuildBlockVerboseDataInvalidBlock) { + errorMessage := &appmessage.GetAcceptingBlockOfTxResponseMessage{} + errorMessage.Error = appmessage.RPCErrorf("Block %s is invalid", consensushashing.BlockHash(acceptingBlock).String()) + return errorMessage, nil + } + return nil, err + } + txIDBlockPairs[i] = &appmessage.TxIDBlockPair{ + TxID: txID.String(), + Block: rpcAcceptingBlock, + } + i++ + } + + response := appmessage.NewGetAcceptingBlocksOfTxsResponse(txIDBlockPairs) + + return response, nil +} diff --git a/app/rpc/rpchandlers/get_including_blockhash_of_tx.go b/app/rpc/rpchandlers/get_including_blockhash_of_tx.go new file mode 100644 index 000000000..22dfc48c6 --- /dev/null +++ b/app/rpc/rpchandlers/get_including_blockhash_of_tx.go @@ -0,0 +1,52 @@ +package rpchandlers + +import ( + "github.com/kaspanet/kaspad/app/appmessage" + "github.com/kaspanet/kaspad/app/rpc/rpccontext" + "github.com/kaspanet/kaspad/domain/consensus/model/externalapi" + "github.com/kaspanet/kaspad/infrastructure/network/netadapter/router" + + "github.com/pkg/errors" +) + +// HandleGetIncludingBlockHashOfTx handles the respectively named RPC command +func HandleGetIncludingBlockHashOfTx(context *rpccontext.Context, _ *router.Router, request appmessage.Message) (appmessage.Message, error) { + if !context.Config.TXIndex { + errorMessage := &appmessage.GetIncludingBlockHashOfTxResponseMessage{} + errorMessage.Error = appmessage.RPCErrorf("Method unavailable when kaspad is run without --txindex") + return errorMessage, nil + } + + getIncludingBlockHashOfTxRequest := request.(*appmessage.GetIncludingBlockHashOfTxRequestMessage) + + domainTxID, err := externalapi.NewDomainTransactionIDFromString(getIncludingBlockHashOfTxRequest.TxID) + if err != nil { + rpcError := &appmessage.RPCError{} + if !errors.As(err, &rpcError) { + return nil, err + } + errorMessage := &appmessage.GetIncludingBlockHashOfTxResponseMessage{} + errorMessage.Error = rpcError + return errorMessage, nil + } + + includingBlockHash, found, err := context.TXIndex.TXIncludingBlockHash(domainTxID) + if err != nil { + rpcError := &appmessage.RPCError{} + if !errors.As(err, &rpcError) { + return nil, err + } + errorMessage := &appmessage.GetIncludingBlockHashOfTxResponseMessage{} + errorMessage.Error = rpcError + return errorMessage, nil + } + if !found { + errorMessage := &appmessage.GetAcceptingBlockHashOfTxResponseMessage{} + errorMessage.Error = appmessage.RPCErrorf("Could not find including block hash in the txindex database for txID: %s", domainTxID.String()) + return errorMessage, nil + } + + response := appmessage.NewGetIncludingBlockHashOfTxResponse(includingBlockHash.String()) + + return response, nil +} diff --git a/app/rpc/rpchandlers/get_tx.go b/app/rpc/rpchandlers/get_tx.go new file mode 100644 index 000000000..84d2a6d6e --- /dev/null +++ b/app/rpc/rpchandlers/get_tx.go @@ -0,0 +1,80 @@ +package rpchandlers + +import ( + "github.com/kaspanet/kaspad/app/appmessage" + "github.com/kaspanet/kaspad/app/rpc/rpccontext" + "github.com/kaspanet/kaspad/domain/consensus/model/externalapi" + "github.com/kaspanet/kaspad/domain/consensus/utils/consensushashing" + "github.com/kaspanet/kaspad/infrastructure/network/netadapter/router" + + "github.com/pkg/errors" +) + +// HandleGetTx handles the respectively named RPC command +func HandleGetTx(context *rpccontext.Context, _ *router.Router, request appmessage.Message) (appmessage.Message, error) { + if !context.Config.TXIndex { + errorMessage := &appmessage.GetTxResponseMessage{} + errorMessage.Error = appmessage.RPCErrorf("Method unavailable when kaspad is run without --txindex") + return errorMessage, nil + } + + getTxRequest := request.(*appmessage.GetTxRequestMessage) + + domainTxID, err := externalapi.NewDomainTransactionIDFromString(getTxRequest.TxID) + if err != nil { + rpcError := &appmessage.RPCError{} + if !errors.As(err, &rpcError) { + return nil, err + } + errorMessage := &appmessage.GetTxResponseMessage{} + errorMessage.Error = rpcError + return errorMessage, nil + } + + transaction, found, err := context.TXIndex.GetTX(domainTxID) + if err != nil { + rpcError := &appmessage.RPCError{} + if !errors.As(err, &rpcError) { + return nil, err + } + errorMessage := &appmessage.GetTxResponseMessage{} + errorMessage.Error = rpcError + return errorMessage, nil + } + if !found { + errorMessage := &appmessage.GetTxResponseMessage{} + errorMessage.Error = appmessage.RPCErrorf("Could not find tx in the txindex database for txID: %s", domainTxID.String()) + return errorMessage, nil + } + + blockForVerboseData, found, err := context.TXIndex.TXAcceptingBlock(domainTxID) + if err != nil { + rpcError := &appmessage.RPCError{} + if !errors.As(err, &rpcError) { + return nil, err + } + errorMessage := &appmessage.GetTxResponseMessage{} + errorMessage.Error = rpcError + return errorMessage, nil + } + if !found { + errorMessage := &appmessage.GetTxResponseMessage{} + errorMessage.Error = appmessage.RPCErrorf("Could not find accepting block in the txindex database for txID: %s", domainTxID.String()) + return errorMessage, nil + } + + rpcTransaction := appmessage.DomainTransactionToRPCTransaction(transaction) + err = context.PopulateTransactionWithVerboseData(rpcTransaction, blockForVerboseData.Header) + if err != nil { + if errors.Is(err, rpccontext.ErrBuildBlockVerboseDataInvalidBlock) { + errorMessage := &appmessage.GetTxResponseMessage{} + errorMessage.Error = appmessage.RPCErrorf("Block %s is invalid", consensushashing.BlockHash(blockForVerboseData).String()) + return errorMessage, nil + } + return nil, err + } + + response := appmessage.NewGetTxResponse(rpcTransaction) + + return response, nil +} diff --git a/app/rpc/rpchandlers/get_tx_confirmations.go b/app/rpc/rpchandlers/get_tx_confirmations.go new file mode 100644 index 000000000..48348a008 --- /dev/null +++ b/app/rpc/rpchandlers/get_tx_confirmations.go @@ -0,0 +1,47 @@ +package rpchandlers + +import ( + "github.com/kaspanet/kaspad/app/appmessage" + "github.com/kaspanet/kaspad/app/rpc/rpccontext" + "github.com/kaspanet/kaspad/domain/consensus/model/externalapi" + "github.com/kaspanet/kaspad/infrastructure/network/netadapter/router" + + "github.com/pkg/errors" +) + +// HandleGetTxConfirmations handles the respectively named RPC command +func HandleGetTxConfirmations(context *rpccontext.Context, _ *router.Router, request appmessage.Message) (appmessage.Message, error) { + if !context.Config.TXIndex { + errorMessage := &appmessage.GetTxConfirmationsResponseMessage{} + errorMessage.Error = appmessage.RPCErrorf("Method unavailable when kaspad is run without --txindex") + return errorMessage, nil + } + + getTxConfirmationsRequest := request.(*appmessage.GetTxConfirmationsRequestMessage) + + domainTxID, err := externalapi.NewDomainTransactionIDFromString(getTxConfirmationsRequest.TxID) + if err != nil { + rpcError := &appmessage.RPCError{} + if !errors.As(err, &rpcError) { + return nil, err + } + errorMessage := &appmessage.GetTxConfirmationsResponseMessage{} + errorMessage.Error = rpcError + return errorMessage, nil + } + + confirmations, _, err := context.TXIndex.GetTXConfirmations(domainTxID) + if err != nil { + rpcError := &appmessage.RPCError{} + if !errors.As(err, &rpcError) { + return nil, err + } + errorMessage := &appmessage.GetTxConfirmationsResponseMessage{} + errorMessage.Error = rpcError + return errorMessage, nil + } + + response := appmessage.NewGetTxConfirmationsResponse(confirmations) + + return response, nil +} diff --git a/app/rpc/rpchandlers/get_txs.go b/app/rpc/rpchandlers/get_txs.go new file mode 100644 index 000000000..645cb64cc --- /dev/null +++ b/app/rpc/rpchandlers/get_txs.go @@ -0,0 +1,12 @@ +package rpchandlers + +import ( + "github.com/kaspanet/kaspad/app/appmessage" + "github.com/kaspanet/kaspad/app/rpc/rpccontext" + "github.com/kaspanet/kaspad/infrastructure/network/netadapter/router" +) + +// HandleGetTxs handles the respectively named RPC command +func HandleGetTxs(context *rpccontext.Context, _ *router.Router, request appmessage.Message) (appmessage.Message, error) { + return nil, nil +} diff --git a/app/rpc/rpchandlers/get_txs_confirmations.go b/app/rpc/rpchandlers/get_txs_confirmations.go new file mode 100644 index 000000000..46917cdd4 --- /dev/null +++ b/app/rpc/rpchandlers/get_txs_confirmations.go @@ -0,0 +1,12 @@ +package rpchandlers + +import ( + "github.com/kaspanet/kaspad/app/appmessage" + "github.com/kaspanet/kaspad/app/rpc/rpccontext" + "github.com/kaspanet/kaspad/infrastructure/network/netadapter/router" +) + +// HandleGetTxsConfirmations handles the respectively named RPC command +func HandleGetTxsConfirmations(context *rpccontext.Context, _ *router.Router, request appmessage.Message) (appmessage.Message, error) { + return nil, nil +} diff --git a/domain/txindex/model.go b/domain/txindex/model.go index 8df405237..c7b268a1c 100644 --- a/domain/txindex/model.go +++ b/domain/txindex/model.go @@ -19,6 +19,9 @@ type TxIDsToBlockHashes map[*externalapi.DomainTransactionID]*externalapi.Domain //TxIDsToBlocks is a map of TxIDs to corrospnding blocks type TxIDsToBlocks map[*externalapi.DomainTransactionID]*externalapi.DomainBlock +//TxIDsToConfirmations is a map of TxIDs to corrospnding Confirmations +type TxIDsToConfirmations map[*externalapi.DomainTransactionID]int64 + // ConvertDomainHashToString converts the given DomainHash to a string func ConvertDomainHashToString(blockHash *externalapi.DomainHash) string { return hex.EncodeToString(blockHash.ByteSlice()) diff --git a/domain/txindex/store.go b/domain/txindex/store.go index 61b7f66ec..38be9d19d 100644 --- a/domain/txindex/store.go +++ b/domain/txindex/store.go @@ -247,7 +247,7 @@ func (tis *txIndexStore) getTxAcceptingBlockHashes(txIDs []*externalapi.DomainTr serializedAcceptingBlockHash, err := tis.database.Get(key) if err != nil { if database.IsNotFoundError(err) { - return nil, false, nil + continue //ignore not found errors we expect this to happen frequently with queries } return nil, false, err } diff --git a/domain/txindex/txindex.go b/domain/txindex/txindex.go index 00059011a..15f61b394 100644 --- a/domain/txindex/txindex.go +++ b/domain/txindex/txindex.go @@ -302,7 +302,7 @@ func (ti *TXIndex) TXAcceptingBlock(txID *externalapi.DomainTransactionID) ( // TXAcceptingBlocks returns the accepting blocks for for the given txIDs func (ti *TXIndex) TXAcceptingBlocks(txIDs []*externalapi.DomainTransactionID) ( - acceptingBlocks []*externalapi.DomainBlock, found bool, err error) { + acceptingBlocks TxIDsToBlocks, found bool, err error) { onEnd := logger.LogAndMeasureExecutionTime(log, "TXIndex.TXAcceptingBlock") defer onEnd() @@ -314,23 +314,20 @@ func (ti *TXIndex) TXAcceptingBlocks(txIDs []*externalapi.DomainTransactionID) ( return nil, false, err } - acceptingBlockHashes := make([]*externalapi.DomainHash, len(acceptingBlockHashTxIDPairs)) - + acceptingBlocks = make(TxIDsToBlocks) i := 0 - for _, acceptingBlockHash := range acceptingBlockHashTxIDPairs { - acceptingBlockHashes[i] = acceptingBlockHash + for txID, blockHash := range acceptingBlockHashTxIDPairs { + acceptingBlocks[txID], err = ti.domain.Consensus().GetBlock(blockHash) + if err != nil { + if database.IsNotFoundError(err) { + continue // ignore + } else { + return nil, false, err + } + } i++ } - if !found { - return nil, false, nil - } - - acceptingBlocks, err = ti.domain.Consensus().GetBlocks(acceptingBlockHashes) - if err != nil { - return nil, false, err - } - return acceptingBlocks, true, nil } @@ -365,9 +362,44 @@ func (ti *TXIndex) GetTX(txID *externalapi.DomainTransactionID) ( return nil, false, fmt.Errorf("Could not find transaction with ID %s in Txindex database", txID.String()) } +// GetTXs returns the domain transaction for for the given txIDs +func (ti *TXIndex) GetTXs(txIDs []*externalapi.DomainTransactionID) ( + txs []*externalapi.DomainTransaction, found bool, err error) { + onEnd := logger.LogAndMeasureExecutionTime(log, "TXIndex.GetTXs") + defer onEnd() + + ti.mutex.Lock() + defer ti.mutex.Unlock() + + acceptingBlockHashes, found, err := ti.store.getTxAcceptingBlockHashes(txIDs) + if err != nil { + return nil, false, err + } + + txs = make([]*externalapi.DomainTransaction, 0) + for txID, acceptingBlockHash := range acceptingBlockHashes { + acceptingBlock, err := ti.domain.Consensus().GetBlock(acceptingBlockHash) + if err != nil { + if database.IsNotFoundError(err) { + continue // ignore + } else { + return nil, false, err + } + } + for _, tx := range acceptingBlock.Transactions { + if consensushashing.TransactionID(tx).Equal(txID) { + txs = append(txs, tx) + } + } + + } + + return txs, true, nil +} + // GetTXConfirmations returns the tx confirmations for for the given txID func (ti *TXIndex) GetTXConfirmations(txID *externalapi.DomainTransactionID) ( - BlockHashTxIDPair uint64, found bool, err error) { + Confirmations int64, found bool, err error) { onEnd := logger.LogAndMeasureExecutionTime(log, "TXIndex.GetTXConfirmations") defer onEnd() @@ -381,7 +413,7 @@ func (ti *TXIndex) GetTXConfirmations(txID *externalapi.DomainTransactionID) ( acceptingBlockHeader, err := ti.domain.Consensus().GetBlockHeader(acceptingBlockHash) if err != nil { - return 0, false, err + return -1, false, err } virtualBlock, err := ti.domain.Consensus().GetVirtualInfo() @@ -389,7 +421,38 @@ func (ti *TXIndex) GetTXConfirmations(txID *externalapi.DomainTransactionID) ( return 0, false, err } - return virtualBlock.BlueScore - acceptingBlockHeader.BlueScore(), true, nil + return int64(virtualBlock.BlueScore - acceptingBlockHeader.BlueScore()), true, nil +} + +// GetTXsConfirmations returns the tx confirmations for for the given txIDs +func (ti *TXIndex) GetTXsConfirmations(txIDs []*externalapi.DomainTransactionID) ( + Confirmations TxIDsToConfirmations, found bool, err error) { + onEnd := logger.LogAndMeasureExecutionTime(log, "TXIndex.GetTXsConfirmations") + defer onEnd() + + ti.mutex.Lock() + defer ti.mutex.Unlock() + + virtualBlock, err := ti.domain.Consensus().GetVirtualInfo() + if err != nil { + return nil, false, err + } + + acceptingBlockHashes, _, err := ti.store.getTxAcceptingBlockHashes(txIDs) + if err != nil { + return nil, false, err + } + + Confirmations = make(TxIDsToConfirmations) + for txID, acceptingBlockHash := range acceptingBlockHashes { + acceptingBlockHeader, err := ti.domain.Consensus().GetBlockHeader(acceptingBlockHash) + if err != nil { + return nil, false, err + } + Confirmations[txID] = int64(acceptingBlockHeader.BlueScore() - virtualBlock.BlueScore) + } + + return Confirmations, true, nil } // TXIncludingBlockHash returns the including block hash for the given txID diff --git a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.md b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.md index b6a97a752..46025b1aa 100644 --- a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.md +++ b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.md @@ -1998,6 +1998,7 @@ See NotifyNewBlockTemplateRequestMessage | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | txID | [string](#string) | | | +| includeTransactions | [bool](#bool) | | | @@ -2029,6 +2030,7 @@ See NotifyNewBlockTemplateRequestMessage | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | txIDs | [string](#string) | repeated | | +| includeTransactions | [bool](#bool) | | | diff --git a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.pb.go b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.pb.go index 251d33f63..f454c0325 100644 --- a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.pb.go +++ b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.pb.go @@ -6487,7 +6487,8 @@ type GetAcceptingBlockOfTxRequestMessage struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - TxID string `protobuf:"bytes,1,opt,name=txID,proto3" json:"txID,omitempty"` + TxID string `protobuf:"bytes,1,opt,name=txID,proto3" json:"txID,omitempty"` + IncludeTransactions bool `protobuf:"varint,2,opt,name=includeTransactions,proto3" json:"includeTransactions,omitempty"` } func (x *GetAcceptingBlockOfTxRequestMessage) Reset() { @@ -6529,6 +6530,13 @@ func (x *GetAcceptingBlockOfTxRequestMessage) GetTxID() string { return "" } +func (x *GetAcceptingBlockOfTxRequestMessage) GetIncludeTransactions() bool { + if x != nil { + return x.IncludeTransactions + } + return false +} + type GetAcceptingBlockOfTxResponseMessage struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -6589,7 +6597,8 @@ type GetAcceptingBlocksOfTxsRequestMessage struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - TxIDs []string `protobuf:"bytes,1,rep,name=txIDs,proto3" json:"txIDs,omitempty"` + TxIDs []string `protobuf:"bytes,1,rep,name=txIDs,proto3" json:"txIDs,omitempty"` + IncludeTransactions bool `protobuf:"varint,2,opt,name=includeTransactions,proto3" json:"includeTransactions,omitempty"` } func (x *GetAcceptingBlocksOfTxsRequestMessage) Reset() { @@ -6631,6 +6640,13 @@ func (x *GetAcceptingBlocksOfTxsRequestMessage) GetTxIDs() []string { return nil } +func (x *GetAcceptingBlocksOfTxsRequestMessage) GetIncludeTransactions() bool { + if x != nil { + return x.IncludeTransactions + } + return false +} + type GetAcceptingBlocksOfTxsResponseMessage struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -8039,93 +8055,99 @@ var file_rpc_proto_rawDesc = []byte{ 0x68, 0x50, 0x61, 0x69, 0x72, 0x73, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0xe8, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x52, 0x50, 0x43, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, - 0x6f, 0x72, 0x22, 0x39, 0x0a, 0x23, 0x47, 0x65, 0x74, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x69, + 0x6f, 0x72, 0x22, 0x6b, 0x0a, 0x23, 0x47, 0x65, 0x74, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6e, 0x67, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x4f, 0x66, 0x54, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x78, 0x49, - 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x78, 0x49, 0x44, 0x22, 0x7d, 0x0a, - 0x24, 0x47, 0x65, 0x74, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6e, 0x67, 0x42, 0x6c, 0x6f, - 0x63, 0x6b, 0x4f, 0x66, 0x54, 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x29, 0x0a, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, - 0x2e, 0x52, 0x70, 0x63, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, - 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0xe8, 0x07, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x52, 0x50, 0x43, - 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x3d, 0x0a, 0x25, - 0x47, 0x65, 0x74, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6e, 0x67, 0x42, 0x6c, 0x6f, 0x63, - 0x6b, 0x73, 0x4f, 0x66, 0x54, 0x78, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x78, 0x49, 0x44, 0x73, 0x18, 0x01, - 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x74, 0x78, 0x49, 0x44, 0x73, 0x22, 0x96, 0x01, 0x0a, 0x26, - 0x47, 0x65, 0x74, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6e, 0x67, 0x42, 0x6c, 0x6f, 0x63, - 0x6b, 0x73, 0x4f, 0x66, 0x54, 0x78, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x40, 0x0a, 0x0e, 0x74, 0x78, 0x49, 0x44, 0x42, 0x6c, - 0x6f, 0x63, 0x6b, 0x50, 0x61, 0x69, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x54, 0x78, 0x49, 0x44, 0x42, - 0x6c, 0x6f, 0x63, 0x6b, 0x50, 0x61, 0x69, 0x72, 0x52, 0x0e, 0x74, 0x78, 0x49, 0x44, 0x42, 0x6c, - 0x6f, 0x63, 0x6b, 0x50, 0x61, 0x69, 0x72, 0x73, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, - 0x72, 0x18, 0xe8, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x77, 0x69, 0x72, 0x65, 0x2e, 0x52, 0x50, 0x43, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, - 0x72, 0x72, 0x6f, 0x72, 0x22, 0x3d, 0x0a, 0x27, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x63, 0x6c, 0x75, - 0x64, 0x69, 0x6e, 0x67, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x4f, 0x66, 0x54, - 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, - 0x12, 0x0a, 0x04, 0x74, 0x78, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, - 0x78, 0x49, 0x44, 0x22, 0x6a, 0x0a, 0x28, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x63, 0x6c, 0x75, 0x64, - 0x69, 0x6e, 0x67, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x4f, 0x66, 0x54, 0x78, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, - 0x12, 0x0a, 0x04, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, - 0x61, 0x73, 0x68, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0xe8, 0x07, 0x20, + 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x78, 0x49, 0x44, 0x12, 0x30, 0x0a, + 0x13, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x69, 0x6e, 0x63, 0x6c, + 0x75, 0x64, 0x65, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, + 0x7d, 0x0a, 0x24, 0x47, 0x65, 0x74, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6e, 0x67, 0x42, + 0x6c, 0x6f, 0x63, 0x6b, 0x4f, 0x66, 0x54, 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x29, 0x0a, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, + 0x72, 0x65, 0x2e, 0x52, 0x70, 0x63, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x05, 0x62, 0x6c, 0x6f, + 0x63, 0x6b, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0xe8, 0x07, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x52, + 0x50, 0x43, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x6f, + 0x0a, 0x25, 0x47, 0x65, 0x74, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6e, 0x67, 0x42, 0x6c, + 0x6f, 0x63, 0x6b, 0x73, 0x4f, 0x66, 0x54, 0x78, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x78, 0x49, 0x44, 0x73, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x74, 0x78, 0x49, 0x44, 0x73, 0x12, 0x30, 0x0a, + 0x13, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x69, 0x6e, 0x63, 0x6c, + 0x75, 0x64, 0x65, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, + 0x96, 0x01, 0x0a, 0x26, 0x47, 0x65, 0x74, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6e, 0x67, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x4f, 0x66, 0x54, 0x78, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x40, 0x0a, 0x0e, 0x74, 0x78, + 0x49, 0x44, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x50, 0x61, 0x69, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x54, + 0x78, 0x49, 0x44, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x50, 0x61, 0x69, 0x72, 0x52, 0x0e, 0x74, 0x78, + 0x49, 0x44, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x50, 0x61, 0x69, 0x72, 0x73, 0x12, 0x2a, 0x0a, 0x05, + 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0xe8, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x52, 0x50, 0x43, 0x45, 0x72, 0x72, 0x6f, + 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x3d, 0x0a, 0x27, 0x47, 0x65, 0x74, 0x49, + 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x69, 0x6e, 0x67, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, + 0x68, 0x4f, 0x66, 0x54, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x78, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x74, 0x78, 0x49, 0x44, 0x22, 0x6a, 0x0a, 0x28, 0x47, 0x65, 0x74, 0x49, 0x6e, + 0x63, 0x6c, 0x75, 0x64, 0x69, 0x6e, 0x67, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, + 0x4f, 0x66, 0x54, 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x68, 0x61, 0x73, 0x68, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, + 0x18, 0xe8, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, + 0x69, 0x72, 0x65, 0x2e, 0x52, 0x50, 0x43, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, + 0x72, 0x6f, 0x72, 0x22, 0x29, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x54, 0x78, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x78, + 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x78, 0x49, 0x44, 0x22, 0x7f, + 0x0a, 0x14, 0x47, 0x65, 0x74, 0x54, 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x3b, 0x0a, 0x0b, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x52, 0x70, 0x63, 0x54, 0x72, 0x61, 0x6e, 0x73, + 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0xe8, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x52, 0x50, 0x43, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, - 0x29, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x54, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, + 0x2c, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x54, 0x78, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x78, 0x49, 0x44, 0x73, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x74, 0x78, 0x49, 0x44, 0x73, 0x22, 0x82, 0x01, + 0x0a, 0x15, 0x47, 0x65, 0x74, 0x54, 0x78, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x3d, 0x0a, 0x0c, 0x74, 0x72, 0x61, 0x6e, 0x73, + 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x52, 0x70, 0x63, 0x54, 0x72, 0x61, + 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, + 0xe8, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, + 0x72, 0x65, 0x2e, 0x52, 0x50, 0x43, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, + 0x6f, 0x72, 0x22, 0x36, 0x0a, 0x20, 0x47, 0x65, 0x74, 0x54, 0x78, 0x43, 0x6f, 0x6e, 0x66, 0x69, + 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x78, 0x49, 0x44, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x78, 0x49, 0x44, 0x22, 0x7f, 0x0a, 0x14, 0x47, 0x65, - 0x74, 0x54, 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, - 0x67, 0x65, 0x12, 0x3b, 0x0a, 0x0b, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, - 0x69, 0x72, 0x65, 0x2e, 0x52, 0x70, 0x63, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, - 0x6f, 0x6e, 0x52, 0x0b, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, - 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0xe8, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x52, 0x50, 0x43, 0x45, - 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x2c, 0x0a, 0x14, 0x47, - 0x65, 0x74, 0x54, 0x78, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x78, 0x49, 0x44, 0x73, 0x18, 0x01, 0x20, 0x03, - 0x28, 0x09, 0x52, 0x05, 0x74, 0x78, 0x49, 0x44, 0x73, 0x22, 0x82, 0x01, 0x0a, 0x15, 0x47, 0x65, - 0x74, 0x54, 0x78, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x12, 0x3d, 0x0a, 0x0c, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x52, 0x70, 0x63, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, - 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0xe8, 0x07, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x52, - 0x50, 0x43, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x36, - 0x0a, 0x20, 0x47, 0x65, 0x74, 0x54, 0x78, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, - 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x78, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x74, 0x78, 0x49, 0x44, 0x22, 0x75, 0x0a, 0x21, 0x47, 0x65, 0x74, 0x54, 0x78, 0x43, - 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x63, - 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x0d, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x73, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0xe8, 0x07, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x52, 0x50, - 0x43, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x39, 0x0a, - 0x21, 0x47, 0x65, 0x74, 0x54, 0x78, 0x73, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, - 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x78, 0x49, 0x44, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, - 0x09, 0x52, 0x05, 0x74, 0x78, 0x49, 0x44, 0x73, 0x22, 0xaa, 0x01, 0x0a, 0x22, 0x47, 0x65, 0x74, - 0x54, 0x78, 0x73, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x78, 0x49, 0x44, 0x22, 0x75, 0x0a, 0x21, 0x47, 0x65, + 0x74, 0x54, 0x78, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, - 0x58, 0x0a, 0x16, 0x74, 0x78, 0x49, 0x44, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x50, 0x61, 0x69, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x20, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x54, 0x78, 0x49, 0x44, - 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x50, 0x61, 0x69, - 0x72, 0x52, 0x16, 0x74, 0x78, 0x49, 0x44, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x50, 0x61, 0x69, 0x72, 0x73, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, - 0x6f, 0x72, 0x18, 0xe8, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x52, 0x50, 0x43, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, - 0x65, 0x72, 0x72, 0x6f, 0x72, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x6e, 0x65, 0x74, 0x2f, 0x6b, 0x61, 0x73, - 0x70, 0x61, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x24, 0x0a, 0x0d, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0xe8, + 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, + 0x65, 0x2e, 0x52, 0x50, 0x43, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, + 0x72, 0x22, 0x39, 0x0a, 0x21, 0x47, 0x65, 0x74, 0x54, 0x78, 0x73, 0x43, 0x6f, 0x6e, 0x66, 0x69, + 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x78, 0x49, 0x44, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x74, 0x78, 0x49, 0x44, 0x73, 0x22, 0xaa, 0x01, 0x0a, + 0x22, 0x47, 0x65, 0x74, 0x54, 0x78, 0x73, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x12, 0x58, 0x0a, 0x16, 0x74, 0x78, 0x49, 0x44, 0x43, 0x6f, 0x6e, 0x66, 0x69, + 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x50, 0x61, 0x69, 0x72, 0x73, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, + 0x54, 0x78, 0x49, 0x44, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x50, 0x61, 0x69, 0x72, 0x52, 0x16, 0x74, 0x78, 0x49, 0x44, 0x43, 0x6f, 0x6e, 0x66, 0x69, + 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x50, 0x61, 0x69, 0x72, 0x73, 0x12, 0x2a, 0x0a, + 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0xe8, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x52, 0x50, 0x43, 0x45, 0x72, 0x72, + 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x6e, 0x65, 0x74, + 0x2f, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, + 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.proto b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.proto index dcb1a529a..52f7427c4 100644 --- a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.proto +++ b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.proto @@ -761,6 +761,7 @@ message GetAcceptingBlockHashesOfTxsResponseMessage{ message GetAcceptingBlockOfTxRequestMessage{ string txID = 1; + bool includeTransactions = 2; } message GetAcceptingBlockOfTxResponseMessage{ @@ -771,6 +772,7 @@ message GetAcceptingBlockOfTxResponseMessage{ message GetAcceptingBlocksOfTxsRequestMessage{ repeated string txIDs = 1; + bool includeTransactions = 2; } message GetAcceptingBlocksOfTxsResponseMessage{ diff --git a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_accepting_block_of_tx.go b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_accepting_block_of_tx.go index 91ab4cf30..598ff3777 100644 --- a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_accepting_block_of_tx.go +++ b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_accepting_block_of_tx.go @@ -14,7 +14,8 @@ func (x *KaspadMessage_GetAcceptingBlockOfTxRequest) toAppMessage() (appmessage. func (x *KaspadMessage_GetAcceptingBlockOfTxRequest) fromAppMessage(message *appmessage.GetAcceptingBlockOfTxRequestMessage) error { x.GetAcceptingBlockOfTxRequest = &GetAcceptingBlockOfTxRequestMessage{ - TxID: message.TxID, + TxID: message.TxID, + IncludeTransactions: message.IncludeTransactions, } return nil } @@ -24,7 +25,8 @@ func (x *GetAcceptingBlockOfTxRequestMessage) toAppMessage() (appmessage.Message return nil, errors.Wrapf(errorNil, "GetAcceptingBlockOfTxRequestMessage is nil") } return &appmessage.GetAcceptingBlockOfTxRequestMessage{ - TxID: x.TxID, + TxID: x.TxID, + IncludeTransactions: x.IncludeTransactions, }, nil } @@ -42,7 +44,7 @@ func (x *KaspadMessage_GetAcceptingBlockOfTxResponse) fromAppMessage(message *ap rpcErr = &RPCError{Message: message.Error.Message} } rpcBlock := &RpcBlock{} - + err := rpcBlock.fromAppMessage(message.Block) if err != nil { return err @@ -75,7 +77,7 @@ func (x *GetAcceptingBlockOfTxResponseMessage) toAppMessage() (appmessage.Messag } return &appmessage.GetAcceptingBlockOfTxResponseMessage{ - Block: appBlock, + Block: appBlock, Error: rpcErr, }, nil } diff --git a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_accepting_blockhashes_of_txs.go b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_accepting_blockhashes_of_txs.go index 8689a5248..ac0125025 100644 --- a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_accepting_blockhashes_of_txs.go +++ b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_accepting_blockhashes_of_txs.go @@ -46,7 +46,7 @@ func (x *KaspadMessage_GetAcceptingBlockHashesOfTxsResponse) fromAppMessage(mess for i := range rpcTxIDBlockHashPairs { rpcTxIDBlockHashPairs[i].fromAppMessage(message.TxIDBlockHashPairs[i]) } - + x.GetAcceptingBlockHashesOfTxsResponse = &GetAcceptingBlockHashesOfTxsResponseMessage{ TxIDBlockHashPairs: rpcTxIDBlockHashPairs, @@ -78,8 +78,8 @@ func (x *GetAcceptingBlockHashesOfTxsResponseMessage) toAppMessage() (appmessage } return &appmessage.GetAcceptingBlockHashesOfTxsResponseMessage{ - TxIDBlockHashPairs: appTxIDBlockHashPairs, - Error: rpcErr, + TxIDBlockHashPairs: appTxIDBlockHashPairs, + Error: rpcErr, }, nil } @@ -89,16 +89,15 @@ func (x *TxIDBlockHashPair) toAppMessage() (*appmessage.TxIDBlockHashPair, error } return &appmessage.TxIDBlockHashPair{ - TxID: x.TxID, - Hash: x.Hash, + TxID: x.TxID, + Hash: x.Hash, }, nil } func (x *TxIDBlockHashPair) fromAppMessage(message *appmessage.TxIDBlockHashPair) { - + *x = TxIDBlockHashPair{ TxID: message.TxID, Hash: message.Hash, - } } diff --git a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_accepting_blocks_of_txs.go b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_accepting_blocks_of_txs.go index 40b3fcca4..673d5c183 100644 --- a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_accepting_blocks_of_txs.go +++ b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_accepting_blocks_of_txs.go @@ -14,7 +14,8 @@ func (x *KaspadMessage_GetAcceptingBlocksOfTxsRequest) toAppMessage() (appmessag func (x *KaspadMessage_GetAcceptingBlocksOfTxsRequest) fromAppMessage(message *appmessage.GetAcceptingBlocksOfTxsRequestMessage) error { x.GetAcceptingBlocksOfTxsRequest = &GetAcceptingBlocksOfTxsRequestMessage{ - TxIDs: message.TxIDs, + TxIDs: message.TxIDs, + IncludeTransactions: message.IncludeTransactions, } return nil } @@ -24,7 +25,8 @@ func (x *GetAcceptingBlocksOfTxsRequestMessage) toAppMessage() (appmessage.Messa return nil, errors.Wrapf(errorNil, "GetAcceptingBlocksOfTxsRequestMessage is nil") } return &appmessage.GetAcceptingBlocksOfTxsRequestMessage{ - TxIDs: x.TxIDs, + TxIDs: x.TxIDs, + IncludeTransactions: x.IncludeTransactions, }, nil } @@ -49,7 +51,7 @@ func (x *KaspadMessage_GetAcceptingBlocksOfTxsResponse) fromAppMessage(message * return err } } - + x.GetAcceptingBlocksOfTxsResponse = &GetAcceptingBlocksOfTxsResponseMessage{ TxIDBlockPairs: rpcTxIDBlockPairs, @@ -81,8 +83,8 @@ func (x *GetAcceptingBlocksOfTxsResponseMessage) toAppMessage() (appmessage.Mess } return &appmessage.GetAcceptingBlocksOfTxsResponseMessage{ - TxIDBlockPairs: appTxIDBlockPairs, - Error: rpcErr, + TxIDBlockPairs: appTxIDBlockPairs, + Error: rpcErr, }, nil } @@ -98,22 +100,21 @@ func (x *TxIDBlockPair) toAppMessage() (*appmessage.TxIDBlockPair, error) { return &appmessage.TxIDBlockPair{ TxID: x.TxID, - Block: *appBlock, + Block: appBlock, }, nil } func (x *TxIDBlockPair) fromAppMessage(message *appmessage.TxIDBlockPair) error { - + rpcBlock := &RpcBlock{} - - err := rpcBlock.fromAppMessage(&message.Block) + + err := rpcBlock.fromAppMessage(message.Block) if err != nil { return err } *x = TxIDBlockPair{ - TxID: message.TxID, + TxID: message.TxID, Block: rpcBlock, - } return nil } diff --git a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_tx.go b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_tx.go index f676aac39..310c67d1c 100644 --- a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_tx.go +++ b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_tx.go @@ -43,7 +43,7 @@ func (x *KaspadMessage_GetTxResponse) fromAppMessage(message *appmessage.GetTxRe } rpcTransaction := &RpcTransaction{} rpcTransaction.fromAppMessage(message.Transaction) - + x.GetTxResponse = &GetTxResponseMessage{ Transaction: rpcTransaction, @@ -72,7 +72,7 @@ func (x *GetTxResponseMessage) toAppMessage() (appmessage.Message, error) { } return &appmessage.GetTxResponseMessage{ - Transaction: appTransaction, - Error: rpcErr, + Transaction: appTransaction, + Error: rpcErr, }, nil } diff --git a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_tx_confirmations.go b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_tx_confirmations.go index 9726c5bed..4ea36692c 100644 --- a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_tx_confirmations.go +++ b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_tx_confirmations.go @@ -41,7 +41,7 @@ func (x *KaspadMessage_GetTxConfirmationsResponse) fromAppMessage(message *appme if message.Error != nil { rpcErr = &RPCError{Message: message.Error.Message} } - + x.GetTxConfirmationsResponse = &GetTxConfirmationsResponseMessage{ Confirmations: message.Confirmations, @@ -65,7 +65,7 @@ func (x *GetTxConfirmationsResponseMessage) toAppMessage() (appmessage.Message, } return &appmessage.GetTxConfirmationsResponseMessage{ - Confirmations: x.Confirmations, - Error: rpcErr, + Confirmations: x.Confirmations, + Error: rpcErr, }, nil } diff --git a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_txs.go b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_txs.go index c23274114..54396f642 100644 --- a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_txs.go +++ b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_txs.go @@ -46,7 +46,7 @@ func (x *KaspadMessage_GetTxsResponse) fromAppMessage(message *appmessage.GetTxs for i := range rpcTransactions { rpcTransactions[i].fromAppMessage(message.Transactions[i]) } - + x.GetTxsResponse = &GetTxsResponseMessage{ Transactions: rpcTransactions, @@ -78,7 +78,7 @@ func (x *GetTxsResponseMessage) toAppMessage() (appmessage.Message, error) { } return &appmessage.GetTxsResponseMessage{ - Transactions: appTransactions, - Error: rpcErr, + Transactions: appTransactions, + Error: rpcErr, }, nil } diff --git a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_txs_confirmations.go b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_txs_confirmations.go index 9d612cbef..07e70b011 100644 --- a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_txs_confirmations.go +++ b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_txs_confirmations.go @@ -46,7 +46,7 @@ func (x *KaspadMessage_GetTxsConfirmationsResponse) fromAppMessage(message *appm for i := range rpcTxIDConfirmationsPairs { rpcTxIDConfirmationsPairs[i].fromAppMessage(message.TxIDConfirmationsPairs[i]) } - + x.GetTxsConfirmationsResponse = &GetTxsConfirmationsResponseMessage{ TxIDConfirmationsPairs: rpcTxIDConfirmationsPairs, @@ -78,8 +78,8 @@ func (x *GetTxsConfirmationsResponseMessage) toAppMessage() (appmessage.Message, } return &appmessage.GetTxsConfirmationsResponseMessage{ - TxIDConfirmationsPairs: appTxIDConfirmationsPairs, - Error: rpcErr, + TxIDConfirmationsPairs: appTxIDConfirmationsPairs, + Error: rpcErr, }, nil } @@ -89,15 +89,15 @@ func (x *TxIDConfirmationsPair) toAppMessage() (*appmessage.TxIDConfirmationsPai } return &appmessage.TxIDConfirmationsPair{ - TxID: x.TxID, - Confirmations: x.Confirmations, + TxID: x.TxID, + Confirmations: x.Confirmations, }, nil } func (x *TxIDConfirmationsPair) fromAppMessage(message *appmessage.TxIDConfirmationsPair) { - + *x = TxIDConfirmationsPair{ - TxID: message.TxID, + TxID: message.TxID, Confirmations: message.Confirmations, } }