mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-11-24 06:25:55 +00:00
some fixes, not all commands working
This commit is contained in:
parent
1b5a236651
commit
1aa93d2fc4
@ -165,7 +165,6 @@ const (
|
||||
CmdGetCoinSupplyResponseMessage
|
||||
CmdGetAcceptingBlockHashOfTxRequestMessage
|
||||
CmdGetAcceptingBlockHashOfTxResponseMessage
|
||||
|
||||
CmdGetAcceptingBlockHashesOfTxsRequestMessage
|
||||
CmdGetAcceptingBlockHashesOfTxsResponseMessage
|
||||
CmdGetAcceptingBlockOfTxRequestMessage
|
||||
|
||||
@ -10,13 +10,14 @@ type GetAcceptingBlockOfTxRequestMessage struct {
|
||||
|
||||
// Command returns the protocol command string for the message
|
||||
func (msg *GetAcceptingBlockOfTxRequestMessage) Command() MessageCommand {
|
||||
return CmdGetAcceptingBlockHashOfTxRequestMessage
|
||||
return CmdGetAcceptingBlockOfTxRequestMessage
|
||||
}
|
||||
|
||||
// NewGetAcceptingBlockOfTxRequest returns a instance of the message
|
||||
func NewGetAcceptingBlockOfTxRequest(txID string) *GetAcceptingBlockOfTxRequestMessage {
|
||||
func NewGetAcceptingBlockOfTxRequest(txID string, includeTransactions bool) *GetAcceptingBlockOfTxRequestMessage {
|
||||
return &GetAcceptingBlockOfTxRequestMessage{
|
||||
TxID: txID,
|
||||
IncludeTransactions: includeTransactions,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -21,9 +21,10 @@ func (msg *GetAcceptingBlocksOfTxsRequestMessage) Command() MessageCommand {
|
||||
}
|
||||
|
||||
// NewGetAcceptingBlocksOfTxsRequest returns a instance of the message
|
||||
func NewGetAcceptingBlocksOfTxsRequest(txIDs []string) *GetAcceptingBlocksOfTxsRequestMessage {
|
||||
func NewGetAcceptingBlocksOfTxsRequest(txIDs []string, includeTransactions bool) *GetAcceptingBlocksOfTxsRequestMessage {
|
||||
return &GetAcceptingBlocksOfTxsRequestMessage{
|
||||
TxIDs: txIDs,
|
||||
IncludeTransactions: includeTransactions,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -52,6 +52,15 @@ var handlers = map[appmessage.MessageCommand]handler{
|
||||
appmessage.CmdGetCoinSupplyRequestMessage: rpchandlers.HandleGetCoinSupply,
|
||||
appmessage.CmdGetMempoolEntriesByAddressesRequestMessage: rpchandlers.HandleGetMempoolEntriesByAddresses,
|
||||
appmessage.CmdGetAcceptingBlockHashOfTxRequestMessage: rpchandlers.HandleGetAcceptingBlockHashOfTx,
|
||||
appmessage.CmdGetAcceptingBlockHashesOfTxsRequestMessage: rpchandlers.HandleGetAcceptingBlockHashesOfTxs,
|
||||
appmessage.CmdGetAcceptingBlockOfTxRequestMessage: rpchandlers.HandleGetAcceptingBlockOfTx,
|
||||
appmessage.CmdGetAcceptingBlocksOfTxsRequestMessage: rpchandlers.HandleGetAcceptingBlocksOfTxs,
|
||||
appmessage.CmdGetIncludingBlockHashOfTxRequestMessage: rpchandlers.HandleGetIncludingBlockHashOfTx,
|
||||
appmessage.CmdGetTxRequestMessage: rpchandlers.HandleGetTx,
|
||||
appmessage.CmdGetTxsRequestMessage: rpchandlers.HandleGetTxs,
|
||||
appmessage.CmdGetTxConfirmationsRequestMessage: rpchandlers.HandleGetTxConfirmations,
|
||||
appmessage.CmdGetTxsConfirmationsRequestMessage: rpchandlers.HandleGetTxsConfirmations,
|
||||
|
||||
}
|
||||
|
||||
func (m *Manager) routerInitializer(router *router.Router, netConnection *netadapter.NetConnection) {
|
||||
|
||||
@ -18,9 +18,9 @@ func HandleGetAcceptingBlockOfTx(context *rpccontext.Context, _ *router.Router,
|
||||
return errorMessage, nil
|
||||
}
|
||||
|
||||
getAcceptingBlockHashOfTxRequest := request.(*appmessage.GetAcceptingBlockOfTxRequestMessage)
|
||||
getAcceptingBlockOfTxRequest := request.(*appmessage.GetAcceptingBlockOfTxRequestMessage)
|
||||
|
||||
domainTxID, err := externalapi.NewDomainTransactionIDFromString(getAcceptingBlockHashOfTxRequest.TxID)
|
||||
domainTxID, err := externalapi.NewDomainTransactionIDFromString(getAcceptingBlockOfTxRequest.TxID)
|
||||
if err != nil {
|
||||
rpcError := &appmessage.RPCError{}
|
||||
if !errors.As(err, &rpcError) {
|
||||
@ -48,7 +48,7 @@ func HandleGetAcceptingBlockOfTx(context *rpccontext.Context, _ *router.Router,
|
||||
}
|
||||
|
||||
rpcAcceptingBlock := appmessage.DomainBlockToRPCBlock(acceptingBlock)
|
||||
err = context.PopulateBlockWithVerboseData(rpcAcceptingBlock, acceptingBlock.Header, acceptingBlock, getAcceptingBlockHashOfTxRequest.IncludeTransactions)
|
||||
err = context.PopulateBlockWithVerboseData(rpcAcceptingBlock, acceptingBlock.Header, acceptingBlock, getAcceptingBlockOfTxRequest.IncludeTransactions)
|
||||
if err != nil {
|
||||
if errors.Is(err, rpccontext.ErrBuildBlockVerboseDataInvalidBlock) {
|
||||
errorMessage := &appmessage.GetAcceptingBlockOfTxResponseMessage{}
|
||||
|
||||
@ -10,8 +10,8 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// HandleGetAcceptingBlocksOfTx handles the respectively named RPC command
|
||||
func HandleGetAcceptingBlocksOfTx(context *rpccontext.Context, _ *router.Router, request appmessage.Message) (appmessage.Message, error) {
|
||||
// HandleGetAcceptingBlocksOfTxs handles the respectively named RPC command
|
||||
func HandleGetAcceptingBlocksOfTxs(context *rpccontext.Context, _ *router.Router, request appmessage.Message) (appmessage.Message, error) {
|
||||
var err error
|
||||
|
||||
if !context.Config.TXIndex {
|
||||
|
||||
@ -2,6 +2,7 @@ package rpchandlers
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/kaspanet/kaspad/app/appmessage"
|
||||
"github.com/kaspanet/kaspad/app/rpc/rpccontext"
|
||||
@ -54,6 +55,9 @@ func HandleGetTxsConfirmations(context *rpccontext.Context, _ *router.Router, re
|
||||
i++
|
||||
}
|
||||
|
||||
fmt.Println(txIDConfirmationPairs[0].Confirmations)
|
||||
fmt.Println(txIDConfirmationPairs[1].Confirmations)
|
||||
|
||||
response := appmessage.NewGetTxsConfirmationsResponse(txIDConfirmationPairs)
|
||||
|
||||
return response, nil
|
||||
|
||||
@ -34,7 +34,7 @@ func New(domain domain.Domain, database database.Database) (*TXIndex, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !isSynced {
|
||||
if !isSynced || true {
|
||||
|
||||
err := txIndex.Reset()
|
||||
if err != nil {
|
||||
@ -187,7 +187,7 @@ func (ti *TXIndex) addTXIDs(selectedParentChainChanges *externalapi.SelectedChai
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for i, addedChainBlock := range chainBlocksChunk {
|
||||
for i := range chainBlocksChunk {
|
||||
chainBlockAcceptanceData := chainBlocksAcceptanceData[i]
|
||||
for _, blockAcceptanceData := range chainBlockAcceptanceData {
|
||||
for _, transactionAcceptanceData := range blockAcceptanceData.TransactionAcceptanceData {
|
||||
@ -195,7 +195,7 @@ func (ti *TXIndex) addTXIDs(selectedParentChainChanges *externalapi.SelectedChai
|
||||
if transactionAcceptanceData.IsAccepted {
|
||||
ti.store.add(
|
||||
*consensushashing.TransactionID(transactionAcceptanceData.Transaction),
|
||||
addedChainBlock,
|
||||
blockAcceptanceData.BlockHash,
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -222,7 +222,7 @@ func (ti *TXIndex) removeTXIDs(selectedParentChainChanges *externalapi.SelectedC
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for i, removedChainBlock := range chainBlocksChunk {
|
||||
for i := range chainBlocksChunk {
|
||||
chainBlockAcceptanceData := chainBlocksAcceptanceData[i]
|
||||
for _, blockAcceptanceData := range chainBlockAcceptanceData {
|
||||
log.Tracef("TX index Removing: %d transactions", len(blockAcceptanceData.TransactionAcceptanceData))
|
||||
@ -230,7 +230,7 @@ func (ti *TXIndex) removeTXIDs(selectedParentChainChanges *externalapi.SelectedC
|
||||
if transactionAcceptanceData.IsAccepted {
|
||||
ti.store.remove(
|
||||
*consensushashing.TransactionID(transactionAcceptanceData.Transaction),
|
||||
removedChainBlock,
|
||||
blockAcceptanceData.BlockHash,
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -350,12 +350,9 @@ func (ti *TXIndex) GetTX(txID *externalapi.DomainTransactionID) (
|
||||
return nil, false, err
|
||||
}
|
||||
|
||||
var transaction *externalapi.DomainTransaction
|
||||
|
||||
for _, tx := range acceptingBlock.Transactions {
|
||||
if consensushashing.TransactionID(tx).Equal(txID) {
|
||||
transaction = tx
|
||||
return transaction, true, nil
|
||||
for i := range acceptingBlock.Transactions {
|
||||
if consensushashing.TransactionID(acceptingBlock.Transactions[i]).Equal(txID) {
|
||||
return acceptingBlock.Transactions[i].Clone(), true, nil
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3,8 +3,8 @@ package rpcclient
|
||||
import "github.com/kaspanet/kaspad/app/appmessage"
|
||||
|
||||
// GetAcceptingBlockOfTx sends an RPC request respective to the function's name and returns the RPC server's response
|
||||
func (c *RPCClient) GetAcceptingBlockOfTx(txID string) (*appmessage.GetAcceptingBlockOfTxResponseMessage, error) {
|
||||
err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewGetAcceptingBlockOfTxRequest(txID))
|
||||
func (c *RPCClient) GetAcceptingBlockOfTx(txID string, includeTransactions bool) (*appmessage.GetAcceptingBlockOfTxResponseMessage, error) {
|
||||
err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewGetAcceptingBlockOfTxRequest(txID, includeTransactions))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -2,8 +2,8 @@ package rpcclient
|
||||
|
||||
import "github.com/kaspanet/kaspad/app/appmessage"
|
||||
|
||||
// GetAcceptingBlockHashOfTxs sends an RPC request respective to the function's name and returns the RPC server's response
|
||||
func (c *RPCClient) GetAcceptingBlockHashOfTxs(txID string) (*appmessage.GetAcceptingBlockHashOfTxResponseMessage, error) {
|
||||
// GetAcceptingBlockHashOfTx sends an RPC request respective to the function's name and returns the RPC server's response
|
||||
func (c *RPCClient) GetAcceptingBlockHashOfTx(txID string) (*appmessage.GetAcceptingBlockHashOfTxResponseMessage, error) {
|
||||
err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewGetAcceptingBlockHashOfTxRequest(txID))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@ -3,8 +3,8 @@ package rpcclient
|
||||
import "github.com/kaspanet/kaspad/app/appmessage"
|
||||
|
||||
// GetAcceptingBlocksTxs sends an RPC request respective to the function's name and returns the RPC server's response
|
||||
func (c *RPCClient) GetAcceptingBlocksTxs(txIDs []string) (*appmessage.GetAcceptingBlocksOfTxsResponseMessage, error) {
|
||||
err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewGetAcceptingBlocksOfTxsRequest(txIDs))
|
||||
func (c *RPCClient) GetAcceptingBlocksTxs(txIDs []string, includeTransactions bool) (*appmessage.GetAcceptingBlocksOfTxsResponseMessage, error) {
|
||||
err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewGetAcceptingBlocksOfTxsRequest(txIDs, includeTransactions))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user