Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database: Add --txIndex to kaspad #2103

Open
wants to merge 56 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
3a33c0f
starting checkpoint
D-Stacks Jun 20, 2022
345eaac
preliminary draft
D-Stacks Jun 21, 2022
c339398
mostly remove old code from first round.
D-Stacks Jun 21, 2022
540d77f
remove leftover from copy pasting and bug splattering
D-Stacks Jun 21, 2022
d9b5f0e
remove smaller bugs and unused code.
D-Stacks Jun 21, 2022
da7a9dd
Merge branch 'dev' into add-tx-index
D-Stacks Jun 21, 2022
02326dc
proper naming and fmt / formatting
D-Stacks Jun 22, 2022
66809e9
Merge branch 'add-tx-index' of https://github.com/D-Stacks/kaspad int…
D-Stacks Jun 22, 2022
346bd26
turn pruning point changes into a consensus event
D-Stacks Jun 22, 2022
463db63
add minimal rpc for usecase and testing.
D-Stacks Jun 24, 2022
e059e88
include removal logic in txindex
D-Stacks Jun 24, 2022
b4754d4
fix cases of nil pointers...
D-Stacks Jun 24, 2022
560a1a9
linting and deal with pruning point commitment
D-Stacks Jun 24, 2022
09b2c53
fix not found sending err, add to kaspactl
D-Stacks Jun 24, 2022
600f39f
fix pruning notification
D-Stacks Jun 24, 2022
8bacd2e
logger to tracef
D-Stacks Jun 24, 2022
edb6962
Merge branch 'dev' into add-tx-index
D-Stacks Jun 29, 2022
576a24a
update with dev
D-Stacks Aug 29, 2022
ca01c1f
fic virtual change nil
D-Stacks Aug 29, 2022
de5f551
Merge branch 'dev' into add-tx-index
D-Stacks Sep 2, 2022
87c5ad0
Merge branch 'dev' into add-tx-index
D-Stacks Sep 10, 2022
f7fcffe
save changes
D-Stacks Sep 13, 2022
11f5a49
pass tests
D-Stacks Oct 9, 2022
9b6c2e3
generate the protos
D-Stacks Oct 9, 2022
3b317fc
Merge branch 'dev' into add-tx-index
D-Stacks Oct 9, 2022
cc937a2
set up commands
D-Stacks Oct 9, 2022
1593769
add appmessages
D-Stacks Oct 10, 2022
06c6706
pass tests - linting & fmt
D-Stacks Oct 10, 2022
38e9ab8
set up appmessage converters
D-Stacks Oct 10, 2022
e8e57fc
checkpoint: started work on handlers
D-Stacks Oct 10, 2022
4c9aa95
finish handlers
D-Stacks Oct 10, 2022
8f1348b
set-up client commnds
D-Stacks Oct 10, 2022
3c94c86
fix fmt and linting
D-Stacks Oct 10, 2022
1b5a236
include commands in kaspactl
D-Stacks Oct 10, 2022
1aa93d2
some fixes, not all commands working
D-Stacks Oct 10, 2022
325d2fd
fix batched calls
D-Stacks Oct 10, 2022
7336b2d
fix fmt
D-Stacks Oct 10, 2022
d401cac
store accepting + including block + index
D-Stacks Oct 13, 2022
6f1456c
expose including & accepting blocks
D-Stacks Oct 14, 2022
4ac225c
Merge branch 'dev' into add-tx-index
D-Stacks Oct 14, 2022
32205a2
implement protobuf txindex notifications
D-Stacks Oct 14, 2022
a905e34
Merge branch 'add-tx-index' of https://github.com/D-Stacks/kaspad int…
D-Stacks Oct 14, 2022
22aeb04
update listener protos
D-Stacks Oct 14, 2022
1f8fe53
add listener converters.
D-Stacks Oct 15, 2022
8875d66
downsize up rpc commands
D-Stacks Oct 16, 2022
231633f
remove excess functions from txindex
D-Stacks Oct 16, 2022
f820acd
remove some more
D-Stacks Oct 16, 2022
735f9c2
add to verbose data and getInfo
D-Stacks Oct 16, 2022
d6f0a16
handle error properly
D-Stacks Oct 16, 2022
f6d1493
set-up app messages for notifications
D-Stacks Oct 16, 2022
e9f7169
fix converters
D-Stacks Oct 16, 2022
ee09eb5
fix fmt and linting
D-Stacks Oct 16, 2022
cdcdfc4
start work on listening logic
D-Stacks Oct 16, 2022
fa5423e
add addrsindex to txindex.
D-Stacks Oct 21, 2022
cc05cfa
add access to addr index
D-Stacks Oct 23, 2022
a2c851f
finish accesss function
D-Stacks Oct 23, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions app/appmessage/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,22 @@ const (
CmdGetMempoolEntriesByAddressesResponseMessage
CmdGetCoinSupplyRequestMessage
CmdGetCoinSupplyResponseMessage
CmdGetAcceptingBlockHashesOfTxsRequestMessage
CmdGetAcceptingBlockHashesOfTxsResponseMessage
CmdGetTxsRequestMessage
CmdGetTxsResponseMessage
CmdGetTxsConfirmationsRequestMessage
CmdGetTxsConfirmationsResponseMessage
CmdNotifyTxsConfirmationChangedRequestMessage
CmdNotifyTxsConfirmationChangedResponseMessage
CmdModifyNotifyingTxsConfirmationChangedRequestMessage
CmdModifyNotifyingTxsConfirmationChangedResponseMessage
CmdTxsConfirmationChangedNotificationMessage
CmdNotifyAddressesTxsRequestMessage
CmdNotifyAddressesTxsResponseMessage
CmdModifyNotifyingAddressesTxsRequestMessage
CmdModifyNotifyingAddressesTxsResponseMessage
CmdAddressesTxsNotificationMessage
)

