mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-11-24 06:25:55 +00:00
add to verbose data and getInfo
This commit is contained in:
parent
f820acd7df
commit
735f9c29e0
@ -24,6 +24,8 @@ type GetInfoResponseMessage struct {
|
||||
MempoolSize uint64
|
||||
ServerVersion string
|
||||
IsUtxoIndexed bool
|
||||
IsTxIndexed bool
|
||||
IsArchival bool
|
||||
IsSynced bool
|
||||
|
||||
Error *RPCError
|
||||
@ -35,12 +37,15 @@ func (msg *GetInfoResponseMessage) Command() MessageCommand {
|
||||
}
|
||||
|
||||
// NewGetInfoResponseMessage returns a instance of the message
|
||||
func NewGetInfoResponseMessage(p2pID string, mempoolSize uint64, serverVersion string, isUtxoIndexed bool, isSynced bool) *GetInfoResponseMessage {
|
||||
func NewGetInfoResponseMessage(p2pID string, mempoolSize uint64, serverVersion string, isUtxoIndexed bool,
|
||||
isTxIndexed bool, isArchival bool, isSynced bool) *GetInfoResponseMessage {
|
||||
return &GetInfoResponseMessage{
|
||||
P2PID: p2pID,
|
||||
MempoolSize: mempoolSize,
|
||||
ServerVersion: serverVersion,
|
||||
IsUtxoIndexed: isUtxoIndexed,
|
||||
IsTxIndexed: isTxIndexed,
|
||||
IsArchival: isArchival,
|
||||
IsSynced: isSynced,
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,6 +102,9 @@ type RPCTransactionVerboseData struct {
|
||||
Mass uint64
|
||||
BlockHash string
|
||||
BlockTime uint64
|
||||
TxIndexed bool
|
||||
AcceptingBlockHash string
|
||||
Confirmations uint32
|
||||
}
|
||||
|
||||
// RPCTransactionInputVerboseData holds data about a transaction input
|
||||
|
||||
@ -128,6 +128,26 @@ func (ctx *Context) PopulateTransactionWithVerboseData(
|
||||
Hash: consensushashing.TransactionHash(domainTransaction).String(),
|
||||
Mass: domainTransaction.Mass,
|
||||
}
|
||||
if ctx.Config.TXIndex {
|
||||
acceptingBlockHash, foundAcceptingBlockHash, err := ctx.TXIndex.TXAcceptingBlockHash(domainTransaction.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
confirmations, foundConfirmations, err := ctx.TXIndex.GetTXConfirmations(domainTransaction.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !foundAcceptingBlockHash || !foundConfirmations {
|
||||
transaction.VerboseData.TxIndexed = false
|
||||
} else {
|
||||
transaction.VerboseData.TxIndexed = true
|
||||
transaction.VerboseData.AcceptingBlockHash = acceptingBlockHash.String()
|
||||
transaction.VerboseData.Confirmations = uint32(confirmations)
|
||||
}
|
||||
} else {
|
||||
transaction.VerboseData.TxIndexed = false
|
||||
}
|
||||
|
||||
if domainBlockHeader != nil {
|
||||
transaction.VerboseData.BlockHash = consensushashing.HeaderHash(domainBlockHeader).String()
|
||||
transaction.VerboseData.BlockTime = uint64(domainBlockHeader.TimeInMilliseconds())
|
||||
|
||||
@ -19,6 +19,8 @@ func HandleGetInfo(context *rpccontext.Context, _ *router.Router, _ appmessage.M
|
||||
uint64(context.Domain.MiningManager().TransactionCount(true, false)),
|
||||
version.Version(),
|
||||
context.Config.UTXOIndex,
|
||||
context.Config.TXIndex,
|
||||
context.Config.IsArchivalNode,
|
||||
context.ProtocolManager.Context().HasPeers() && isNearlySynced,
|
||||
)
|
||||
|
||||
|
||||
@ -249,6 +249,26 @@ func (ti *TXIndex) removeTXIDs(selectedParentChainChanges *externalapi.SelectedC
|
||||
return nil
|
||||
}
|
||||
|
||||
// TXAcceptingBlockHash returns the accepting block hash for for the given txID
|
||||
func (ti *TXIndex) TXAcceptingBlockHash(txID *externalapi.DomainTransactionID) (
|
||||
acceptingBlockHash *externalapi.DomainHash, found bool, err error) {
|
||||
onEnd := logger.LogAndMeasureExecutionTime(log, "TXIndex.TXAcceptingBlockHash")
|
||||
defer onEnd()
|
||||
|
||||
ti.mutex.Lock()
|
||||
defer ti.mutex.Unlock()
|
||||
|
||||
txData, found, err := ti.store.getTxData(txID)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
if !found {
|
||||
return nil, false, nil
|
||||
}
|
||||
|
||||
return txData.AcceptingBlockHash, found, nil
|
||||
}
|
||||
|
||||
// TXAcceptingBlockHashes returns the accepting block hashes for for the given txIDs
|
||||
func (ti *TXIndex) TXAcceptingBlockHashes(txIDs []*externalapi.DomainTransactionID) (
|
||||
txIDsToAcceptingBlockHashes TxIDsToBlockHashes, missingTxIds []*externalapi.DomainTransactionID, err error) {
|
||||
@ -305,6 +325,33 @@ func (ti *TXIndex) GetTXs(txIDs []*externalapi.DomainTransactionID) (
|
||||
return txs, notFound, nil
|
||||
}
|
||||
|
||||
// GetTXConfirmations returns the tx confirmations for for the given txID
|
||||
func (ti *TXIndex) GetTXConfirmations(txID *externalapi.DomainTransactionID) (
|
||||
confirmations int64, found bool, err error) {
|
||||
onEnd := logger.LogAndMeasureExecutionTime(log, "TXIndex.GetTXConfirmations")
|
||||
defer onEnd()
|
||||
|
||||
ti.mutex.Lock()
|
||||
defer ti.mutex.Unlock()
|
||||
|
||||
txdata, found, err := ti.store.getTxData(txID)
|
||||
if err != nil {
|
||||
return 0, false, err
|
||||
}
|
||||
|
||||
acceptingBlockHeader, err := ti.domain.Consensus().GetBlockHeader(txdata.AcceptingBlockHash)
|
||||
if err != nil {
|
||||
return -1, false, err
|
||||
}
|
||||
|
||||
virtualBlock, err := ti.domain.Consensus().GetVirtualInfo()
|
||||
if err != nil {
|
||||
return 0, false, err
|
||||
}
|
||||
|
||||
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) (
|
||||
txIDsToConfirmations TxIDsToConfirmations, notFound []*externalapi.DomainTransactionID, err error) {
|
||||
|
||||
@ -376,6 +376,9 @@ Receivers of any ResponseMessage are expected to check whether its error field i
|
||||
| mass | [uint64](#uint64) | | |
|
||||
| blockHash | [string](#string) | | |
|
||||
| blockTime | [uint64](#uint64) | | |
|
||||
| txIndexed | [bool](#bool) | | whether the transaction is stored in the txindex database. Kaspad must be started with the `--txindex` flag, for parameter to display. |
|
||||
| acceptingBlockHash | [string](#string) | | Kaspad must be started with the `--txindex` flag, for parameter to display. |
|
||||
| confirmations | [uint32](#uint32) | | Kaspad must be started with the `--txindex` flag for parameter to display. |
|
||||
|
||||
|
||||
|
||||
@ -1963,7 +1966,7 @@ See NotifyNewBlockTemplateRequestMessage
|
||||
<a name="protowire.GetAcceptingBlockHashesOfTxsRequestMessage"></a>
|
||||
|
||||
### GetAcceptingBlockHashesOfTxsRequestMessage
|
||||
Kaspad most be started with the `--txindex` flag for this Request to work.
|
||||
Kaspad must be started with the `--txindex` flag for this Request to work.
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
@ -1994,7 +1997,7 @@ Kaspad most be started with the `--txindex` flag for this Request to work.
|
||||
<a name="protowire.GetTxsRequestMessage"></a>
|
||||
|
||||
### GetTxsRequestMessage
|
||||
Kaspad most be started with the `--txindex` flag for this Request to work.
|
||||
Kaspad must be started with the `--txindex` flag for this Request to work.
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
@ -2025,7 +2028,7 @@ Kaspad most be started with the `--txindex` flag for this Request to work.
|
||||
<a name="protowire.GetTxsConfirmationsRequestMessage"></a>
|
||||
|
||||
### GetTxsConfirmationsRequestMessage
|
||||
Kaspad most be started with the `--txindex` flag for this Request to work.
|
||||
Kaspad must be started with the `--txindex` flag for this Request to work.
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
@ -2057,7 +2060,7 @@ Kaspad most be started with the `--txindex` flag for this Request to work.
|
||||
|
||||
### NotifyTxsConfirmationChangedRequestMessage
|
||||
NotifyTxsConfirmationChangedRequstMessage is a listener that registers confirmations from supplied TxIDs
|
||||
Kaspad most be started with the `--txindex` flag for this Request to work.
|
||||
Kaspad must be started with the `--txindex` flag for this Request to work.
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
@ -2109,13 +2112,13 @@ TxsConfirmationChangedNotificationMessage is the notification about txs pertaini
|
||||
|
||||
### ModifyNotifyingTxsConfirmationChangedRequestMessage
|
||||
ModifyNotifyingTxsConfirmationChangedRequestMessage modfies the params of a registered `NotifyTxsConfirmationChangedRequstMessage`
|
||||
most be registered to NotifyTxsConfirmationChangedRequstMessage for this command to work
|
||||
must be registered to NotifyTxsConfirmationChangedRequstMessage for this command to work
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| addTxIDs | [string](#string) | repeated | |
|
||||
| removeTxIDs | [string](#string) | repeated | |
|
||||
| addTxIDs | [string](#string) | repeated | add txIds to the notification stream |
|
||||
| removeTxIDs | [string](#string) | repeated | remove txIds to the notification stream |
|
||||
| requiredConfirmations | [uint32](#uint32) | | |
|
||||
| includePending | [bool](#bool) | | |
|
||||
|
||||
@ -2210,13 +2213,13 @@ NotifyAddressesTxsChangedRequestMessage Listens for Txs pertaining to specified
|
||||
|
||||
### ModifyNotifyingAddressesTxsRequestMessage
|
||||
ModifyNotifyAddressesTxsParamsRequestMessage modifies the params used for a regesitered `NotifyAddressesTxsRequest`
|
||||
Most be registered to NotifyAddressTxChangedRequestMessage for this command to work
|
||||
Must be registered to NotifyAddressTxChangedRequestMessage for this command to work
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| AddAddresses | [string](#string) | repeated | |
|
||||
| RemoveAddresses | [string](#string) | repeated | |
|
||||
| AddAddresses | [string](#string) | repeated | add addresses to the notification stream |
|
||||
| RemoveAddresses | [string](#string) | repeated | remove addresses to the notification stream |
|
||||
| requiredConfirmations | [uint32](#uint32) | | |
|
||||
| includePending | [bool](#bool) | | |
|
||||
| includeSending | [bool](#bool) | | |
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -105,6 +105,9 @@ message RpcTransactionVerboseData{
|
||||
uint64 mass = 4;
|
||||
string blockHash = 12;
|
||||
uint64 blockTime = 14;
|
||||
bool txIndexed = 15; //whether the transaction is stored in the txindex database, regardless if kaspad is run with the `--txindex` flag, or not.
|
||||
string acceptingBlockHash = 16; // Kaspad must be started with the `--txindex` flag, for parameter to display.
|
||||
uint32 confirmations = 17; // Kaspad must be started with the `--txindex` flag for parameter to display.
|
||||
}
|
||||
|
||||
message RpcTransactionInputVerboseData{
|
||||
@ -662,7 +665,10 @@ message GetInfoResponseMessage{
|
||||
uint64 mempoolSize = 2;
|
||||
string serverVersion = 3;
|
||||
bool isUtxoIndexed = 4;
|
||||
bool isSynced = 5;
|
||||
bool isTxIndexed = 5;
|
||||
bool isArchival = 6;
|
||||
bool isSynced = 7;
|
||||
|
||||
RPCError error = 1000;
|
||||
}
|
||||
|
||||
@ -749,7 +755,7 @@ message RpcTxIDBlockPair {
|
||||
RpcBlock block = 2;
|
||||
}
|
||||
|
||||
// Kaspad most be started with the `--txindex` flag for this Request to work.
|
||||
// Kaspad must be started with the `--txindex` flag for this Request to work.
|
||||
message GetAcceptingBlockHashesOfTxsRequestMessage{
|
||||
repeated string txIDs = 1;
|
||||
}
|
||||
@ -759,7 +765,7 @@ message GetAcceptingBlockHashesOfTxsResponseMessage{
|
||||
RPCError error = 1000;
|
||||
}
|
||||
|
||||
// Kaspad most be started with the `--txindex` flag for this Request to work.
|
||||
// Kaspad must be started with the `--txindex` flag for this Request to work.
|
||||
message GetTxsRequestMessage{
|
||||
repeated string txIDs = 1;
|
||||
}
|
||||
@ -772,7 +778,7 @@ message GetTxsResponseMessage{
|
||||
}
|
||||
|
||||
|
||||
//Kaspad most be started with the `--txindex` flag for this Request to work.
|
||||
// Kaspad must be started with the `--txindex` flag for this Request to work.
|
||||
message GetTxsConfirmationsRequestMessage{
|
||||
repeated string txIDs = 1;
|
||||
}
|
||||
@ -784,7 +790,7 @@ message GetTxsConfirmationsResponseMessage{
|
||||
}
|
||||
|
||||
// NotifyTxsConfirmationChangedRequstMessage is a listener that registers confirmations from supplied TxIDs
|
||||
// Kaspad most be started with the `--txindex` flag for this Request to work.
|
||||
// Kaspad must be started with the `--txindex` flag for this Request to work.
|
||||
message NotifyTxsConfirmationChangedRequestMessage{
|
||||
repeated string TxIDs = 1; //initial TxIds to listen for when regestering for notifications
|
||||
|
||||
@ -809,10 +815,10 @@ message TxsConfirmationChangedNotificationMessage{
|
||||
}
|
||||
|
||||
// ModifyNotifyingTxsConfirmationChangedRequestMessage modfies the params of a registered `NotifyTxsConfirmationChangedRequstMessage`
|
||||
// most be registered to NotifyTxsConfirmationChangedRequstMessage for this command to work
|
||||
// must be registered to NotifyTxsConfirmationChangedRequstMessage for this command to work
|
||||
message ModifyNotifyingTxsConfirmationChangedRequestMessage{
|
||||
repeated string addTxIDs = 1;
|
||||
repeated string removeTxIDs = 2;
|
||||
repeated string addTxIDs = 1; //add txIds to the notification stream
|
||||
repeated string removeTxIDs = 2; //remove txIds to the notification stream
|
||||
uint32 requiredConfirmations = 3;
|
||||
bool includePending = 4;
|
||||
}
|
||||
@ -842,15 +848,14 @@ message NotifyAddressesTxsRequestMessage{
|
||||
}
|
||||
|
||||
message NotifyAddressesTxsResponseMessage{
|
||||
|
||||
RPCError error = 1000;
|
||||
}
|
||||
|
||||
// ModifyNotifyAddressesTxsParamsRequestMessage modifies the params used for a regesitered `NotifyAddressesTxsRequest`
|
||||
// Most be registered to NotifyAddressTxChangedRequestMessage for this command to work
|
||||
// Must be registered to NotifyAddressTxChangedRequestMessage for this command to work
|
||||
message ModifyNotifyingAddressesTxsRequestMessage{
|
||||
repeated string AddAddresses = 1;
|
||||
repeated string RemoveAddresses = 2;
|
||||
repeated string AddAddresses = 1; //add addresses to the notification stream
|
||||
repeated string RemoveAddresses = 2; //remove addresses to the notification stream
|
||||
uint32 requiredConfirmations = 3;
|
||||
bool includePending = 4;
|
||||
bool includeSending = 5;
|
||||
|
||||
@ -31,6 +31,8 @@ func (x *KaspadMessage_GetInfoResponse) fromAppMessage(message *appmessage.GetIn
|
||||
ServerVersion: message.ServerVersion,
|
||||
MempoolSize: message.MempoolSize,
|
||||
IsUtxoIndexed: message.IsUtxoIndexed,
|
||||
IsTxIndexed: message.IsTxIndexed;
|
||||
IsArchival: message.IsArchival;
|
||||
IsSynced: message.IsSynced,
|
||||
Error: err,
|
||||
}
|
||||
@ -56,6 +58,8 @@ func (x *GetInfoResponseMessage) toAppMessage() (appmessage.Message, error) {
|
||||
MempoolSize: x.MempoolSize,
|
||||
ServerVersion: x.ServerVersion,
|
||||
IsUtxoIndexed: x.IsUtxoIndexed,
|
||||
IsTxIndexed: x.IsTxIndexed;
|
||||
IsArchival: x.IsArchival;
|
||||
IsSynced: x.IsSynced,
|
||||
|
||||
Error: rpcErr,
|
||||
|
||||
@ -14,6 +14,8 @@ func (x *KaspadMessage_ModifyNotifyingAddressesTxsRequest) toAppMessage() (appme
|
||||
|
||||
func (x *KaspadMessage_ModifyNotifyingAddressesTxsRequest) fromAppMessage(message *appmessage.ModifyNotifyingAddressesTxsRequestMessage) error {
|
||||
x.ModifyNotifyingAddressesTxsRequest = &ModifyNotifyingAddressesTxsRequestMessage{
|
||||
AddAddresses: message.AddAddresses,
|
||||
RemoveAddresses: message.RemoveAddresses,
|
||||
RequiredConfirmations: message.RequiredConfirmations,
|
||||
IncludePending: message.IncludePending,
|
||||
IncludeSending: message.IncludeSending,
|
||||
@ -27,6 +29,8 @@ func (x *ModifyNotifyingAddressesTxsRequestMessage) toAppMessage() (appmessage.M
|
||||
return nil, errors.Wrapf(errorNil, "ModifyNotifyingAddressesTxsRequestMessage is nil")
|
||||
}
|
||||
return &appmessage.ModifyNotifyingAddressesTxsRequestMessage{
|
||||
AddAddresses: x.AddAddresses,
|
||||
RemoveAddresses: x.RemoveAddresses,
|
||||
RequiredConfirmations: x.RequiredConfirmations,
|
||||
IncludePending: x.IncludePending,
|
||||
IncludeSending: x.IncludeSending,
|
||||
|
||||
@ -14,6 +14,8 @@ func (x *KaspadMessage_ModifyNotifyingTxsConfirmationChangedRequest) toAppMessag
|
||||
|
||||
func (x *KaspadMessage_ModifyNotifyingTxsConfirmationChangedRequest) fromAppMessage(message *appmessage.ModifyNotifyingTxsConfirmationChangedRequestMessage) error {
|
||||
x.ModifyNotifyingTxsConfirmationChangedRequest = &ModifyNotifyingTxsConfirmationChangedRequestMessage{
|
||||
AddTxIDs: message.AddTxIDs,
|
||||
RemoveTxIDs: message.RemoveTxIDs,
|
||||
RequiredConfirmations: message.RequiredConfirmations,
|
||||
IncludePending: message.IncludePending,
|
||||
}
|
||||
@ -25,6 +27,8 @@ func (x *ModifyNotifyingTxsConfirmationChangedRequestMessage) toAppMessage() (ap
|
||||
return nil, errors.Wrapf(errorNil, "ModifyNotifyingTxsConfirmationChangedRequestMessage is nil")
|
||||
}
|
||||
return &appmessage.ModifyNotifyingTxsConfirmationChangedRequestMessage{
|
||||
AddTxIDs: x.AddTxIDs,
|
||||
RemoveTxIDs: x.RemoveTxIDs,
|
||||
RequiredConfirmations: x.RequiredConfirmations,
|
||||
IncludePending: x.IncludePending,
|
||||
}, nil
|
||||
|
||||
@ -299,6 +299,9 @@ func (x *RpcTransactionVerboseData) toAppMessage() (*appmessage.RPCTransactionVe
|
||||
Mass: x.Mass,
|
||||
BlockHash: x.BlockHash,
|
||||
BlockTime: x.BlockTime,
|
||||
TxIndexed: x.TxIndexed,
|
||||
AcceptingBlockHash: x.AcceptingBlockHash,
|
||||
Confirmations: x.Confirmations,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -309,6 +312,9 @@ func (x *RpcTransactionVerboseData) fromAppMessage(message *appmessage.RPCTransa
|
||||
Mass: message.Mass,
|
||||
BlockHash: message.BlockHash,
|
||||
BlockTime: message.BlockTime,
|
||||
TxIndexed: message.TxIndexed,
|
||||
AcceptingBlockHash: message.AcceptingBlockHash,
|
||||
Confirmations: message.Confirmations,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user