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 43 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
48 changes: 48 additions & 0 deletions app/appmessage/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,30 @@ const (
CmdGetMempoolEntriesByAddressesResponseMessage
CmdGetCoinSupplyRequestMessage
CmdGetCoinSupplyResponseMessage
CmdGetAcceptingBlockHashOfTxRequestMessage
CmdGetAcceptingBlockHashOfTxResponseMessage
CmdGetAcceptingBlockHashesOfTxsRequestMessage
CmdGetAcceptingBlockHashesOfTxsResponseMessage
CmdGetAcceptingBlockOfTxRequestMessage
CmdGetAcceptingBlockOfTxResponseMessage
CmdGetAcceptingBlocksOfTxsRequestMessage
CmdGetAcceptingBlocksOfTxsResponseMessage
CmdGetIncludingBlockHashOfTxRequestMessage
CmdGetIncludingBlockHashOfTxResponseMessage
CmdGetIncludingBlockHashesOfTxsRequestMessage
CmdGetIncludingBlockHashesOfTxsResponseMessage
CmdGetIncludingBlockOfTxRequestMessage
CmdGetIncludingBlockOfTxResponseMessage
CmdGetIncludingBlocksOfTxsRequestMessage
CmdGetIncludingBlocksOfTxsResponseMessage
CmdGetTxRequestMessage
CmdGetTxResponseMessage
CmdGetTxsRequestMessage
CmdGetTxsResponseMessage
CmdGetTxConfirmationsRequestMessage
CmdGetTxConfirmationsResponseMessage
CmdGetTxsConfirmationsRequestMessage
CmdGetTxsConfirmationsResponseMessage
)

// ProtocolMessageCommandToString maps all MessageCommands to their string representation
Expand Down Expand Up @@ -300,6 +324,30 @@ var RPCMessageCommandToString = map[MessageCommand]string{
CmdGetMempoolEntriesByAddressesResponseMessage: "GetMempoolEntriesByAddressesResponse",
CmdGetCoinSupplyRequestMessage: "GetCoinSupplyRequest",
CmdGetCoinSupplyResponseMessage: "GetCoinSupplyResponse",
CmdGetAcceptingBlockHashOfTxRequestMessage: "GetAcceptingBlockHashOfTxRequest",
CmdGetAcceptingBlockHashOfTxResponseMessage: "GetAcceptingBlockHashOfTxResponse",
CmdGetAcceptingBlockHashesOfTxsRequestMessage: "GetAcceptingBlockHashesOfTxsRequest",
CmdGetAcceptingBlockHashesOfTxsResponseMessage: "GetAcceptingBlockHashesOfTxsResponse",
CmdGetAcceptingBlockOfTxRequestMessage: "GetAcceptingBlockOfTxRequest",
CmdGetAcceptingBlockOfTxResponseMessage: "GetAcceptingBlockOfTxResponse",
CmdGetAcceptingBlocksOfTxsRequestMessage: "GetAcceptingBlocksOfTxsRequest",
CmdGetAcceptingBlocksOfTxsResponseMessage: "GetAcceptingBlocksOfTxsResponse",
CmdGetIncludingBlockHashOfTxRequestMessage: "GetIncludingBlockHashOfTxRequest",
CmdGetIncludingBlockHashOfTxResponseMessage: "GetIncludingBlockHashOfTxResponse",
CmdGetIncludingBlockHashesOfTxsRequestMessage: "GetIncludingBlockHashesOfTxsRequest",
CmdGetIncludingBlockHashesOfTxsResponseMessage: "GetIncludingBlockHashesOfTxsResponse",
CmdGetIncludingBlockOfTxRequestMessage: "GetIncludingBlockOfTxRequest",
CmdGetIncludingBlockOfTxResponseMessage: "GetIncludingBlockOfTxResponse",
CmdGetIncludingBlocksOfTxsRequestMessage: "GetIncludingBlocksOfTxsRequest",
CmdGetIncludingBlocksOfTxsResponseMessage: "GetIncludingBlocksOfTxsResponse",
CmdGetTxRequestMessage: "GetTxRequest",
CmdGetTxResponseMessage: "GetTxResponse",
CmdGetTxsRequestMessage: "GetTxsRequest",
CmdGetTxsResponseMessage: "GetTxsResponse",
CmdGetTxConfirmationsRequestMessage: "GetTxConfirmationsRequest",
CmdGetTxConfirmationsResponseMessage: "GetTxConfirmationsResponse",
CmdGetTxsConfirmationsRequestMessage: "GetTxsConfirmationsRequest",
CmdGetTxsConfirmationsResponseMessage: "GetTxsConfirmationsResponse",
}

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

// GetAcceptingBlockOfTxRequestMessage is an appmessage corresponding to
// its respective RPC message
type GetAcceptingBlockOfTxRequestMessage struct {
baseMessage
TxID string
IncludeTransactions bool
}

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

// NewGetAcceptingBlockOfTxRequest returns a instance of the message
func NewGetAcceptingBlockOfTxRequest(txID string, includeTransactions bool) *GetAcceptingBlockOfTxRequestMessage {
return &GetAcceptingBlockOfTxRequestMessage{
TxID: txID,
IncludeTransactions: includeTransactions,
}
}

// GetAcceptingBlockOfTxResponseMessage is an appmessage corresponding to
// its respective RPC message
type GetAcceptingBlockOfTxResponseMessage struct {
baseMessage
Block *RPCBlock

Error *RPCError
}

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