// ProtocolMessageCommandToString maps all MessageCommands to their string representation
Expand Down Expand Up @@ -300,6 +316,22 @@ var RPCMessageCommandToString = map[MessageCommand]string{
CmdGetMempoolEntriesByAddressesResponseMessage: "GetMempoolEntriesByAddressesResponse",
CmdGetCoinSupplyRequestMessage: "GetCoinSupplyRequest",
CmdGetCoinSupplyResponseMessage: "GetCoinSupplyResponse",
CmdGetAcceptingBlockHashesOfTxsRequestMessage: "GetAcceptingBlockHashesOfTxsRequest",
CmdGetAcceptingBlockHashesOfTxsResponseMessage: "GetAcceptingBlockHashesOfTxsResponse",
CmdGetTxsRequestMessage: "GetTxsRequest",
CmdGetTxsResponseMessage: "GetTxsResponse",
CmdGetTxsConfirmationsRequestMessage: "GetTxsConfirmationsRequest",
CmdGetTxsConfirmationsResponseMessage: "GetTxsConfirmationsResponse",
CmdNotifyTxsConfirmationChangedRequestMessage: "NotifyTxsConfirmationChangedRequest",
CmdNotifyTxsConfirmationChangedResponseMessage: "ModifyNotifyingTxsConfirmationChangedRequest",
CmdModifyNotifyingTxsConfirmationChangedRequestMessage: "ModifyNotifyingTxsConfirmationChangedResponse",
CmdModifyNotifyingTxsConfirmationChangedResponseMessage: "TxsConfirmationChangedNotification",
CmdTxsConfirmationChangedNotificationMessage: "TxsConfirmationChangedNotification",
CmdNotifyAddressesTxsRequestMessage: "NotifyAddressesTxsRequest",
CmdNotifyAddressesTxsResponseMessage: "NotifyAddressesTxsResponse",
CmdModifyNotifyingAddressesTxsRequestMessage: "ModifyNotifyingAddressesTxsRequest",
CmdModifyNotifyingAddressesTxsResponseMessage: "ModifyNotifyingAddressesTxsResponse",
CmdAddressesTxsNotificationMessage: "AddressesTxsNotification",
}

// Message is an interface that describes a kaspa message. A type that
Expand Down
48 changes: 48 additions & 0 deletions app/appmessage/rpc_get_accepting_blockhashes_of_txs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package appmessage

// TxIDBlockHashPair is an appmessage corresponding to
// its respective RPC message
type TxIDBlockHashPair struct {
TxID string
Hash string
}

// GetAcceptingBlockHashesOfTxsRequestMessage is an appmessage corresponding to
// its respective RPC message
type GetAcceptingBlockHashesOfTxsRequestMessage struct {
baseMessage
TxIDs []string
}

// Command returns the protocol command string for the message
func (msg *GetAcceptingBlockHashesOfTxsRequestMessage) Command() MessageCommand {
return CmdGetAcceptingBlockHashesOfTxsRequestMessage
}

// NewGetAcceptingBlockHashesOfTxsRequest returns a instance of the message
func NewGetAcceptingBlockHashesOfTxsRequest(txIDs []string) *GetAcceptingBlockHashesOfTxsRequestMessage {
return &GetAcceptingBlockHashesOfTxsRequestMessage{
TxIDs: txIDs,
}
}

// GetAcceptingBlockHashesOfTxsResponseMessage is an appmessage corresponding to
// its respective RPC message
type GetAcceptingBlockHashesOfTxsResponseMessage struct {
baseMessage
TxIDBlockHashPairs []*TxIDBlockHashPair

Error *RPCError
}

// Command returns the protocol command string for the message
func (msg *GetAcceptingBlockHashesOfTxsResponseMessage) Command() MessageCommand {
return CmdGetAcceptingBlockHashesOfTxsResponseMessage
}

// NewGetAcceptingBlockHashesOfTxsResponse returns an instance of the message
func NewGetAcceptingBlockHashesOfTxsResponse(txIDBlockHashPairs []*TxIDBlockHashPair) *GetAcceptingBlockHashesOfTxsResponseMessage {
return &GetAcceptingBlockHashesOfTxsResponseMessage{
TxIDBlockHashPairs: txIDBlockHashPairs,
}
}
7 changes: 6 additions & 1 deletion app/appmessage/rpc_get_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ type GetInfoResponseMessage struct {
MempoolSize uint64
ServerVersion string
IsUtxoIndexed bool
IsTxIndexed bool
IsArchival bool
IsSynced bool

Error *RPCError
Expand All @@ -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,
}
}
41 changes: 41 additions & 0 deletions app/appmessage/rpc_get_txs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package appmessage

// GetTxsRequestMessage is an appmessage corresponding to
// its respective RPC message
type GetTxsRequestMessage struct {
baseMessage
TxIDs []string
}

// Command returns the protocol command string for the message
func (msg *GetTxsRequestMessage) Command() MessageCommand {
return CmdGetTxsRequestMessage
}

// NewGetTxsRequest returns a instance of the message
func NewGetTxsRequest(txIDs []string) *GetTxsRequestMessage {
return &GetTxsRequestMessage{
TxIDs: txIDs,
}
}

// GetTxsResponseMessage is an appmessage corresponding to
// its respective RPC message
type GetTxsResponseMessage struct {
baseMessage
Transactions []*RPCTransaction

Error *RPCError
}

// Command returns the protocol command string for the message
func (msg *GetTxsResponseMessage) Command() MessageCommand {
return CmdGetTxsResponseMessage
}

// NewGetTxsResponse returns an instance of the message
func NewGetTxsResponse(transactions []*RPCTransaction) *GetTxsResponseMessage {
return &GetTxsResponseMessage{
Transactions: transactions,
}
}
48 changes: 48 additions & 0 deletions app/appmessage/rpc_get_txs_confirmations.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package appmessage

// TxIDConfirmationsPair is an appmessage corresponding to
// its respective RPC message
type TxIDConfirmationsPair struct {
TxID string
Confirmations int64
}

// GetTxsConfirmationsRequestMessage is an appmessage corresponding to
// its respective RPC message
type GetTxsConfirmationsRequestMessage struct {
baseMessage
TxIDs []string
}

// Command returns the protocol command string for the message
func (msg *GetTxsConfirmationsRequestMessage) Command() MessageCommand {
return CmdGetTxsConfirmationsRequestMessage
}