// NewGetAcceptingBlockOfTxResponse returns an instance of the message
func NewGetAcceptingBlockOfTxResponse(block *RPCBlock) *GetAcceptingBlockOfTxResponseMessage {
return &GetAcceptingBlockOfTxResponseMessage{
Block: block,
}
}
41 changes: 41 additions & 0 deletions app/appmessage/rpc_get_accepting_blockhash_of_tx.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package appmessage

// GetAcceptingBlockHashOfTxRequestMessage is an appmessage corresponding to
// its respective RPC message
type GetAcceptingBlockHashOfTxRequestMessage struct {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not very important, but usually the language we use is "GetTxAcceptingBlock" without any "of"

baseMessage
TxID string
}

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

// NewGetAcceptingBlockHashOfTxRequest returns a instance of the message
func NewGetAcceptingBlockHashOfTxRequest(txID string) *GetAcceptingBlockHashOfTxRequestMessage {
return &GetAcceptingBlockHashOfTxRequestMessage{
TxID: txID,
}
}

// GetAcceptingBlockHashOfTxResponseMessage is an appmessage corresponding to
// its respective RPC message
type GetAcceptingBlockHashOfTxResponseMessage struct {
baseMessage
Hash string

Error *RPCError
}

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

// NewGetAcceptingBlockHashOfTxResponse returns an instance of the message
func NewGetAcceptingBlockHashOfTxResponse(hash string) *GetAcceptingBlockHashOfTxResponseMessage {
return &GetAcceptingBlockHashOfTxResponseMessage{
Hash: hash,
}
}
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,
}
}
50 changes: 50 additions & 0 deletions app/appmessage/rpc_get_accepting_blocks_of_txs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package appmessage

// TxIDBlockPair is an appmessage corresponding to
// its respective RPC message
type TxIDBlockPair struct {
TxID string
Block *RPCBlock
}

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

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

// NewGetAcceptingBlocksOfTxsRequest returns a instance of the message
func NewGetAcceptingBlocksOfTxsRequest(txIDs []string, includeTransactions bool) *GetAcceptingBlocksOfTxsRequestMessage {
return &GetAcceptingBlocksOfTxsRequestMessage{
TxIDs: txIDs,
IncludeTransactions: includeTransactions,
}
}

// GetAcceptingBlocksOfTxsResponseMessage is an appmessage corresponding to
// its respective RPC message
type GetAcceptingBlocksOfTxsResponseMessage struct {
baseMessage
TxIDBlockPairs []*TxIDBlockPair

Error *RPCError
}

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

// NewGetAcceptingBlocksOfTxsResponse returns an instance of the message
func NewGetAcceptingBlocksOfTxsResponse(txIDBlockPairs []*TxIDBlockPair) *GetAcceptingBlocksOfTxsResponseMessage {
return &GetAcceptingBlocksOfTxsResponseMessage{
TxIDBlockPairs: txIDBlockPairs,
}
}
43 changes: 43 additions & 0 deletions app/appmessage/rpc_get_including_block_of_tx.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package appmessage
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't expose the including block to the user if it's different between kaspads


// GetIncludingBlockOfTxRequestMessage is an appmessage corresponding to
// its respective RPC message
type GetIncludingBlockOfTxRequestMessage struct {
baseMessage
TxID string
IncludeTransactions bool
}

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

// NewGetIncludingBlockOfTxRequest returns a instance of the message
func NewGetIncludingBlockOfTxRequest(txID string, includeTransactions bool) *GetIncludingBlockOfTxRequestMessage {
return &GetIncludingBlockOfTxRequestMessage{
TxID: txID,
IncludeTransactions: includeTransactions,
}
}

// GetIncludingBlockOfTxResponseMessage is an appmessage corresponding to
// its respective RPC message
type GetIncludingBlockOfTxResponseMessage struct {
baseMessage
Block *RPCBlock

Error *RPCError
}

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

// NewGetIncludingBlockOfTxResponse returns an instance of the message
func NewGetIncludingBlockOfTxResponse(block *RPCBlock) *GetIncludingBlockOfTxResponseMessage {
return &GetIncludingBlockOfTxResponseMessage{
Block: block,
}
}
41 changes: 41 additions & 0 deletions app/appmessage/rpc_get_including_blockhash_of_tx.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package appmessage
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't expose the including block to the user if it's different between kaspads.


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

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

// NewGetIncludingBlockHashOfTxRequest returns a instance of the message
func NewGetIncludingBlockHashOfTxRequest(txID string) *GetIncludingBlockHashOfTxRequestMessage {
return &GetIncludingBlockHashOfTxRequestMessage{
TxID: txID,
}
}

// GetIncludingBlockHashOfTxResponseMessage is an appmessage corresponding to
// its respective RPC message
type GetIncludingBlockHashOfTxResponseMessage struct {
baseMessage
Hash string

Error *RPCError
}

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

// NewGetIncludingBlockHashOfTxResponse returns an instance of the message
func NewGetIncludingBlockHashOfTxResponse(hash string) *GetIncludingBlockHashOfTxResponseMessage {
return &GetIncludingBlockHashOfTxResponseMessage{
Hash: hash,
}
}
41 changes: 41 additions & 0 deletions app/appmessage/rpc_get_including_blockhashes_of_txs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package appmessage
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't expose the including block to the user if it's different between kaspads


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

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

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

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

Error *RPCError
}

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

// NewGetIncludingBlockHashesOfTxsResponse returns an instance of the message
func NewGetIncludingBlockHashesOfTxsResponse(txIDBlockHashPairs []*TxIDBlockHashPair) *GetIncludingBlockHashesOfTxsResponseMessage {
return &GetIncludingBlockHashesOfTxsResponseMessage{
TxIDBlockHashPairs: txIDBlockHashPairs,
}
}
Loading