// NewGetTxsConfirmationsRequest returns a instance of the message
func NewGetTxsConfirmationsRequest(txIDs []string) *GetTxsConfirmationsRequestMessage {
return &GetTxsConfirmationsRequestMessage{
TxIDs: txIDs,
}
}

// GetTxsConfirmationsResponseMessage is an appmessage corresponding to
// its respective RPC message
type GetTxsConfirmationsResponseMessage struct {
baseMessage
TxIDConfirmationsPairs []*TxIDConfirmationsPair

Error *RPCError
}

// Command returns the protocol command string for the message
func (msg *GetTxsConfirmationsResponseMessage) Command() MessageCommand {
return CmdGetTxsConfirmationsResponseMessage
}

// NewGetTxsConfirmationsResponse returns an instance of the message
func NewGetTxsConfirmationsResponse(txIDConfirmationsPairs []*TxIDConfirmationsPair) *GetTxsConfirmationsResponseMessage {
return &GetTxsConfirmationsResponseMessage{
TxIDConfirmationsPairs: txIDConfirmationsPairs,
}
}
49 changes: 49 additions & 0 deletions app/appmessage/rpc_modify_notifying_addresses_txs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package appmessage

// ModifyNotifyingAddressesTxsRequestMessage is an appmessage corresponding to
// its respective RPC message
type ModifyNotifyingAddressesTxsRequestMessage struct {
baseMessage
AddAddresses []string
RemoveAddresses []string
RequiredConfirmations uint32
IncludePending bool
IncludeSending bool
IncludeReceiving bool
}

// Command returns the protocol command string for the message
func (msg *ModifyNotifyingAddressesTxsRequestMessage) Command() MessageCommand {
return CmdModifyNotifyingAddressesTxsRequestMessage
}

// NewModifyNotifyingAddressesTxsRequestMessage returns a instance of the message
func NewModifyNotifyingAddressesTxsRequestMessage(addAddresses []string, removeAddresses []string,
requiredConfirmations uint32, includePending bool, includeSending bool,
includeReceiving bool) *ModifyNotifyingAddressesTxsRequestMessage {
return &ModifyNotifyingAddressesTxsRequestMessage{
AddAddresses: addAddresses,
RemoveAddresses: removeAddresses,
RequiredConfirmations: requiredConfirmations,
IncludePending: includePending,
IncludeSending: includeSending,
IncludeReceiving: includeReceiving,
}
}

// ModifyNotifyingAddressesTxsResponseMessage is an appmessage corresponding to
// its respective RPC message
type ModifyNotifyingAddressesTxsResponseMessage struct {
baseMessage
Error *RPCError
}

// Command returns the protocol command string for the message
func (msg *ModifyNotifyingAddressesTxsResponseMessage) Command() MessageCommand {
return CmdModifyNotifyingAddressesTxsResponseMessage
}

// NewModifyNotifyingAddressesTxsResponseMessage returns a instance of the message
func NewModifyNotifyingAddressesTxsResponseMessage() *NotifyAddressesTxsResponseMessage {
return &NotifyAddressesTxsResponseMessage{}
}
44 changes: 44 additions & 0 deletions app/appmessage/rpc_modify_notifying_txs_confirmation_changed.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package appmessage

// ModifyNotifyingTxsConfirmationChangedRequestMessage is an appmessage corresponding to
// its respective RPC message
type ModifyNotifyingTxsConfirmationChangedRequestMessage struct {
baseMessage
AddTxIDs []string
RemoveTxIDs []string
RequiredConfirmations uint32
IncludePending bool
}

// Command returns the protocol command string for the message
func (msg *ModifyNotifyingTxsConfirmationChangedRequestMessage) Command() MessageCommand {
return CmdModifyNotifyingTxsConfirmationChangedRequestMessage
}

// NewModifyNotifyingTxsConfirmationChangedRequestMessage returns a instance of the message
func NewModifyNotifyingTxsConfirmationChangedRequestMessage(addTxIDs []string, removeTxIDs []string,
requiredConfirmations uint32, includePending bool) *ModifyNotifyingTxsConfirmationChangedRequestMessage {
return &ModifyNotifyingTxsConfirmationChangedRequestMessage{
AddTxIDs: addTxIDs,
RemoveTxIDs: removeTxIDs,
RequiredConfirmations: requiredConfirmations,
IncludePending: includePending,
}
}

// ModifyNotifyingTxsConfirmationChangedResponseMessage is an appmessage corresponding to
// its respective RPC message
type ModifyNotifyingTxsConfirmationChangedResponseMessage struct {
baseMessage
Error *RPCError
}

// Command returns the protocol command string for the message
func (msg *ModifyNotifyingTxsConfirmationChangedResponseMessage) Command() MessageCommand {
return CmdModifyNotifyingTxsConfirmationChangedResponseMessage
}

// NewModifyNotifyingTxsChangedResponseMessage returns a instance of the message
func NewModifyNotifyingTxsChangedResponseMessage() *NotifyTxsConfirmationChangedResponseMessage {
return &NotifyTxsConfirmationChangedResponseMessage{}
}
87 changes: 87 additions & 0 deletions app/appmessage/rpc_notify_addresses_txs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package appmessage

// NotifyAddressesTxsRequestMessage is an appmessage corresponding to
// its respective RPC message
type NotifyAddressesTxsRequestMessage struct {
baseMessage
Addresses []string
RequiredConfirmations uint32
IncludePending bool
IncludeSending bool
IncludeReceiving bool
}

// Command returns the protocol command string for the message
func (msg *NotifyAddressesTxsRequestMessage) Command() MessageCommand {
return CmdNotifyAddressesTxsRequestMessage
}

// NewNotifyAddressesTxsRequestMessage returns a instance of the message
func NewNotifyAddressesTxsRequestMessage(addresses []string, requiredConfirmations uint32,
includePending bool, includeSending bool, includeReceiving bool) *NotifyAddressesTxsRequestMessage {
return &NotifyAddressesTxsRequestMessage{
Addresses: addresses,
RequiredConfirmations: requiredConfirmations,
IncludePending: includePending,
IncludeSending: includeSending,
IncludeReceiving: includeReceiving,
}
}

// NotifyAddressesTxsResponseMessage is an appmessage corresponding to
// its respective RPC message
type NotifyAddressesTxsResponseMessage struct {
baseMessage
Error *RPCError
}

// Command returns the protocol command string for the message
func (msg *NotifyAddressesTxsResponseMessage) Command() MessageCommand {
return CmdNotifyAddressesTxsResponseMessage
}

// NewNotifyAddressesTxsResponseMessage returns a instance of the message
func NewNotifyAddressesTxsResponseMessage() *NotifyAddressesTxsResponseMessage {
return &NotifyAddressesTxsResponseMessage{}
}

// AddressesTxsNotificationMessage is an appmessage corresponding to
// its respective RPC message
type AddressesTxsNotificationMessage struct {
baseMessage
RequiredConfirmations uint32
Pending *TxEntriesByAddresses
Confirmed *TxEntriesByAddresses
Unconfirmed *TxEntriesByAddresses
}

// Command returns the protocol command string for the message
func (msg *AddressesTxsNotificationMessage) Command() MessageCommand {
return CmdAddressesTxsNotificationMessage
}

// NewAddressesTxsNotificationMessage returns a instance of the message
func NewAddressesTxsNotificationMessage(requiredConfirmations uint32, pending *TxEntriesByAddresses,
confirmed *TxEntriesByAddresses, unconfirmed *TxEntriesByAddresses) *AddressesTxsNotificationMessage {
return &AddressesTxsNotificationMessage{
RequiredConfirmations: requiredConfirmations,
Pending: pending,
Confirmed: confirmed,
Unconfirmed: unconfirmed,
}
}

// TxEntriesByAddresses is an appmessage corresponding to
// its respective RPC message
type TxEntriesByAddresses struct {
Sent []*TxEntryByAddress
Received []*TxEntryByAddress
}

// TxEntryByAddress is an appmessage corresponding to
// its respective RPC message
type TxEntryByAddress struct {
Address string
TxID string
Confirmations uint32
}
Loading