mirror of
https://github.com/kaspanet/kaspad.git
synced 2026-02-22 03:32:55 +00:00
Compare commits
15 Commits
v0.10.0-de
...
v0.10.4-de
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3903d10af1 | ||
|
|
de0bdfcd33 | ||
|
|
eaf4180082 | ||
|
|
5ef24ae37e | ||
|
|
83e631548f | ||
|
|
0adfb2dfbb | ||
|
|
4461f56ca3 | ||
|
|
a18f2f8802 | ||
|
|
04dc1947ff | ||
|
|
36c56f73bf | ||
|
|
b76ca41109 | ||
|
|
50fd86e287 | ||
|
|
79cf0d64d0 | ||
|
|
b405ea50e5 | ||
|
|
ccfe8a45dd |
@@ -137,6 +137,9 @@ const (
|
||||
CmdPruningPointUTXOSetOverrideNotificationMessage
|
||||
CmdStopNotifyingPruningPointUTXOSetOverrideRequestMessage
|
||||
CmdStopNotifyingPruningPointUTXOSetOverrideResponseMessage
|
||||
CmdNotifyVirtualDaaScoreChangedRequestMessage
|
||||
CmdNotifyVirtualDaaScoreChangedResponseMessage
|
||||
CmdVirtualDaaScoreChangedNotificationMessage
|
||||
)
|
||||
|
||||
// ProtocolMessageCommandToString maps all MessageCommands to their string representation
|
||||
@@ -248,6 +251,9 @@ var RPCMessageCommandToString = map[MessageCommand]string{
|
||||
CmdPruningPointUTXOSetOverrideNotificationMessage: "PruningPointUTXOSetOverrideNotification",
|
||||
CmdStopNotifyingPruningPointUTXOSetOverrideRequestMessage: "StopNotifyingPruningPointUTXOSetOverrideRequest",
|
||||
CmdStopNotifyingPruningPointUTXOSetOverrideResponseMessage: "StopNotifyingPruningPointUTXOSetOverrideResponse",
|
||||
CmdNotifyVirtualDaaScoreChangedRequestMessage: "NotifyVirtualDaaScoreChangedRequest",
|
||||
CmdNotifyVirtualDaaScoreChangedResponseMessage: "NotifyVirtualDaaScoreChangedResponse",
|
||||
CmdVirtualDaaScoreChangedNotificationMessage: "VirtualDaaScoreChangedNotification",
|
||||
}
|
||||
|
||||
// Message is an interface that describes a kaspa message. A type that
|
||||
|
||||
@@ -28,6 +28,7 @@ type GetBlockDAGInfoResponseMessage struct {
|
||||
Difficulty float64
|
||||
PastMedianTime int64
|
||||
PruningPointHash string
|
||||
VirtualDAAScore uint64
|
||||
|
||||
Error *RPCError
|
||||
}
|
||||
|
||||
55
app/appmessage/rpc_notify_virtual_daa_score_changed.go
Normal file
55
app/appmessage/rpc_notify_virtual_daa_score_changed.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package appmessage
|
||||
|
||||
// NotifyVirtualDaaScoreChangedRequestMessage is an appmessage corresponding to
|
||||
// its respective RPC message
|
||||
type NotifyVirtualDaaScoreChangedRequestMessage struct {
|
||||
baseMessage
|
||||
}
|
||||
|
||||
// Command returns the protocol command string for the message
|
||||
func (msg *NotifyVirtualDaaScoreChangedRequestMessage) Command() MessageCommand {
|
||||
return CmdNotifyVirtualDaaScoreChangedRequestMessage
|
||||
}
|
||||
|
||||
// NewNotifyVirtualDaaScoreChangedRequestMessage returns a instance of the message
|
||||
func NewNotifyVirtualDaaScoreChangedRequestMessage() *NotifyVirtualDaaScoreChangedRequestMessage {
|
||||
return &NotifyVirtualDaaScoreChangedRequestMessage{}
|
||||
}
|
||||
|
||||
// NotifyVirtualDaaScoreChangedResponseMessage is an appmessage corresponding to
|
||||
// its respective RPC message
|
||||
type NotifyVirtualDaaScoreChangedResponseMessage struct {
|
||||
baseMessage
|
||||
Error *RPCError
|
||||
}
|
||||
|
||||
// Command returns the protocol command string for the message
|
||||
func (msg *NotifyVirtualDaaScoreChangedResponseMessage) Command() MessageCommand {
|
||||
return CmdNotifyVirtualDaaScoreChangedResponseMessage
|
||||
}
|
||||
|
||||
// NewNotifyVirtualDaaScoreChangedResponseMessage returns a instance of the message
|
||||
func NewNotifyVirtualDaaScoreChangedResponseMessage() *NotifyVirtualDaaScoreChangedResponseMessage {
|
||||
return &NotifyVirtualDaaScoreChangedResponseMessage{}
|
||||
}
|
||||
|
||||
// VirtualDaaScoreChangedNotificationMessage is an appmessage corresponding to
|
||||
// its respective RPC message
|
||||
type VirtualDaaScoreChangedNotificationMessage struct {
|
||||
baseMessage
|
||||
VirtualDaaScore uint64
|
||||
}
|
||||
|
||||
// Command returns the protocol command string for the message
|
||||
func (msg *VirtualDaaScoreChangedNotificationMessage) Command() MessageCommand {
|
||||
return CmdVirtualDaaScoreChangedNotificationMessage
|
||||
}
|
||||
|
||||
// NewVirtualDaaScoreChangedNotificationMessage returns a instance of the message
|
||||
func NewVirtualDaaScoreChangedNotificationMessage(
|
||||
virtualDaaScore uint64) *VirtualDaaScoreChangedNotificationMessage {
|
||||
|
||||
return &VirtualDaaScoreChangedNotificationMessage{
|
||||
VirtualDaaScore: virtualDaaScore,
|
||||
}
|
||||
}
|
||||
@@ -49,8 +49,9 @@ func (flow *handleRequestHeadersFlow) start() error {
|
||||
|
||||
// GetHashesBetween is a relatively heavy operation so we limit it
|
||||
// in order to avoid locking the consensus for too long
|
||||
const maxBlueScoreDifference = 1 << 10
|
||||
blockHashes, _, err := flow.Domain().Consensus().GetHashesBetween(lowHash, highHash, maxBlueScoreDifference)
|
||||
// maxBlocks MUST be >= MergeSetSizeLimit + 1
|
||||
const maxBlocks = 1 << 10
|
||||
blockHashes, _, err := flow.Domain().Consensus().GetHashesBetween(lowHash, highHash, maxBlocks)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -130,6 +130,10 @@ type fakeRelayInvsContext struct {
|
||||
rwLock sync.RWMutex
|
||||
}
|
||||
|
||||
func (f *fakeRelayInvsContext) GetBlockEvenIfHeaderOnly(blockHash *externalapi.DomainHash) (*externalapi.DomainBlock, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (f *fakeRelayInvsContext) GetBlockRelations(blockHash *externalapi.DomainHash) ([]*externalapi.DomainHash, *externalapi.DomainHash, []*externalapi.DomainHash, error) {
|
||||
panic(errors.Errorf("called unimplemented function from test '%s'", f.testName))
|
||||
}
|
||||
@@ -182,7 +186,7 @@ func (f *fakeRelayInvsContext) GetBlockAcceptanceData(blockHash *externalapi.Dom
|
||||
panic(errors.Errorf("called unimplemented function from test '%s'", f.testName))
|
||||
}
|
||||
|
||||
func (f *fakeRelayInvsContext) GetHashesBetween(lowHash, highHash *externalapi.DomainHash, maxBlueScoreDifference uint64) (hashes []*externalapi.DomainHash, actualHighHash *externalapi.DomainHash, err error) {
|
||||
func (f *fakeRelayInvsContext) GetHashesBetween(lowHash, highHash *externalapi.DomainHash, maxBlocks uint64) (hashes []*externalapi.DomainHash, actualHighHash *externalapi.DomainHash, err error) {
|
||||
panic(errors.Errorf("called unimplemented function from test '%s'", f.testName))
|
||||
}
|
||||
|
||||
|
||||
@@ -64,6 +64,11 @@ func (m *Manager) NotifyBlockAddedToDAG(block *externalapi.DomainBlock, blockIns
|
||||
return err
|
||||
}
|
||||
|
||||
err = m.notifyVirtualDaaScoreChanged()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = m.notifyVirtualSelectedParentChainChanged(blockInsertionResult)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -153,6 +158,19 @@ func (m *Manager) notifyVirtualSelectedParentBlueScoreChanged() error {
|
||||
return m.context.NotificationManager.NotifyVirtualSelectedParentBlueScoreChanged(notification)
|
||||
}
|
||||
|
||||
func (m *Manager) notifyVirtualDaaScoreChanged() error {
|
||||
onEnd := logger.LogAndMeasureExecutionTime(log, "RPCManager.NotifyVirtualDaaScoreChanged")
|
||||
defer onEnd()
|
||||
|
||||
virtualInfo, err := m.context.Domain.Consensus().GetVirtualInfo()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
notification := appmessage.NewVirtualDaaScoreChangedNotificationMessage(virtualInfo.DAAScore)
|
||||
return m.context.NotificationManager.NotifyVirtualDaaScoreChanged(notification)
|
||||
}
|
||||
|
||||
func (m *Manager) notifyVirtualSelectedParentChainChanged(blockInsertionResult *externalapi.BlockInsertionResult) error {
|
||||
onEnd := logger.LogAndMeasureExecutionTime(log, "RPCManager.NotifyVirtualSelectedParentChainChanged")
|
||||
defer onEnd()
|
||||
|
||||
@@ -44,6 +44,7 @@ var handlers = map[appmessage.MessageCommand]handler{
|
||||
appmessage.CmdGetInfoRequestMessage: rpchandlers.HandleGetInfo,
|
||||
appmessage.CmdNotifyPruningPointUTXOSetOverrideRequestMessage: rpchandlers.HandleNotifyPruningPointUTXOSetOverrideRequest,
|
||||
appmessage.CmdStopNotifyingPruningPointUTXOSetOverrideRequestMessage: rpchandlers.HandleStopNotifyingPruningPointUTXOSetOverrideRequest,
|
||||
appmessage.CmdNotifyVirtualDaaScoreChangedRequestMessage: rpchandlers.HandleNotifyVirtualDaaScoreChanged,
|
||||
}
|
||||
|
||||
func (m *Manager) routerInitializer(router *router.Router, netConnection *netadapter.NetConnection) {
|
||||
|
||||
@@ -30,6 +30,7 @@ type NotificationListener struct {
|
||||
propagateFinalityConflictResolvedNotifications bool
|
||||
propagateUTXOsChangedNotifications bool
|
||||
propagateVirtualSelectedParentBlueScoreChangedNotifications bool
|
||||
propagateVirtualDaaScoreChangedNotifications bool
|
||||
propagatePruningPointUTXOSetOverrideNotifications bool
|
||||
|
||||
propagateUTXOsChangedNotificationAddresses map[utxoindex.ScriptPublicKeyString]*UTXOsChangedNotificationAddress
|
||||
@@ -181,6 +182,25 @@ func (nm *NotificationManager) NotifyVirtualSelectedParentBlueScoreChanged(
|
||||
return nil
|
||||
}
|
||||
|
||||
// NotifyVirtualDaaScoreChanged notifies the notification manager that the DAG's
|
||||
// virtual DAA score has changed
|
||||
func (nm *NotificationManager) NotifyVirtualDaaScoreChanged(
|
||||
notification *appmessage.VirtualDaaScoreChangedNotificationMessage) error {
|
||||
|
||||
nm.RLock()
|
||||
defer nm.RUnlock()
|
||||
|
||||
for router, listener := range nm.listeners {
|
||||
if listener.propagateVirtualDaaScoreChangedNotifications {
|
||||
err := router.OutgoingRoute().Enqueue(notification)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// NotifyPruningPointUTXOSetOverride notifies the notification manager that the UTXO index
|
||||
// reset due to pruning point change via IBD.
|
||||
func (nm *NotificationManager) NotifyPruningPointUTXOSetOverride() error {
|
||||
@@ -308,6 +328,12 @@ func (nl *NotificationListener) PropagateVirtualSelectedParentBlueScoreChangedNo
|
||||
nl.propagateVirtualSelectedParentBlueScoreChangedNotifications = true
|
||||
}
|
||||
|
||||
// PropagateVirtualDaaScoreChangedNotifications instructs the listener to send
|
||||
// virtual DAA score notifications to the remote listener
|
||||
func (nl *NotificationListener) PropagateVirtualDaaScoreChangedNotifications() {
|
||||
nl.propagateVirtualDaaScoreChangedNotifications = true
|
||||
}
|
||||
|
||||
// PropagatePruningPointUTXOSetOverrideNotifications instructs the listener to send pruning point UTXO set override notifications
|
||||
// to the remote listener.
|
||||
func (nl *NotificationListener) PropagatePruningPointUTXOSetOverrideNotifications() {
|
||||
|
||||
@@ -80,7 +80,7 @@ func (ctx *Context) PopulateBlockWithVerboseData(block *appmessage.RPCBlock, dom
|
||||
|
||||
// Get the block if we didn't receive it previously
|
||||
if domainBlock == nil {
|
||||
domainBlock, err = ctx.Domain.Consensus().GetBlock(blockHash)
|
||||
domainBlock, err = ctx.Domain.Consensus().GetBlockEvenIfHeaderOnly(blockHash)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -20,18 +20,22 @@ func HandleGetBlock(context *rpccontext.Context, _ *router.Router, request appme
|
||||
return errorMessage, nil
|
||||
}
|
||||
|
||||
header, err := context.Domain.Consensus().GetBlockHeader(hash)
|
||||
block, err := context.Domain.Consensus().GetBlockEvenIfHeaderOnly(hash)
|
||||
if err != nil {
|
||||
errorMessage := &appmessage.GetBlockResponseMessage{}
|
||||
errorMessage.Error = appmessage.RPCErrorf("Block %s not found", hash)
|
||||
return errorMessage, nil
|
||||
}
|
||||
block := &externalapi.DomainBlock{Header: header}
|
||||
|
||||
response := appmessage.NewGetBlockResponseMessage()
|
||||
response.Block = appmessage.DomainBlockToRPCBlock(block)
|
||||
|
||||
err = context.PopulateBlockWithVerboseData(response.Block, header, nil, getBlockRequest.IncludeTransactionVerboseData)
|
||||
if getBlockRequest.IncludeTransactionVerboseData {
|
||||
response.Block = appmessage.DomainBlockToRPCBlock(block)
|
||||
} else {
|
||||
response.Block = appmessage.DomainBlockToRPCBlock(&externalapi.DomainBlock{Header: block.Header})
|
||||
}
|
||||
|
||||
err = context.PopulateBlockWithVerboseData(response.Block, block.Header, block, getBlockRequest.IncludeTransactionVerboseData)
|
||||
if err != nil {
|
||||
if errors.Is(err, rpccontext.ErrBuildBlockVerboseDataInvalidBlock) {
|
||||
errorMessage := &appmessage.GetBlockResponseMessage{}
|
||||
|
||||
@@ -35,6 +35,7 @@ func HandleGetBlockDAGInfo(context *rpccontext.Context, _ *router.Router, _ appm
|
||||
response.VirtualParentHashes = hashes.ToStrings(virtualInfo.ParentHashes)
|
||||
response.Difficulty = context.GetDifficultyRatio(virtualInfo.Bits, context.Config.ActiveNetParams)
|
||||
response.PastMedianTime = virtualInfo.PastMedianTime
|
||||
response.VirtualDAAScore = virtualInfo.DAAScore
|
||||
|
||||
pruningPoint, err := context.Domain.Consensus().PruningPoint()
|
||||
if err != nil {
|
||||
|
||||
@@ -8,12 +8,6 @@ import (
|
||||
"github.com/kaspanet/kaspad/infrastructure/network/netadapter/router"
|
||||
)
|
||||
|
||||
const (
|
||||
// maxBlocksInGetBlocksResponse is the max amount of blocks that are
|
||||
// allowed in a GetBlocksResult.
|
||||
maxBlocksInGetBlocksResponse = 1000
|
||||
)
|
||||
|
||||
// HandleGetBlocks handles the respectively named RPC command
|
||||
func HandleGetBlocks(context *rpccontext.Context, _ *router.Router, request appmessage.Message) (appmessage.Message, error) {
|
||||
getBlocksRequest := request.(*appmessage.GetBlocksRequestMessage)
|
||||
@@ -55,7 +49,11 @@ func HandleGetBlocks(context *rpccontext.Context, _ *router.Router, request appm
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
blockHashes, highHash, err := context.Domain.Consensus().GetHashesBetween(lowHash, virtualSelectedParent, maxBlocksInGetBlocksResponse)
|
||||
|
||||
// We use +1 because lowHash is also returned
|
||||
// maxBlocks MUST be >= MergeSetSizeLimit + 1
|
||||
maxBlocks := context.Config.NetParams().MergeSetSizeLimit + 1
|
||||
blockHashes, highHash, err := context.Domain.Consensus().GetHashesBetween(lowHash, virtualSelectedParent, maxBlocks)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -74,29 +72,28 @@ func HandleGetBlocks(context *rpccontext.Context, _ *router.Router, request appm
|
||||
blockHashes = append(blockHashes, virtualSelectedParentAnticone...)
|
||||
}
|
||||
|
||||
// Both GetHashesBetween and Anticone might return more then the allowed number of blocks, so
|
||||
// trim any extra blocks.
|
||||
if len(blockHashes) > maxBlocksInGetBlocksResponse {
|
||||
blockHashes = blockHashes[:maxBlocksInGetBlocksResponse]
|
||||
}
|
||||
|
||||
// Prepare the response
|
||||
response := appmessage.NewGetBlocksResponseMessage()
|
||||
response.BlockHashes = hashes.ToStrings(blockHashes)
|
||||
if getBlocksRequest.IncludeBlocks {
|
||||
blocks := make([]*appmessage.RPCBlock, len(blockHashes))
|
||||
rpcBlocks := make([]*appmessage.RPCBlock, len(blockHashes))
|
||||
for i, blockHash := range blockHashes {
|
||||
blockHeader, err := context.Domain.Consensus().GetBlockHeader(blockHash)
|
||||
block, err := context.Domain.Consensus().GetBlockEvenIfHeaderOnly(blockHash)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
block := &externalapi.DomainBlock{Header: blockHeader}
|
||||
blocks[i] = appmessage.DomainBlockToRPCBlock(block)
|
||||
err = context.PopulateBlockWithVerboseData(blocks[i], blockHeader, nil, getBlocksRequest.IncludeTransactionVerboseData)
|
||||
|
||||
if getBlocksRequest.IncludeTransactionVerboseData {
|
||||
rpcBlocks[i] = appmessage.DomainBlockToRPCBlock(block)
|
||||
} else {
|
||||
rpcBlocks[i] = appmessage.DomainBlockToRPCBlock(&externalapi.DomainBlock{Header: block.Header})
|
||||
}
|
||||
err = context.PopulateBlockWithVerboseData(rpcBlocks[i], block.Header, nil, getBlocksRequest.IncludeTransactionVerboseData)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
response.Blocks = rpcBlocks
|
||||
}
|
||||
|
||||
return response, nil
|
||||
|
||||
19
app/rpc/rpchandlers/notify_virtual_daa_score_changed.go
Normal file
19
app/rpc/rpchandlers/notify_virtual_daa_score_changed.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package rpchandlers
|
||||
|
||||
import (
|
||||
"github.com/kaspanet/kaspad/app/appmessage"
|
||||
"github.com/kaspanet/kaspad/app/rpc/rpccontext"
|
||||
"github.com/kaspanet/kaspad/infrastructure/network/netadapter/router"
|
||||
)
|
||||
|
||||
// HandleNotifyVirtualDaaScoreChanged handles the respectively named RPC command
|
||||
func HandleNotifyVirtualDaaScoreChanged(context *rpccontext.Context, router *router.Router, _ appmessage.Message) (appmessage.Message, error) {
|
||||
listener, err := context.NotificationManager.Listener(router)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
listener.PropagateVirtualDaaScoreChangedNotifications()
|
||||
|
||||
response := appmessage.NewNotifyVirtualDaaScoreChangedResponseMessage()
|
||||
return response, nil
|
||||
}
|
||||
@@ -1,3 +1,25 @@
|
||||
Kaspad v0.10.4 - 2021-07-05
|
||||
===========================
|
||||
* Make use of maxBlocks instead of maxBlueScoreDifference in antiPastHashesBetween (#1774)
|
||||
|
||||
Kaspad v0.10.3 - 2021-06-06
|
||||
===========================
|
||||
Non-breaking changes:
|
||||
* Implement NotifyVirtualDaaScoreChanged (#1737)
|
||||
|
||||
Kaspad v0.10.2 - 2021-05-18
|
||||
===========================
|
||||
Non-breaking changes:
|
||||
* Fix getBlock and getBlocks RPC commands to return blocks and transactions properly (#1716)
|
||||
* serializeAddress should always serialize as IPv6, since it assumes the IP size is 16 bytes (#1720)
|
||||
* Add VirtualDaaScore to GetBlockDagInfo (#1719)
|
||||
* Fix calcTxSequenceLockFromReferencedUTXOEntries for loop break condition (#1723)
|
||||
* Fix overflow when checking coinbase maturity and don't ban peers that send transactions with immature spend (#1722)
|
||||
|
||||
Kaspad v0.10.1 - 2021-05-11
|
||||
===========================
|
||||
* Calculate virtual's acceptance data and multiset after importing a new pruning point (#1700)
|
||||
|
||||
Kaspad v0.10.0 - 2021-04-26
|
||||
===========================
|
||||
Major changes include:
|
||||
|
||||
@@ -28,15 +28,14 @@ func balance(conf *balanceConfig) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
virtualSelectedParentBlueScoreResponse, err := client.GetVirtualSelectedParentBlueScore()
|
||||
blockDAGInfo, err := client.GetBlockDAGInfo()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
virtualSelectedParentBlueScore := virtualSelectedParentBlueScoreResponse.BlueScore
|
||||
|
||||
var availableBalance, pendingBalance uint64
|
||||
for _, entry := range getUTXOsByAddressesResponse.Entries {
|
||||
if isUTXOSpendable(entry, virtualSelectedParentBlueScore, conf.ActiveNetParams.BlockCoinbaseMaturity) {
|
||||
if isUTXOSpendable(entry, blockDAGInfo.VirtualDAAScore, conf.ActiveNetParams.BlockCoinbaseMaturity) {
|
||||
availableBalance += entry.UTXOEntry.Amount
|
||||
} else {
|
||||
pendingBalance += entry.UTXOEntry.Amount
|
||||
|
||||
@@ -8,13 +8,12 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
func isUTXOSpendable(entry *appmessage.UTXOsByAddressesEntry, virtualSelectedParentBlueScore uint64, coinbaseMaturity uint64) bool {
|
||||
func isUTXOSpendable(entry *appmessage.UTXOsByAddressesEntry, virtualDAAScore uint64, coinbaseMaturity uint64) bool {
|
||||
if !entry.UTXOEntry.IsCoinbase {
|
||||
return true
|
||||
}
|
||||
blockBlueScore := entry.UTXOEntry.BlockDAAScore
|
||||
// TODO: Check for a better alternative than virtualSelectedParentBlueScore
|
||||
return blockBlueScore+coinbaseMaturity < virtualSelectedParentBlueScore
|
||||
return blockBlueScore+coinbaseMaturity < virtualDAAScore
|
||||
}
|
||||
|
||||
func printErrorAndExit(err error) {
|
||||
|
||||
@@ -96,15 +96,15 @@ func fetchSpendableUTXOs(params *dagconfig.Params, client *rpcclient.RPCClient,
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
virtualSelectedParentBlueScoreResponse, err := client.GetVirtualSelectedParentBlueScore()
|
||||
|
||||
blockDAGInfo, err := client.GetBlockDAGInfo()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
virtualSelectedParentBlueScore := virtualSelectedParentBlueScoreResponse.BlueScore
|
||||
|
||||
spendableUTXOs := make([]*appmessage.UTXOsByAddressesEntry, 0)
|
||||
for _, entry := range getUTXOsByAddressesResponse.Entries {
|
||||
if !isUTXOSpendable(entry, virtualSelectedParentBlueScore, params.BlockCoinbaseMaturity) {
|
||||
if !isUTXOSpendable(entry, blockDAGInfo.VirtualDAAScore, params.BlockCoinbaseMaturity) {
|
||||
continue
|
||||
}
|
||||
spendableUTXOs = append(spendableUTXOs, entry)
|
||||
|
||||
@@ -112,6 +112,30 @@ func (s *consensus) GetBlock(blockHash *externalapi.DomainHash) (*externalapi.Do
|
||||
return block, nil
|
||||
}
|
||||
|
||||
func (s *consensus) GetBlockEvenIfHeaderOnly(blockHash *externalapi.DomainHash) (*externalapi.DomainBlock, error) {
|
||||
s.lock.Lock()
|
||||
defer s.lock.Unlock()
|
||||
|
||||
stagingArea := model.NewStagingArea()
|
||||
|
||||
block, err := s.blockStore.Block(s.databaseContext, stagingArea, blockHash)
|
||||
if err == nil {
|
||||
return block, nil
|
||||
}
|
||||
if !errors.Is(err, database.ErrNotFound) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
header, err := s.blockHeaderStore.BlockHeader(s.databaseContext, stagingArea, blockHash)
|
||||
if err != nil {
|
||||
if errors.Is(err, database.ErrNotFound) {
|
||||
return nil, errors.Wrapf(err, "block %s does not exist", blockHash)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
return &externalapi.DomainBlock{Header: header}, nil
|
||||
}
|
||||
|
||||
func (s *consensus) GetBlockHeader(blockHash *externalapi.DomainHash) (externalapi.BlockHeader, error) {
|
||||
s.lock.Lock()
|
||||
defer s.lock.Unlock()
|
||||
@@ -202,7 +226,7 @@ func (s *consensus) GetBlockAcceptanceData(blockHash *externalapi.DomainHash) (e
|
||||
return s.acceptanceDataStore.Get(s.databaseContext, stagingArea, blockHash)
|
||||
}
|
||||
|
||||
func (s *consensus) GetHashesBetween(lowHash, highHash *externalapi.DomainHash, maxBlueScoreDifference uint64) (
|
||||
func (s *consensus) GetHashesBetween(lowHash, highHash *externalapi.DomainHash, maxBlocks uint64) (
|
||||
hashes []*externalapi.DomainHash, actualHighHash *externalapi.DomainHash, err error) {
|
||||
|
||||
s.lock.Lock()
|
||||
@@ -219,7 +243,7 @@ func (s *consensus) GetHashesBetween(lowHash, highHash *externalapi.DomainHash,
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return s.syncManager.GetHashesBetween(stagingArea, lowHash, highHash, maxBlueScoreDifference)
|
||||
return s.syncManager.GetHashesBetween(stagingArea, lowHash, highHash, maxBlocks)
|
||||
}
|
||||
|
||||
func (s *consensus) GetMissingBlockBodyHashes(highHash *externalapi.DomainHash) ([]*externalapi.DomainHash, error) {
|
||||
@@ -363,11 +387,17 @@ func (s *consensus) GetVirtualInfo() (*externalapi.VirtualInfo, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
daaScore, err := s.daaBlocksStore.DAAScore(s.databaseContext, stagingArea, model.VirtualBlockHash)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &externalapi.VirtualInfo{
|
||||
ParentHashes: blockRelations.Parents,
|
||||
Bits: bits,
|
||||
PastMedianTime: pastMedianTime,
|
||||
BlueScore: virtualGHOSTDAGData.BlueScore(),
|
||||
DAAScore: daaScore,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -314,6 +314,7 @@ func (f *factory) NewConsensus(config *Config, db infrastructuredatabase.Databas
|
||||
syncManager := syncmanager.New(
|
||||
dbManager,
|
||||
genesisHash,
|
||||
config.MergeSetSizeLimit,
|
||||
dagTraversalManager,
|
||||
dagTopologyManager,
|
||||
ghostdagManager,
|
||||
|
||||
@@ -7,12 +7,13 @@ type Consensus interface {
|
||||
ValidateTransactionAndPopulateWithConsensusData(transaction *DomainTransaction) error
|
||||
|
||||
GetBlock(blockHash *DomainHash) (*DomainBlock, error)
|
||||
GetBlockEvenIfHeaderOnly(blockHash *DomainHash) (*DomainBlock, error)
|
||||
GetBlockHeader(blockHash *DomainHash) (BlockHeader, error)
|
||||
GetBlockInfo(blockHash *DomainHash) (*BlockInfo, error)
|
||||
GetBlockRelations(blockHash *DomainHash) (parents []*DomainHash, selectedParent *DomainHash, children []*DomainHash, err error)
|
||||
GetBlockAcceptanceData(blockHash *DomainHash) (AcceptanceData, error)
|
||||
|
||||
GetHashesBetween(lowHash, highHash *DomainHash, maxBlueScoreDifference uint64) (hashes []*DomainHash, actualHighHash *DomainHash, err error)
|
||||
GetHashesBetween(lowHash, highHash *DomainHash, maxBlocks uint64) (hashes []*DomainHash, actualHighHash *DomainHash, err error)
|
||||
GetMissingBlockBodyHashes(highHash *DomainHash) ([]*DomainHash, error)
|
||||
GetPruningPointUTXOs(expectedPruningPointHash *DomainHash, fromOutpoint *DomainOutpoint, limit int) ([]*OutpointAndUTXOEntryPair, error)
|
||||
GetVirtualUTXOs(expectedVirtualParents []*DomainHash, fromOutpoint *DomainOutpoint, limit int) ([]*OutpointAndUTXOEntryPair, error)
|
||||
|
||||
@@ -6,4 +6,5 @@ type VirtualInfo struct {
|
||||
Bits uint32
|
||||
PastMedianTime int64
|
||||
BlueScore uint64
|
||||
DAAScore uint64
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import "github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
|
||||
|
||||
// SyncManager exposes functions to support sync between kaspad nodes
|
||||
type SyncManager interface {
|
||||
GetHashesBetween(stagingArea *StagingArea, lowHash, highHash *externalapi.DomainHash, maxBlueScoreDifference uint64) (
|
||||
GetHashesBetween(stagingArea *StagingArea, lowHash, highHash *externalapi.DomainHash, maxBlocks uint64) (
|
||||
hashes []*externalapi.DomainHash, actualHighHash *externalapi.DomainHash, err error)
|
||||
GetMissingBlockBodyHashes(stagingArea *StagingArea, highHash *externalapi.DomainHash) (
|
||||
[]*externalapi.DomainHash, error)
|
||||
|
||||
@@ -59,6 +59,22 @@ func (bp *blockProcessor) setBlockStatusAfterBlockValidation(
|
||||
return nil
|
||||
}
|
||||
|
||||
func (bp *blockProcessor) updateVirtualAcceptanceDataAfterImportingPruningPoint(stagingArea *model.StagingArea) error {
|
||||
|
||||
_, virtualAcceptanceData, virtualMultiset, err :=
|
||||
bp.consensusStateManager.CalculatePastUTXOAndAcceptanceData(stagingArea, model.VirtualBlockHash)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Debugf("Staging virtual acceptance data after importing the pruning point")
|
||||
bp.acceptanceDataStore.Stage(stagingArea, model.VirtualBlockHash, virtualAcceptanceData)
|
||||
|
||||
log.Debugf("Staging virtual multiset after importing the pruning point")
|
||||
bp.multisetStore.Stage(stagingArea, model.VirtualBlockHash, virtualMultiset)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (bp *blockProcessor) validateAndInsertBlock(stagingArea *model.StagingArea, block *externalapi.DomainBlock,
|
||||
isPruningPoint bool) (*externalapi.BlockInsertionResult, error) {
|
||||
|
||||
@@ -102,6 +118,11 @@ func (bp *blockProcessor) validateAndInsertBlock(stagingArea *model.StagingArea,
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
err := bp.updateVirtualAcceptanceDataAfterImportingPruningPoint(stagingArea)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,11 +7,19 @@ import (
|
||||
)
|
||||
|
||||
// antiPastHashesBetween returns the hashes of the blocks between the
|
||||
// lowHash's antiPast and highHash's antiPast, or up to
|
||||
// `maxBlueScoreDifference`, if non-zero.
|
||||
// lowHash's antiPast and highHash's antiPast, or up to `maxBlocks`, if non-zero.
|
||||
// The result excludes lowHash and includes highHash. If lowHash == highHash, returns nothing.
|
||||
// If maxBlocks != 0 then maxBlocks MUST be >= MergeSetSizeLimit + 1
|
||||
// because it returns blocks with MergeSet granularity,
|
||||
// so if MergeSet > maxBlocks, function will return nothing
|
||||
func (sm *syncManager) antiPastHashesBetween(stagingArea *model.StagingArea, lowHash, highHash *externalapi.DomainHash,
|
||||
maxBlueScoreDifference uint64) (hashes []*externalapi.DomainHash, actualHighHash *externalapi.DomainHash, err error) {
|
||||
maxBlocks uint64) (hashes []*externalapi.DomainHash, actualHighHash *externalapi.DomainHash, err error) {
|
||||
|
||||
// Sanity check, for debugging only
|
||||
if maxBlocks != 0 && maxBlocks < sm.mergeSetSizeLimit+1 {
|
||||
return nil, nil,
|
||||
errors.Errorf("maxBlocks (%d) MUST be >= MergeSetSizeLimit + 1 (%d)", maxBlocks, sm.mergeSetSizeLimit+1)
|
||||
}
|
||||
|
||||
// If lowHash is not in the selectedParentChain of highHash - SelectedChildIterator will fail.
|
||||
// Therefore, we traverse down lowHash's selectedParentChain until we reach a block that is in
|
||||
@@ -36,23 +44,6 @@ func (sm *syncManager) antiPastHashesBetween(stagingArea *model.StagingArea, low
|
||||
lowBlockGHOSTDAGData.BlueScore(), highBlockGHOSTDAGData.BlueScore())
|
||||
}
|
||||
|
||||
if maxBlueScoreDifference != 0 {
|
||||
// In order to get no more then maxBlueScoreDifference
|
||||
// blocks from the future of the lowHash (including itself),
|
||||
// we iterate the selected parent chain of the highNode and
|
||||
// stop once we reach
|
||||
// highBlockBlueScore-lowBlockBlueScore+1 <= maxBlueScoreDifference.
|
||||
// That stop point becomes the new highHash.
|
||||
// Using blueScore as an approximation is considered to be
|
||||
// fairly accurate because we presume that most DAG blocks are
|
||||
// blue.
|
||||
highHash, err = sm.findHighHashAccordingToMaxBlueScoreDifference(stagingArea,
|
||||
lowHash, highHash, maxBlueScoreDifference, highBlockGHOSTDAGData, lowBlockGHOSTDAGData)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// Collect all hashes by concatenating the merge-sets of all blocks between highHash and lowHash
|
||||
blockHashes := []*externalapi.DomainHash{}
|
||||
iterator, err := sm.dagTraversalManager.SelectedChildIterator(stagingArea, highHash, lowHash)
|
||||
@@ -76,6 +67,12 @@ func (sm *syncManager) antiPastHashesBetween(stagingArea *model.StagingArea, low
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
if maxBlocks != 0 && uint64(len(blockHashes)+len(sortedMergeSet)) > maxBlocks {
|
||||
break
|
||||
}
|
||||
|
||||
highHash = current
|
||||
|
||||
// append to blockHashes all blocks in sortedMergeSet which are not in the past of originalLowHash
|
||||
for _, blockHash := range sortedMergeSet {
|
||||
isInPastOfOriginalLowHash, err := sm.dagTopologyManager.IsAncestorOf(stagingArea, blockHash, originalLowHash)
|
||||
@@ -136,37 +133,6 @@ func (sm *syncManager) getSortedMergeSet(stagingArea *model.StagingArea, current
|
||||
return sortedMergeSet, nil
|
||||
}
|
||||
|
||||
func (sm *syncManager) findHighHashAccordingToMaxBlueScoreDifference(stagingArea *model.StagingArea,
|
||||
lowHash *externalapi.DomainHash, highHash *externalapi.DomainHash, maxBlueScoreDifference uint64,
|
||||
highBlockGHOSTDAGData *model.BlockGHOSTDAGData, lowBlockGHOSTDAGData *model.BlockGHOSTDAGData) (
|
||||
*externalapi.DomainHash, error) {
|
||||
|
||||
if highBlockGHOSTDAGData.BlueScore()-lowBlockGHOSTDAGData.BlueScore() <= maxBlueScoreDifference {
|
||||
return highHash, nil
|
||||
}
|
||||
|
||||
iterator, err := sm.dagTraversalManager.SelectedChildIterator(stagingArea, highHash, lowHash)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer iterator.Close()
|
||||
for ok := iterator.First(); ok; ok = iterator.Next() {
|
||||
highHashCandidate, err := iterator.Get()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
highBlockGHOSTDAGData, err = sm.ghostdagDataStore.Get(sm.databaseContext, stagingArea, highHashCandidate)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if highBlockGHOSTDAGData.BlueScore()-lowBlockGHOSTDAGData.BlueScore() > maxBlueScoreDifference {
|
||||
break
|
||||
}
|
||||
highHash = highHashCandidate
|
||||
}
|
||||
return highHash, nil
|
||||
}
|
||||
|
||||
func (sm *syncManager) findLowHashInHighHashSelectedParentChain(stagingArea *model.StagingArea,
|
||||
lowHash *externalapi.DomainHash, highHash *externalapi.DomainHash) (*externalapi.DomainHash, error) {
|
||||
for {
|
||||
|
||||
@@ -21,12 +21,15 @@ type syncManager struct {
|
||||
blockStore model.BlockStore
|
||||
pruningStore model.PruningStore
|
||||
headersSelectedChainStore model.HeadersSelectedChainStore
|
||||
|
||||
mergeSetSizeLimit uint64
|
||||
}
|
||||
|
||||
// New instantiates a new SyncManager
|
||||
func New(
|
||||
databaseContext model.DBReader,
|
||||
genesisBlockHash *externalapi.DomainHash,
|
||||
mergeSetSizeLimit uint64,
|
||||
dagTraversalManager model.DAGTraversalManager,
|
||||
dagTopologyManager model.DAGTopologyManager,
|
||||
ghostdagManager model.GHOSTDAGManager,
|
||||
@@ -58,12 +61,12 @@ func New(
|
||||
}
|
||||
|
||||
func (sm *syncManager) GetHashesBetween(stagingArea *model.StagingArea, lowHash, highHash *externalapi.DomainHash,
|
||||
maxBlueScoreDifference uint64) (hashes []*externalapi.DomainHash, actualHighHash *externalapi.DomainHash, err error) {
|
||||
maxBlocks uint64) (hashes []*externalapi.DomainHash, actualHighHash *externalapi.DomainHash, err error) {
|
||||
|
||||
onEnd := logger.LogAndMeasureExecutionTime(log, "GetHashesBetween")
|
||||
defer onEnd()
|
||||
|
||||
return sm.antiPastHashesBetween(stagingArea, lowHash, highHash, maxBlueScoreDifference)
|
||||
return sm.antiPastHashesBetween(stagingArea, lowHash, highHash, maxBlocks)
|
||||
}
|
||||
|
||||
func (sm *syncManager) GetMissingBlockBodyHashes(stagingArea *model.StagingArea, highHash *externalapi.DomainHash) ([]*externalapi.DomainHash, error) {
|
||||
|
||||
@@ -68,8 +68,7 @@ func (v *transactionValidator) checkTransactionCoinbaseMaturity(stagingArea *mod
|
||||
missingOutpoints = append(missingOutpoints, &input.PreviousOutpoint)
|
||||
} else if utxoEntry.IsCoinbase() {
|
||||
originDAAScore := utxoEntry.BlockDAAScore()
|
||||
daaScoreSincePrev := povDAAScore - originDAAScore
|
||||
if daaScoreSincePrev < v.blockCoinbaseMaturity {
|
||||
if originDAAScore+v.blockCoinbaseMaturity > povDAAScore {
|
||||
return errors.Wrapf(ruleerrors.ErrImmatureSpend, "tried to spend coinbase "+
|
||||
"transaction output %s from DAA score %d "+
|
||||
"to DAA score %d before required maturity "+
|
||||
@@ -266,7 +265,7 @@ func (v *transactionValidator) calcTxSequenceLockFromReferencedUTXOEntries(stagi
|
||||
baseHash := povBlockHash
|
||||
|
||||
for {
|
||||
selectedParentDAAScore, err := v.daaBlocksStore.DAAScore(v.databaseContext, stagingArea, povBlockHash)
|
||||
selectedParentDAAScore, err := v.daaBlocksStore.DAAScore(v.databaseContext, stagingArea, baseHash)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -78,7 +78,17 @@ func TestValidateTransactionInContextAndPopulateMassAndFee(t *testing.T) {
|
||||
true,
|
||||
uint64(5)),
|
||||
}
|
||||
txInputWithMaxSequence := externalapi.DomainTransactionInput{
|
||||
immatureInput := externalapi.DomainTransactionInput{
|
||||
PreviousOutpoint: prevOutPoint,
|
||||
SignatureScript: []byte{},
|
||||
Sequence: constants.MaxTxInSequenceNum,
|
||||
UTXOEntry: utxo.NewUTXOEntry(
|
||||
100_000_000, // 1 KAS
|
||||
scriptPublicKey,
|
||||
true,
|
||||
uint64(6)),
|
||||
}
|
||||
txInputWithSequenceLockTimeIsSeconds := externalapi.DomainTransactionInput{
|
||||
PreviousOutpoint: prevOutPoint,
|
||||
SignatureScript: []byte{},
|
||||
Sequence: constants.SequenceLockTimeIsSeconds,
|
||||
@@ -110,7 +120,7 @@ func TestValidateTransactionInContextAndPopulateMassAndFee(t *testing.T) {
|
||||
|
||||
validTx := externalapi.DomainTransaction{
|
||||
Version: constants.MaxTransactionVersion,
|
||||
Inputs: []*externalapi.DomainTransactionInput{&txInputWithMaxSequence},
|
||||
Inputs: []*externalapi.DomainTransactionInput{&txInputWithSequenceLockTimeIsSeconds},
|
||||
Outputs: []*externalapi.DomainTransactionOutput{&txOut},
|
||||
SubnetworkID: subnetworks.SubnetworkIDRegistry,
|
||||
Gas: 0,
|
||||
@@ -127,7 +137,7 @@ func TestValidateTransactionInContextAndPopulateMassAndFee(t *testing.T) {
|
||||
|
||||
txWithImmatureCoinbase := externalapi.DomainTransaction{
|
||||
Version: constants.MaxTransactionVersion,
|
||||
Inputs: []*externalapi.DomainTransactionInput{&txInput},
|
||||
Inputs: []*externalapi.DomainTransactionInput{&immatureInput},
|
||||
Outputs: []*externalapi.DomainTransactionOutput{&txOut},
|
||||
SubnetworkID: subnetworks.SubnetworkIDRegistry,
|
||||
Gas: 0,
|
||||
@@ -158,7 +168,15 @@ func TestValidateTransactionInContextAndPopulateMassAndFee(t *testing.T) {
|
||||
|
||||
povBlockHash := externalapi.NewDomainHashFromByteArray(&[32]byte{0x01})
|
||||
tc.DAABlocksStore().StageDAAScore(stagingArea, povBlockHash, consensusConfig.BlockCoinbaseMaturity+txInput.UTXOEntry.BlockDAAScore())
|
||||
tc.DAABlocksStore().StageDAAScore(stagingArea, povBlockHash, 10)
|
||||
|
||||
// Just use some stub ghostdag data
|
||||
tc.GHOSTDAGDataStore().Stage(stagingArea, povBlockHash, model.NewBlockGHOSTDAGData(
|
||||
0,
|
||||
nil,
|
||||
consensusConfig.GenesisHash,
|
||||
nil,
|
||||
nil,
|
||||
nil))
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -171,7 +189,7 @@ func TestValidateTransactionInContextAndPopulateMassAndFee(t *testing.T) {
|
||||
{
|
||||
name: "Valid transaction",
|
||||
tx: &validTx,
|
||||
povBlockHash: model.VirtualBlockHash,
|
||||
povBlockHash: povBlockHash,
|
||||
selectedParentMedianTime: 1,
|
||||
isValid: true,
|
||||
expectedError: nil,
|
||||
@@ -189,7 +207,7 @@ func TestValidateTransactionInContextAndPopulateMassAndFee(t *testing.T) {
|
||||
{ // The total inputs amount is bigger than the allowed maximum (constants.MaxSompi)
|
||||
name: "checkTransactionInputAmounts",
|
||||
tx: &txWithLargeAmount,
|
||||
povBlockHash: model.VirtualBlockHash,
|
||||
povBlockHash: povBlockHash,
|
||||
selectedParentMedianTime: 1,
|
||||
isValid: false,
|
||||
expectedError: ruleerrors.ErrBadTxOutValue,
|
||||
@@ -197,7 +215,7 @@ func TestValidateTransactionInContextAndPopulateMassAndFee(t *testing.T) {
|
||||
{ // The total SompiIn (sum of inputs amount) is smaller than the total SompiOut (sum of outputs value) and hence invalid.
|
||||
name: "checkTransactionOutputAmounts",
|
||||
tx: &txWithBigValue,
|
||||
povBlockHash: model.VirtualBlockHash,
|
||||
povBlockHash: povBlockHash,
|
||||
selectedParentMedianTime: 1,
|
||||
isValid: false,
|
||||
expectedError: ruleerrors.ErrSpendTooHigh,
|
||||
@@ -205,15 +223,15 @@ func TestValidateTransactionInContextAndPopulateMassAndFee(t *testing.T) {
|
||||
{ // the selectedParentMedianTime is negative and hence invalid.
|
||||
name: "checkTransactionSequenceLock",
|
||||
tx: &validTx,
|
||||
povBlockHash: model.VirtualBlockHash,
|
||||
povBlockHash: povBlockHash,
|
||||
selectedParentMedianTime: -1,
|
||||
isValid: false,
|
||||
expectedError: ruleerrors.ErrUnfinalizedTx,
|
||||
},
|
||||
{ // The SignatureScript (in the txInput) is empty and hence invalid.
|
||||
{ // The SignatureScript (in the immatureInput) is empty and hence invalid.
|
||||
name: "checkTransactionScripts",
|
||||
tx: &txWithInvalidSignature,
|
||||
povBlockHash: model.VirtualBlockHash,
|
||||
povBlockHash: povBlockHash,
|
||||
selectedParentMedianTime: 1,
|
||||
isValid: false,
|
||||
expectedError: ruleerrors.ErrScriptValidation,
|
||||
@@ -226,7 +244,7 @@ func TestValidateTransactionInContextAndPopulateMassAndFee(t *testing.T) {
|
||||
if test.isValid {
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error on TestValidateTransactionInContextAndPopulateMassAndFee"+
|
||||
" on test '%v': %v", test.name, err)
|
||||
" on test '%v': %+v", test.name, err)
|
||||
}
|
||||
} else {
|
||||
if err == nil || !errors.Is(err, test.expectedError) {
|
||||
|
||||
@@ -49,6 +49,7 @@ const (
|
||||
RejectInsufficientFee RejectCode = 0x42
|
||||
RejectFinality RejectCode = 0x43
|
||||
RejectDifficulty RejectCode = 0x44
|
||||
RejectImmatureSpend RejectCode = 0x45
|
||||
)
|
||||
|
||||
// Map of reject codes back strings for pretty printing.
|
||||
@@ -63,6 +64,7 @@ var rejectCodeStrings = map[RejectCode]string{
|
||||
RejectFinality: "REJECT_FINALITY",
|
||||
RejectDifficulty: "REJECT_DIFFICULTY",
|
||||
RejectNotRequested: "REJECT_NOTREQUESTED",
|
||||
RejectImmatureSpend: "REJECT_IMMATURESPEND",
|
||||
}
|
||||
|
||||
// String returns the RejectCode in human-readable form.
|
||||
|
||||
@@ -720,6 +720,9 @@ func (mp *mempool) maybeAcceptTransaction(tx *consensusexternalapi.DomainTransac
|
||||
if errors.As(err, &missingOutpoints) {
|
||||
return missingOutpoints.MissingOutpoints, nil, nil
|
||||
}
|
||||
if errors.Is(err, ruleerrors.ErrImmatureSpend) {
|
||||
return nil, nil, txRuleError(RejectImmatureSpend, "one of the transaction inputs spends an immature UTXO")
|
||||
}
|
||||
if errors.As(err, &ruleerrors.RuleError{}) {
|
||||
return nil, nil, newRuleError(err)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package miningmanager_test
|
||||
|
||||
import (
|
||||
"github.com/kaspanet/kaspad/domain/miningmanager/mempool"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -70,11 +71,35 @@ func TestValidateAndInsertTransaction(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestImmatureSpend(t *testing.T) {
|
||||
testutils.ForAllNets(t, true, func(t *testing.T, consensusConfig *consensus.Config) {
|
||||
factory := consensus.NewFactory()
|
||||
tc, teardown, err := factory.NewTestConsensus(consensusConfig, "TestValidateAndInsertTransaction")
|
||||
if err != nil {
|
||||
t.Fatalf("Error setting up TestConsensus: %+v", err)
|
||||
}
|
||||
defer teardown(false)
|
||||
|
||||
miningFactory := miningmanager.NewFactory()
|
||||
miningManager := miningFactory.NewMiningManager(tc, &consensusConfig.Params)
|
||||
tx := createTransactionWithUTXOEntry(t, 0)
|
||||
err = miningManager.ValidateAndInsertTransaction(tx, false)
|
||||
txRuleError := &mempool.TxRuleError{}
|
||||
if !errors.As(err, txRuleError) || txRuleError.RejectCode != mempool.RejectImmatureSpend {
|
||||
t.Fatalf("Unexpected error %+v", err)
|
||||
}
|
||||
transactionsFromMempool := miningManager.AllTransactions()
|
||||
if contains(tx, transactionsFromMempool) {
|
||||
t.Fatalf("Mempool contains a transaction with immature coinbase")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// TestInsertDoubleTransactionsToMempool verifies that an attempt to insert a transaction
|
||||
// more than once into the mempool will result in raising an appropriate error.
|
||||
func TestInsertDoubleTransactionsToMempool(t *testing.T) {
|
||||
testutils.ForAllNets(t, true, func(t *testing.T, consensusConfig *consensus.Config) {
|
||||
|
||||
consensusConfig.BlockCoinbaseMaturity = 0
|
||||
factory := consensus.NewFactory()
|
||||
tc, teardown, err := factory.NewTestConsensus(consensusConfig, "TestInsertDoubleTransactionsToMempool")
|
||||
if err != nil {
|
||||
@@ -99,7 +124,7 @@ func TestInsertDoubleTransactionsToMempool(t *testing.T) {
|
||||
// TestHandleNewBlockTransactions verifies that all the transactions in the block were successfully removed from the mempool.
|
||||
func TestHandleNewBlockTransactions(t *testing.T) {
|
||||
testutils.ForAllNets(t, true, func(t *testing.T, consensusConfig *consensus.Config) {
|
||||
|
||||
consensusConfig.BlockCoinbaseMaturity = 0
|
||||
factory := consensus.NewFactory()
|
||||
tc, teardown, err := factory.NewTestConsensus(consensusConfig, "TestHandleNewBlockTransactions")
|
||||
if err != nil {
|
||||
@@ -165,7 +190,7 @@ func domainBlocksToBlockIds(blocks []*externalapi.DomainTransaction) []*external
|
||||
// will be removed from the mempool.
|
||||
func TestDoubleSpends(t *testing.T) {
|
||||
testutils.ForAllNets(t, true, func(t *testing.T, consensusConfig *consensus.Config) {
|
||||
|
||||
consensusConfig.BlockCoinbaseMaturity = 0
|
||||
factory := consensus.NewFactory()
|
||||
tc, teardown, err := factory.NewTestConsensus(consensusConfig, "TestDoubleSpends")
|
||||
if err != nil {
|
||||
@@ -309,7 +334,7 @@ func createTransactionWithUTXOEntry(t *testing.T, i int) *externalapi.DomainTran
|
||||
100000000, // 1 KAS
|
||||
scriptPublicKey,
|
||||
true,
|
||||
uint64(5)),
|
||||
uint64(0)),
|
||||
}
|
||||
txOut := externalapi.DomainTransactionOutput{
|
||||
Value: 10000,
|
||||
|
||||
@@ -243,7 +243,7 @@ func (as *addressStore) serializeAddress(address *address) []byte {
|
||||
serializedSize := 16 + 2 + 8 + 8 // ipv6 + port + timestamp + connectionFailedCount
|
||||
serializedNetAddress := make([]byte, serializedSize)
|
||||
|
||||
copy(serializedNetAddress[:], address.netAddress.IP[:])
|
||||
copy(serializedNetAddress[:], address.netAddress.IP.To16()[:])
|
||||
binary.LittleEndian.PutUint16(serializedNetAddress[16:], address.netAddress.Port)
|
||||
binary.LittleEndian.PutUint64(serializedNetAddress[18:], uint64(address.netAddress.Timestamp.UnixMilliseconds()))
|
||||
binary.LittleEndian.PutUint64(serializedNetAddress[26:], uint64(address.connectionFailedCount))
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.25.0
|
||||
// protoc-gen-go v1.26.0
|
||||
// protoc v3.12.3
|
||||
// source: messages.proto
|
||||
|
||||
package protowire
|
||||
|
||||
import (
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
@@ -21,10 +20,6 @@ const (
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// This is a compile-time assertion that a sufficiently up-to-date version
|
||||
// of the legacy proto package is being used.
|
||||
const _ = proto.ProtoPackageIsVersion4
|
||||
|
||||
type KaspadMessage struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
@@ -134,6 +129,9 @@ type KaspadMessage struct {
|
||||
// *KaspadMessage_PruningPointUTXOSetOverrideNotification
|
||||
// *KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideRequest
|
||||
// *KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideResponse
|
||||
// *KaspadMessage_NotifyVirtualDaaScoreChangedRequest
|
||||
// *KaspadMessage_NotifyVirtualDaaScoreChangedResponse
|
||||
// *KaspadMessage_VirtualDaaScoreChangedNotification
|
||||
Payload isKaspadMessage_Payload `protobuf_oneof:"payload"`
|
||||
}
|
||||
|
||||
@@ -897,6 +895,27 @@ func (x *KaspadMessage) GetStopNotifyingPruningPointUTXOSetOverrideResponse() *S
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *KaspadMessage) GetNotifyVirtualDaaScoreChangedRequest() *NotifyVirtualDaaScoreChangedRequestMessage {
|
||||
if x, ok := x.GetPayload().(*KaspadMessage_NotifyVirtualDaaScoreChangedRequest); ok {
|
||||
return x.NotifyVirtualDaaScoreChangedRequest
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *KaspadMessage) GetNotifyVirtualDaaScoreChangedResponse() *NotifyVirtualDaaScoreChangedResponseMessage {
|
||||
if x, ok := x.GetPayload().(*KaspadMessage_NotifyVirtualDaaScoreChangedResponse); ok {
|
||||
return x.NotifyVirtualDaaScoreChangedResponse
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *KaspadMessage) GetVirtualDaaScoreChangedNotification() *VirtualDaaScoreChangedNotificationMessage {
|
||||
if x, ok := x.GetPayload().(*KaspadMessage_VirtualDaaScoreChangedNotification); ok {
|
||||
return x.VirtualDaaScoreChangedNotification
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type isKaspadMessage_Payload interface {
|
||||
isKaspadMessage_Payload()
|
||||
}
|
||||
@@ -1313,6 +1332,18 @@ type KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideResponse struct {
|
||||
StopNotifyingPruningPointUTXOSetOverrideResponse *StopNotifyingPruningPointUTXOSetOverrideResponseMessage `protobuf:"bytes,1071,opt,name=stopNotifyingPruningPointUTXOSetOverrideResponse,proto3,oneof"`
|
||||
}
|
||||
|
||||
type KaspadMessage_NotifyVirtualDaaScoreChangedRequest struct {
|
||||
NotifyVirtualDaaScoreChangedRequest *NotifyVirtualDaaScoreChangedRequestMessage `protobuf:"bytes,1072,opt,name=notifyVirtualDaaScoreChangedRequest,proto3,oneof"`
|
||||
}
|
||||
|
||||
type KaspadMessage_NotifyVirtualDaaScoreChangedResponse struct {
|
||||
NotifyVirtualDaaScoreChangedResponse *NotifyVirtualDaaScoreChangedResponseMessage `protobuf:"bytes,1073,opt,name=notifyVirtualDaaScoreChangedResponse,proto3,oneof"`
|
||||
}
|
||||
|
||||
type KaspadMessage_VirtualDaaScoreChangedNotification struct {
|
||||
VirtualDaaScoreChangedNotification *VirtualDaaScoreChangedNotificationMessage `protobuf:"bytes,1074,opt,name=virtualDaaScoreChangedNotification,proto3,oneof"`
|
||||
}
|
||||
|
||||
func (*KaspadMessage_Addresses) isKaspadMessage_Payload() {}
|
||||
|
||||
func (*KaspadMessage_Block) isKaspadMessage_Payload() {}
|
||||
@@ -1519,13 +1550,19 @@ func (*KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideRequest) isKaspadMe
|
||||
|
||||
func (*KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideResponse) isKaspadMessage_Payload() {}
|
||||
|
||||
func (*KaspadMessage_NotifyVirtualDaaScoreChangedRequest) isKaspadMessage_Payload() {}
|
||||
|
||||
func (*KaspadMessage_NotifyVirtualDaaScoreChangedResponse) isKaspadMessage_Payload() {}
|
||||
|
||||
func (*KaspadMessage_VirtualDaaScoreChangedNotification) isKaspadMessage_Payload() {}
|
||||
|
||||
var File_messages_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_messages_proto_rawDesc = []byte{
|
||||
0x0a, 0x0e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x12, 0x09, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x1a, 0x09, 0x70, 0x32, 0x70,
|
||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x09, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x22, 0xa4, 0x55, 0x0a, 0x0d, 0x4b, 0x61, 0x73, 0x70, 0x61, 0x64, 0x4d, 0x65, 0x73, 0x73,
|
||||
0x6f, 0x22, 0xcb, 0x58, 0x0a, 0x0d, 0x4b, 0x61, 0x73, 0x70, 0x61, 0x64, 0x4d, 0x65, 0x73, 0x73,
|
||||
0x61, 0x67, 0x65, 0x12, 0x3b, 0x0a, 0x09, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73,
|
||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69,
|
||||
0x72, 0x65, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x4d, 0x65, 0x73, 0x73,
|
||||
@@ -2206,21 +2243,48 @@ var file_messages_proto_rawDesc = []byte{
|
||||
0x73, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x00, 0x52, 0x30, 0x73, 0x74, 0x6f,
|
||||
0x70, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x69, 0x6e, 0x67, 0x50, 0x72, 0x75, 0x6e, 0x69, 0x6e,
|
||||
0x67, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x55, 0x54, 0x58, 0x4f, 0x53, 0x65, 0x74, 0x4f, 0x76, 0x65,
|
||||
0x72, 0x72, 0x69, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x09, 0x0a,
|
||||
0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x32, 0x50, 0x0a, 0x03, 0x50, 0x32, 0x50, 0x12,
|
||||
0x49, 0x0a, 0x0d, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d,
|
||||
0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x4b, 0x61, 0x73,
|
||||
0x70, 0x61, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x4b, 0x61, 0x73, 0x70, 0x61, 0x64, 0x4d, 0x65, 0x73,
|
||||
0x73, 0x61, 0x67, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x32, 0x50, 0x0a, 0x03, 0x52, 0x50,
|
||||
0x43, 0x12, 0x49, 0x0a, 0x0d, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x53, 0x74, 0x72, 0x65,
|
||||
0x61, 0x6d, 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x4b,
|
||||
0x61, 0x73, 0x70, 0x61, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x18, 0x2e, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x4b, 0x61, 0x73, 0x70, 0x61, 0x64, 0x4d,
|
||||
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 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,
|
||||
0x72, 0x72, 0x69, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x8a, 0x01,
|
||||
0x0a, 0x23, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x56, 0x69, 0x72, 0x74, 0x75, 0x61, 0x6c, 0x44,
|
||||
0x61, 0x61, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x64, 0x52, 0x65,
|
||||
0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0xb0, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x56,
|
||||
0x69, 0x72, 0x74, 0x75, 0x61, 0x6c, 0x44, 0x61, 0x61, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x43, 0x68,
|
||||
0x61, 0x6e, 0x67, 0x65, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73,
|
||||
0x61, 0x67, 0x65, 0x48, 0x00, 0x52, 0x23, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x56, 0x69, 0x72,
|
||||
0x74, 0x75, 0x61, 0x6c, 0x44, 0x61, 0x61, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x43, 0x68, 0x61, 0x6e,
|
||||
0x67, 0x65, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x8d, 0x01, 0x0a, 0x24, 0x6e,
|
||||
0x6f, 0x74, 0x69, 0x66, 0x79, 0x56, 0x69, 0x72, 0x74, 0x75, 0x61, 0x6c, 0x44, 0x61, 0x61, 0x53,
|
||||
0x63, 0x6f, 0x72, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f,
|
||||
0x6e, 0x73, 0x65, 0x18, 0xb1, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x36, 0x2e, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x56, 0x69, 0x72,
|
||||
0x74, 0x75, 0x61, 0x6c, 0x44, 0x61, 0x61, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x43, 0x68, 0x61, 0x6e,
|
||||
0x67, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61,
|
||||
0x67, 0x65, 0x48, 0x00, 0x52, 0x24, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x56, 0x69, 0x72, 0x74,
|
||||
0x75, 0x61, 0x6c, 0x44, 0x61, 0x61, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67,
|
||||
0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x87, 0x01, 0x0a, 0x22, 0x76,
|
||||
0x69, 0x72, 0x74, 0x75, 0x61, 0x6c, 0x44, 0x61, 0x61, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x43, 0x68,
|
||||
0x61, 0x6e, 0x67, 0x65, 0x64, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x18, 0xb2, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x34, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x77, 0x69, 0x72, 0x65, 0x2e, 0x56, 0x69, 0x72, 0x74, 0x75, 0x61, 0x6c, 0x44, 0x61, 0x61, 0x53,
|
||||
0x63, 0x6f, 0x72, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x64, 0x4e, 0x6f, 0x74, 0x69, 0x66,
|
||||
0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x00,
|
||||
0x52, 0x22, 0x76, 0x69, 0x72, 0x74, 0x75, 0x61, 0x6c, 0x44, 0x61, 0x61, 0x53, 0x63, 0x6f, 0x72,
|
||||
0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x64, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x42, 0x09, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x32,
|
||||
0x50, 0x0a, 0x03, 0x50, 0x32, 0x50, 0x12, 0x49, 0x0a, 0x0d, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67,
|
||||
0x65, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77,
|
||||
0x69, 0x72, 0x65, 0x2e, 0x4b, 0x61, 0x73, 0x70, 0x61, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67,
|
||||
0x65, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x4b, 0x61,
|
||||
0x73, 0x70, 0x61, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30,
|
||||
0x01, 0x32, 0x50, 0x0a, 0x03, 0x52, 0x50, 0x43, 0x12, 0x49, 0x0a, 0x0d, 0x4d, 0x65, 0x73, 0x73,
|
||||
0x61, 0x67, 0x65, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x4b, 0x61, 0x73, 0x70, 0x61, 0x64, 0x4d, 0x65, 0x73, 0x73,
|
||||
0x61, 0x67, 0x65, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e,
|
||||
0x4b, 0x61, 0x73, 0x70, 0x61, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x00, 0x28,
|
||||
0x01, 0x30, 0x01, 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 (
|
||||
@@ -2340,6 +2404,9 @@ var file_messages_proto_goTypes = []interface{}{
|
||||
(*PruningPointUTXOSetOverrideNotificationMessage)(nil), // 100: protowire.PruningPointUTXOSetOverrideNotificationMessage
|
||||
(*StopNotifyingPruningPointUTXOSetOverrideRequestMessage)(nil), // 101: protowire.StopNotifyingPruningPointUTXOSetOverrideRequestMessage
|
||||
(*StopNotifyingPruningPointUTXOSetOverrideResponseMessage)(nil), // 102: protowire.StopNotifyingPruningPointUTXOSetOverrideResponseMessage
|
||||
(*NotifyVirtualDaaScoreChangedRequestMessage)(nil), // 103: protowire.NotifyVirtualDaaScoreChangedRequestMessage
|
||||
(*NotifyVirtualDaaScoreChangedResponseMessage)(nil), // 104: protowire.NotifyVirtualDaaScoreChangedResponseMessage
|
||||
(*VirtualDaaScoreChangedNotificationMessage)(nil), // 105: protowire.VirtualDaaScoreChangedNotificationMessage
|
||||
}
|
||||
var file_messages_proto_depIdxs = []int32{
|
||||
1, // 0: protowire.KaspadMessage.addresses:type_name -> protowire.AddressesMessage
|
||||
@@ -2445,15 +2512,18 @@ var file_messages_proto_depIdxs = []int32{
|
||||
100, // 100: protowire.KaspadMessage.pruningPointUTXOSetOverrideNotification:type_name -> protowire.PruningPointUTXOSetOverrideNotificationMessage
|
||||
101, // 101: protowire.KaspadMessage.stopNotifyingPruningPointUTXOSetOverrideRequest:type_name -> protowire.StopNotifyingPruningPointUTXOSetOverrideRequestMessage
|
||||
102, // 102: protowire.KaspadMessage.stopNotifyingPruningPointUTXOSetOverrideResponse:type_name -> protowire.StopNotifyingPruningPointUTXOSetOverrideResponseMessage
|
||||
0, // 103: protowire.P2P.MessageStream:input_type -> protowire.KaspadMessage
|
||||
0, // 104: protowire.RPC.MessageStream:input_type -> protowire.KaspadMessage
|
||||
0, // 105: protowire.P2P.MessageStream:output_type -> protowire.KaspadMessage
|
||||
0, // 106: protowire.RPC.MessageStream:output_type -> protowire.KaspadMessage
|
||||
105, // [105:107] is the sub-list for method output_type
|
||||
103, // [103:105] is the sub-list for method input_type
|
||||
103, // [103:103] is the sub-list for extension type_name
|
||||
103, // [103:103] is the sub-list for extension extendee
|
||||
0, // [0:103] is the sub-list for field type_name
|
||||
103, // 103: protowire.KaspadMessage.notifyVirtualDaaScoreChangedRequest:type_name -> protowire.NotifyVirtualDaaScoreChangedRequestMessage
|
||||
104, // 104: protowire.KaspadMessage.notifyVirtualDaaScoreChangedResponse:type_name -> protowire.NotifyVirtualDaaScoreChangedResponseMessage
|
||||
105, // 105: protowire.KaspadMessage.virtualDaaScoreChangedNotification:type_name -> protowire.VirtualDaaScoreChangedNotificationMessage
|
||||
0, // 106: protowire.P2P.MessageStream:input_type -> protowire.KaspadMessage
|
||||
0, // 107: protowire.RPC.MessageStream:input_type -> protowire.KaspadMessage
|
||||
0, // 108: protowire.P2P.MessageStream:output_type -> protowire.KaspadMessage
|
||||
0, // 109: protowire.RPC.MessageStream:output_type -> protowire.KaspadMessage
|
||||
108, // [108:110] is the sub-list for method output_type
|
||||
106, // [106:108] is the sub-list for method input_type
|
||||
106, // [106:106] is the sub-list for extension type_name
|
||||
106, // [106:106] is the sub-list for extension extendee
|
||||
0, // [0:106] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_messages_proto_init() }
|
||||
@@ -2581,6 +2651,9 @@ func file_messages_proto_init() {
|
||||
(*KaspadMessage_PruningPointUTXOSetOverrideNotification)(nil),
|
||||
(*KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideRequest)(nil),
|
||||
(*KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideResponse)(nil),
|
||||
(*KaspadMessage_NotifyVirtualDaaScoreChangedRequest)(nil),
|
||||
(*KaspadMessage_NotifyVirtualDaaScoreChangedResponse)(nil),
|
||||
(*KaspadMessage_VirtualDaaScoreChangedNotification)(nil),
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
|
||||
@@ -112,6 +112,9 @@ message KaspadMessage {
|
||||
PruningPointUTXOSetOverrideNotificationMessage pruningPointUTXOSetOverrideNotification = 1069;
|
||||
StopNotifyingPruningPointUTXOSetOverrideRequestMessage stopNotifyingPruningPointUTXOSetOverrideRequest = 1070;
|
||||
StopNotifyingPruningPointUTXOSetOverrideResponseMessage stopNotifyingPruningPointUTXOSetOverrideResponse = 1071;
|
||||
NotifyVirtualDaaScoreChangedRequestMessage notifyVirtualDaaScoreChangedRequest = 1072;
|
||||
NotifyVirtualDaaScoreChangedResponseMessage notifyVirtualDaaScoreChangedResponse = 1073;
|
||||
VirtualDaaScoreChangedNotificationMessage virtualDaaScoreChangedNotification = 1074;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,8 @@ import (
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
const _ = grpc.SupportPackageIsVersion6
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
// P2PClient is the client API for P2P service.
|
||||
//
|
||||
@@ -29,7 +30,7 @@ func NewP2PClient(cc grpc.ClientConnInterface) P2PClient {
|
||||
}
|
||||
|
||||
func (c *p2PClient) MessageStream(ctx context.Context, opts ...grpc.CallOption) (P2P_MessageStreamClient, error) {
|
||||
stream, err := c.cc.NewStream(ctx, &_P2P_serviceDesc.Streams[0], "/protowire.P2P/MessageStream", opts...)
|
||||
stream, err := c.cc.NewStream(ctx, &P2P_ServiceDesc.Streams[0], "/protowire.P2P/MessageStream", opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -71,13 +72,20 @@ type P2PServer interface {
|
||||
type UnimplementedP2PServer struct {
|
||||
}
|
||||
|
||||
func (*UnimplementedP2PServer) MessageStream(P2P_MessageStreamServer) error {
|
||||
func (UnimplementedP2PServer) MessageStream(P2P_MessageStreamServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method MessageStream not implemented")
|
||||
}
|
||||
func (*UnimplementedP2PServer) mustEmbedUnimplementedP2PServer() {}
|
||||
func (UnimplementedP2PServer) mustEmbedUnimplementedP2PServer() {}
|
||||
|
||||
func RegisterP2PServer(s *grpc.Server, srv P2PServer) {
|
||||
s.RegisterService(&_P2P_serviceDesc, srv)
|
||||
// UnsafeP2PServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to P2PServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeP2PServer interface {
|
||||
mustEmbedUnimplementedP2PServer()
|
||||
}
|
||||
|
||||
func RegisterP2PServer(s grpc.ServiceRegistrar, srv P2PServer) {
|
||||
s.RegisterService(&P2P_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _P2P_MessageStream_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
@@ -106,7 +114,10 @@ func (x *p2PMessageStreamServer) Recv() (*KaspadMessage, error) {
|
||||
return m, nil
|
||||
}
|
||||
|
||||
var _P2P_serviceDesc = grpc.ServiceDesc{
|
||||
// P2P_ServiceDesc is the grpc.ServiceDesc for P2P service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var P2P_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "protowire.P2P",
|
||||
HandlerType: (*P2PServer)(nil),
|
||||
Methods: []grpc.MethodDesc{},
|
||||
@@ -137,7 +148,7 @@ func NewRPCClient(cc grpc.ClientConnInterface) RPCClient {
|
||||
}
|
||||
|
||||
func (c *rPCClient) MessageStream(ctx context.Context, opts ...grpc.CallOption) (RPC_MessageStreamClient, error) {
|
||||
stream, err := c.cc.NewStream(ctx, &_RPC_serviceDesc.Streams[0], "/protowire.RPC/MessageStream", opts...)
|
||||
stream, err := c.cc.NewStream(ctx, &RPC_ServiceDesc.Streams[0], "/protowire.RPC/MessageStream", opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -179,13 +190,20 @@ type RPCServer interface {
|
||||
type UnimplementedRPCServer struct {
|
||||
}
|
||||
|
||||
func (*UnimplementedRPCServer) MessageStream(RPC_MessageStreamServer) error {
|
||||
func (UnimplementedRPCServer) MessageStream(RPC_MessageStreamServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method MessageStream not implemented")
|
||||
}
|
||||
func (*UnimplementedRPCServer) mustEmbedUnimplementedRPCServer() {}
|
||||
func (UnimplementedRPCServer) mustEmbedUnimplementedRPCServer() {}
|
||||
|
||||
func RegisterRPCServer(s *grpc.Server, srv RPCServer) {
|
||||
s.RegisterService(&_RPC_serviceDesc, srv)
|
||||
// UnsafeRPCServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to RPCServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeRPCServer interface {
|
||||
mustEmbedUnimplementedRPCServer()
|
||||
}
|
||||
|
||||
func RegisterRPCServer(s grpc.ServiceRegistrar, srv RPCServer) {
|
||||
s.RegisterService(&RPC_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _RPC_MessageStream_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
@@ -214,7 +232,10 @@ func (x *rPCMessageStreamServer) Recv() (*KaspadMessage, error) {
|
||||
return m, nil
|
||||
}
|
||||
|
||||
var _RPC_serviceDesc = grpc.ServiceDesc{
|
||||
// RPC_ServiceDesc is the grpc.ServiceDesc for RPC service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var RPC_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "protowire.RPC",
|
||||
HandlerType: (*RPCServer)(nil),
|
||||
Methods: []grpc.MethodDesc{},
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.25.0
|
||||
// protoc-gen-go v1.26.0
|
||||
// protoc v3.12.3
|
||||
// source: p2p.proto
|
||||
|
||||
package protowire
|
||||
|
||||
import (
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
@@ -21,10 +20,6 @@ const (
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// This is a compile-time assertion that a sufficiently up-to-date version
|
||||
// of the legacy proto package is being used.
|
||||
const _ = proto.ProtoPackageIsVersion4
|
||||
|
||||
type RequestAddressesMessage struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
|
||||
@@ -4,32 +4,42 @@
|
||||
## Table of Contents
|
||||
|
||||
- [rpc.proto](#rpc.proto)
|
||||
- [RPCError](#protowire.RPCError)
|
||||
- [GetCurrentNetworkRequestMessage](#protowire.GetCurrentNetworkRequestMessage)
|
||||
- [GetCurrentNetworkResponseMessage](#protowire.GetCurrentNetworkResponseMessage)
|
||||
- [SubmitBlockRequestMessage](#protowire.SubmitBlockRequestMessage)
|
||||
- [RpcBlock](#protowire.RpcBlock)
|
||||
- [RpcBlockHeader](#protowire.RpcBlockHeader)
|
||||
- [SubmitBlockResponseMessage](#protowire.SubmitBlockResponseMessage)
|
||||
- [GetBlockTemplateRequestMessage](#protowire.GetBlockTemplateRequestMessage)
|
||||
- [GetBlockTemplateResponseMessage](#protowire.GetBlockTemplateResponseMessage)
|
||||
- [NotifyBlockAddedRequestMessage](#protowire.NotifyBlockAddedRequestMessage)
|
||||
- [NotifyBlockAddedResponseMessage](#protowire.NotifyBlockAddedResponseMessage)
|
||||
- [BlockAddedNotificationMessage](#protowire.BlockAddedNotificationMessage)
|
||||
- [GetPeerAddressesRequestMessage](#protowire.GetPeerAddressesRequestMessage)
|
||||
- [GetPeerAddressesResponseMessage](#protowire.GetPeerAddressesResponseMessage)
|
||||
- [GetPeerAddressesKnownAddressMessage](#protowire.GetPeerAddressesKnownAddressMessage)
|
||||
- [GetSelectedTipHashRequestMessage](#protowire.GetSelectedTipHashRequestMessage)
|
||||
- [GetSelectedTipHashResponseMessage](#protowire.GetSelectedTipHashResponseMessage)
|
||||
- [GetMempoolEntryRequestMessage](#protowire.GetMempoolEntryRequestMessage)
|
||||
- [GetMempoolEntryResponseMessage](#protowire.GetMempoolEntryResponseMessage)
|
||||
- [GetMempoolEntriesRequestMessage](#protowire.GetMempoolEntriesRequestMessage)
|
||||
- [GetMempoolEntriesResponseMessage](#protowire.GetMempoolEntriesResponseMessage)
|
||||
- [MempoolEntry](#protowire.MempoolEntry)
|
||||
- [GetConnectedPeerInfoRequestMessage](#protowire.GetConnectedPeerInfoRequestMessage)
|
||||
- [GetConnectedPeerInfoResponseMessage](#protowire.GetConnectedPeerInfoResponseMessage)
|
||||
- [GetConnectedPeerInfoMessage](#protowire.GetConnectedPeerInfoMessage)
|
||||
- [AddPeerRequestMessage](#protowire.AddPeerRequestMessage)
|
||||
- [RPCError](#protowire.RPCError)
|
||||
- [RpcBlock](#protowire.RpcBlock)
|
||||
- [RpcBlockHeader](#protowire.RpcBlockHeader)
|
||||
- [RpcBlockVerboseData](#protowire.RpcBlockVerboseData)
|
||||
- [RpcTransaction](#protowire.RpcTransaction)
|
||||
- [RpcTransactionInput](#protowire.RpcTransactionInput)
|
||||
- [RpcScriptPublicKey](#protowire.RpcScriptPublicKey)
|
||||
- [RpcTransactionOutput](#protowire.RpcTransactionOutput)
|
||||
- [RpcOutpoint](#protowire.RpcOutpoint)
|
||||
- [RpcUtxoEntry](#protowire.RpcUtxoEntry)
|
||||
- [RpcTransactionVerboseData](#protowire.RpcTransactionVerboseData)
|
||||
- [RpcTransactionInputVerboseData](#protowire.RpcTransactionInputVerboseData)
|
||||
- [RpcTransactionOutputVerboseData](#protowire.RpcTransactionOutputVerboseData)
|
||||
- [GetCurrentNetworkRequestMessage](#protowire.GetCurrentNetworkRequestMessage)
|
||||
- [GetCurrentNetworkResponseMessage](#protowire.GetCurrentNetworkResponseMessage)
|
||||
- [SubmitBlockRequestMessage](#protowire.SubmitBlockRequestMessage)
|
||||
- [SubmitBlockResponseMessage](#protowire.SubmitBlockResponseMessage)
|
||||
- [GetBlockTemplateRequestMessage](#protowire.GetBlockTemplateRequestMessage)
|
||||
- [GetBlockTemplateResponseMessage](#protowire.GetBlockTemplateResponseMessage)
|
||||
- [NotifyBlockAddedRequestMessage](#protowire.NotifyBlockAddedRequestMessage)
|
||||
- [NotifyBlockAddedResponseMessage](#protowire.NotifyBlockAddedResponseMessage)
|
||||
- [BlockAddedNotificationMessage](#protowire.BlockAddedNotificationMessage)
|
||||
- [GetPeerAddressesRequestMessage](#protowire.GetPeerAddressesRequestMessage)
|
||||
- [GetPeerAddressesResponseMessage](#protowire.GetPeerAddressesResponseMessage)
|
||||
- [GetPeerAddressesKnownAddressMessage](#protowire.GetPeerAddressesKnownAddressMessage)
|
||||
- [GetSelectedTipHashRequestMessage](#protowire.GetSelectedTipHashRequestMessage)
|
||||
- [GetSelectedTipHashResponseMessage](#protowire.GetSelectedTipHashResponseMessage)
|
||||
- [GetMempoolEntryRequestMessage](#protowire.GetMempoolEntryRequestMessage)
|
||||
- [GetMempoolEntryResponseMessage](#protowire.GetMempoolEntryResponseMessage)
|
||||
- [GetMempoolEntriesRequestMessage](#protowire.GetMempoolEntriesRequestMessage)
|
||||
- [GetMempoolEntriesResponseMessage](#protowire.GetMempoolEntriesResponseMessage)
|
||||
- [MempoolEntry](#protowire.MempoolEntry)
|
||||
- [GetConnectedPeerInfoRequestMessage](#protowire.GetConnectedPeerInfoRequestMessage)
|
||||
- [GetConnectedPeerInfoResponseMessage](#protowire.GetConnectedPeerInfoResponseMessage)
|
||||
- [GetConnectedPeerInfoMessage](#protowire.GetConnectedPeerInfoMessage)
|
||||
- [AddPeerRequestMessage](#protowire.AddPeerRequestMessage)
|
||||
- [AddPeerResponseMessage](#protowire.AddPeerResponseMessage)
|
||||
- [SubmitTransactionRequestMessage](#protowire.SubmitTransactionRequestMessage)
|
||||
- [SubmitTransactionResponseMessage](#protowire.SubmitTransactionResponseMessage)
|
||||
@@ -40,10 +50,6 @@
|
||||
- [AcceptedBlock](#protowire.AcceptedBlock)
|
||||
- [GetBlockRequestMessage](#protowire.GetBlockRequestMessage)
|
||||
- [GetBlockResponseMessage](#protowire.GetBlockResponseMessage)
|
||||
- [BlockVerboseData](#protowire.BlockVerboseData)
|
||||
- [TransactionVerboseData](#protowire.TransactionVerboseData)
|
||||
- [TransactionVerboseInput](#protowire.TransactionVerboseInput)
|
||||
- [TransactionVerboseOutput](#protowire.TransactionVerboseOutput)
|
||||
- [GetSubnetworkRequestMessage](#protowire.GetSubnetworkRequestMessage)
|
||||
- [GetSubnetworkResponseMessage](#protowire.GetSubnetworkResponseMessage)
|
||||
- [GetVirtualSelectedParentChainFromBlockRequestMessage](#protowire.GetVirtualSelectedParentChainFromBlockRequestMessage)
|
||||
@@ -70,12 +76,6 @@
|
||||
- [UtxosByAddressesEntry](#protowire.UtxosByAddressesEntry)
|
||||
- [StopNotifyingUtxosChangedRequestMessage](#protowire.StopNotifyingUtxosChangedRequestMessage)
|
||||
- [StopNotifyingUtxosChangedResponseMessage](#protowire.StopNotifyingUtxosChangedResponseMessage)
|
||||
- [RpcTransaction](#protowire.RpcTransaction)
|
||||
- [RpcTransactionInput](#protowire.RpcTransactionInput)
|
||||
- [RpcScriptPublicKey](#protowire.RpcScriptPublicKey)
|
||||
- [RpcTransactionOutput](#protowire.RpcTransactionOutput)
|
||||
- [RpcOutpoint](#protowire.RpcOutpoint)
|
||||
- [RpcUtxoEntry](#protowire.RpcUtxoEntry)
|
||||
- [GetUtxosByAddressesRequestMessage](#protowire.GetUtxosByAddressesRequestMessage)
|
||||
- [GetUtxosByAddressesResponseMessage](#protowire.GetUtxosByAddressesResponseMessage)
|
||||
- [GetVirtualSelectedParentBlueScoreRequestMessage](#protowire.GetVirtualSelectedParentBlueScoreRequestMessage)
|
||||
@@ -83,6 +83,9 @@
|
||||
- [NotifyVirtualSelectedParentBlueScoreChangedRequestMessage](#protowire.NotifyVirtualSelectedParentBlueScoreChangedRequestMessage)
|
||||
- [NotifyVirtualSelectedParentBlueScoreChangedResponseMessage](#protowire.NotifyVirtualSelectedParentBlueScoreChangedResponseMessage)
|
||||
- [VirtualSelectedParentBlueScoreChangedNotificationMessage](#protowire.VirtualSelectedParentBlueScoreChangedNotificationMessage)
|
||||
- [NotifyVirtualDaaScoreChangedRequestMessage](#protowire.NotifyVirtualDaaScoreChangedRequestMessage)
|
||||
- [NotifyVirtualDaaScoreChangedResponseMessage](#protowire.NotifyVirtualDaaScoreChangedResponseMessage)
|
||||
- [VirtualDaaScoreChangedNotificationMessage](#protowire.VirtualDaaScoreChangedNotificationMessage)
|
||||
- [NotifyPruningPointUTXOSetOverrideRequestMessage](#protowire.NotifyPruningPointUTXOSetOverrideRequestMessage)
|
||||
- [NotifyPruningPointUTXOSetOverrideResponseMessage](#protowire.NotifyPruningPointUTXOSetOverrideResponseMessage)
|
||||
- [PruningPointUTXOSetOverrideNotificationMessage](#protowire.PruningPointUTXOSetOverrideNotificationMessage)
|
||||
@@ -132,6 +135,218 @@ Receivers of any ResponseMessage are expected to check whether its error field i
|
||||
|
||||
|
||||
|
||||
<a name="protowire.RpcBlock"></a>
|
||||
|
||||
### RpcBlock
|
||||
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| header | [RpcBlockHeader](#protowire.RpcBlockHeader) | | |
|
||||
| transactions | [RpcTransaction](#protowire.RpcTransaction) | repeated | |
|
||||
| verboseData | [RpcBlockVerboseData](#protowire.RpcBlockVerboseData) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="protowire.RpcBlockHeader"></a>
|
||||
|
||||
### RpcBlockHeader
|
||||
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| version | [uint32](#uint32) | | |
|
||||
| parentHashes | [string](#string) | repeated | |
|
||||
| hashMerkleRoot | [string](#string) | | |
|
||||
| acceptedIdMerkleRoot | [string](#string) | | |
|
||||
| utxoCommitment | [string](#string) | | |
|
||||
| timestamp | [int64](#int64) | | |
|
||||
| bits | [uint32](#uint32) | | |
|
||||
| nonce | [uint64](#uint64) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="protowire.RpcBlockVerboseData"></a>
|
||||
|
||||
### RpcBlockVerboseData
|
||||
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| hash | [string](#string) | | |
|
||||
| difficulty | [double](#double) | | |
|
||||
| selectedParentHash | [string](#string) | | |
|
||||
| transactionIds | [string](#string) | repeated | |
|
||||
| isHeaderOnly | [bool](#bool) | | |
|
||||
| blueScore | [uint64](#uint64) | | |
|
||||
| childrenHashes | [string](#string) | repeated | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="protowire.RpcTransaction"></a>
|
||||
|
||||
### RpcTransaction
|
||||
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| version | [uint32](#uint32) | | |
|
||||
| inputs | [RpcTransactionInput](#protowire.RpcTransactionInput) | repeated | |
|
||||
| outputs | [RpcTransactionOutput](#protowire.RpcTransactionOutput) | repeated | |
|
||||
| lockTime | [uint64](#uint64) | | |
|
||||
| subnetworkId | [string](#string) | | |
|
||||
| gas | [uint64](#uint64) | | |
|
||||
| payload | [string](#string) | | |
|
||||
| verboseData | [RpcTransactionVerboseData](#protowire.RpcTransactionVerboseData) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="protowire.RpcTransactionInput"></a>
|
||||
|
||||
### RpcTransactionInput
|
||||
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| previousOutpoint | [RpcOutpoint](#protowire.RpcOutpoint) | | |
|
||||
| signatureScript | [string](#string) | | |
|
||||
| sequence | [uint64](#uint64) | | |
|
||||
| verboseData | [RpcTransactionInputVerboseData](#protowire.RpcTransactionInputVerboseData) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="protowire.RpcScriptPublicKey"></a>
|
||||
|
||||
### RpcScriptPublicKey
|
||||
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| version | [uint32](#uint32) | | |
|
||||
| scriptPublicKey | [string](#string) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="protowire.RpcTransactionOutput"></a>
|
||||
|
||||
### RpcTransactionOutput
|
||||
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| amount | [uint64](#uint64) | | |
|
||||
| scriptPublicKey | [RpcScriptPublicKey](#protowire.RpcScriptPublicKey) | | |
|
||||
| verboseData | [RpcTransactionOutputVerboseData](#protowire.RpcTransactionOutputVerboseData) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="protowire.RpcOutpoint"></a>
|
||||
|
||||
### RpcOutpoint
|
||||
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| transactionId | [string](#string) | | |
|
||||
| index | [uint32](#uint32) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="protowire.RpcUtxoEntry"></a>
|
||||
|
||||
### RpcUtxoEntry
|
||||
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| amount | [uint64](#uint64) | | |
|
||||
| scriptPublicKey | [RpcScriptPublicKey](#protowire.RpcScriptPublicKey) | | |
|
||||
| blockDaaScore | [uint64](#uint64) | | |
|
||||
| isCoinbase | [bool](#bool) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="protowire.RpcTransactionVerboseData"></a>
|
||||
|
||||
### RpcTransactionVerboseData
|
||||
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| transactionId | [string](#string) | | |
|
||||
| hash | [string](#string) | | |
|
||||
| size | [uint64](#uint64) | | |
|
||||
| blockHash | [string](#string) | | |
|
||||
| blockTime | [uint64](#uint64) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="protowire.RpcTransactionInputVerboseData"></a>
|
||||
|
||||
### RpcTransactionInputVerboseData
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="protowire.RpcTransactionOutputVerboseData"></a>
|
||||
|
||||
### RpcTransactionOutputVerboseData
|
||||
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| scriptPublicKeyType | [string](#string) | | |
|
||||
| scriptPublicKeyAddress | [string](#string) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="protowire.GetCurrentNetworkRequestMessage"></a>
|
||||
|
||||
### GetCurrentNetworkRequestMessage
|
||||
@@ -163,44 +378,27 @@ Possible networks are: Mainnet, Testnet, Simnet, Devnet
|
||||
<a name="protowire.SubmitBlockRequestMessage"></a>
|
||||
|
||||
### SubmitBlockRequestMessage
|
||||
|
||||
SubmitBlockRequestMessage requests to submit a block into the DAG. Blocks are generally expected to have been generated
|
||||
using the getBlockTemplate call.
|
||||
SubmitBlockRequestMessage requests to submit a block into the DAG.
|
||||
Blocks are generally expected to have been generated using the getBlockTemplate call.
|
||||
|
||||
See: GetBlockTemplateRequestMessage
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| block | [RpcBlock](#protowire.RpcBlock) | | |
|
||||
|
||||
<a name="protowire.RpcBlock"></a>
|
||||
|
||||
### RpcBlock
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| header | [RpcBlockHeader](#protowire.RpcBlockHeader) | | |
|
||||
| transactions | [RpcTransaction](#protowire.RpcTransaction) | repeated | |
|
||||
|
||||
<a name="protowire.RpcBlockHeader"></a>
|
||||
|
||||
### RpcBlockHeader
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| version | [uint32](#uint32) | | |
|
||||
| parentHashes | [string](#string) | repeated | |
|
||||
| hashMerkleRoot | [string](#string) | | |
|
||||
| acceptedIdMerkleRoot | [string](#string) | | |
|
||||
| utxoCommitment | [string](#string) | | |
|
||||
| timestamp | [int64](#int64) | | |
|
||||
| bits | [uint32](#uint32) | | |
|
||||
| nonce | [uint64](#uint64) | | |
|
||||
|
||||
<a name="protowire.SubmitBlockResponseMessage"></a>
|
||||
|
||||
### SubmitBlockResponseMessage
|
||||
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| rejectReason | [SubmitBlockResponseMessage.RejectReason](#protowire.SubmitBlockResponseMessage.RejectReason) | | |
|
||||
@@ -284,7 +482,7 @@ See: NotifyBlockAddedRequestMessage
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| blockVerboseData | [BlockVerboseData](#protowire.BlockVerboseData) | | |
|
||||
| block | [RpcBlock](#protowire.RpcBlock) | | |
|
||||
|
||||
|
||||
|
||||
@@ -429,7 +627,7 @@ currently in the mempool.
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| fee | [uint64](#uint64) | | |
|
||||
| transactionVerboseData | [TransactionVerboseData](#protowire.TransactionVerboseData) | | |
|
||||
| transaction | [RpcTransaction](#protowire.RpcTransaction) | | |
|
||||
|
||||
|
||||
|
||||
@@ -651,78 +849,8 @@ GetBlockRequestMessage requests information about a specific block
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| blockHash | [string](#string) | | |
|
||||
| blockVerboseData | [BlockVerboseData](#protowire.BlockVerboseData) | | |
|
||||
| error | [RPCError](#protowire.RPCError) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="protowire.BlockVerboseData"></a>
|
||||
|
||||
### BlockVerboseData
|
||||
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| hash | [string](#string) | | |
|
||||
| block | [RpcBlock](#protowire.RpcBlock) | | |
|
||||
| transactionVerboseData | [TransactionVerboseData](#protowire.TransactionVerboseData) | repeated | |
|
||||
| difficulty | [double](#double) | | |
|
||||
| childrenHashes | [string](#string) | repeated | |
|
||||
| selectedParentHash | [string](#string) | | |
|
||||
| transactionIDs | [string](#string) | repeated | |
|
||||
| isHeaderOnly | [bool](#bool) | | |
|
||||
| blueScore | [uint64](#uint64) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="protowire.TransactionVerboseData"></a>
|
||||
|
||||
### TransactionVerboseData
|
||||
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| txId | [string](#string) | | |
|
||||
| hash | [string](#string) | | |
|
||||
| size | [uint64](#uint64) | | |
|
||||
| transactionVerboseInputs | [TransactionVerboseInput](#protowire.TransactionVerboseInput) | repeated | |
|
||||
| transactionVerboseOutputs | [TransactionVerboseOutput](#protowire.TransactionVerboseOutput) | repeated | |
|
||||
| blockHash | [string](#string) | | |
|
||||
| blockTime | [uint64](#uint64) | | |
|
||||
| transaction | [RpcTransaction](#protowire.RpcTransaction) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="protowire.TransactionVerboseInput"></a>
|
||||
|
||||
### TransactionVerboseInput
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="protowire.TransactionVerboseOutput"></a>
|
||||
|
||||
### TransactionVerboseOutput
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| scriptPublicKeyType | [string](#string) | | |
|
||||
| scriptPublicKeyAddress | [string](#string) | | |
|
||||
| error | [RPCError](#protowire.RPCError) | | |
|
||||
|
||||
|
||||
|
||||
@@ -805,7 +933,7 @@ kaspad's current virtual.
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| lowHash | [string](#string) | | |
|
||||
| includeBlockVerboseData | [bool](#bool) | | |
|
||||
| includeBlocks | [bool](#bool) | | |
|
||||
| includeTransactionVerboseData | [bool](#bool) | | |
|
||||
|
||||
|
||||
@@ -822,7 +950,7 @@ kaspad's current virtual.
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| blockHashes | [string](#string) | repeated | |
|
||||
| blockVerboseData | [BlockVerboseData](#protowire.BlockVerboseData) | repeated | |
|
||||
| blocks | [RpcBlock](#protowire.RpcBlock) | repeated | |
|
||||
| error | [RPCError](#protowire.RPCError) | | |
|
||||
|
||||
|
||||
@@ -885,6 +1013,7 @@ of this kaspad's DAG.
|
||||
| pastMedianTime | [int64](#int64) | | |
|
||||
| virtualParentHashes | [string](#string) | repeated | |
|
||||
| pruningPointHash | [string](#string) | | |
|
||||
| virtualDaaScore | [uint64](#uint64) | | |
|
||||
| error | [RPCError](#protowire.RPCError) | | |
|
||||
|
||||
|
||||
@@ -1141,110 +1270,6 @@ See: UtxosChangedNotificationMessage
|
||||
|
||||
|
||||
|
||||
<a name="protowire.RpcTransaction"></a>
|
||||
|
||||
### RpcTransaction
|
||||
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| version | [uint32](#uint32) | | |
|
||||
| inputs | [RpcTransactionInput](#protowire.RpcTransactionInput) | repeated | |
|
||||
| outputs | [RpcTransactionOutput](#protowire.RpcTransactionOutput) | repeated | |
|
||||
| lockTime | [uint64](#uint64) | | |
|
||||
| subnetworkId | [string](#string) | | |
|
||||
| gas | [uint64](#uint64) | | |
|
||||
| payload | [string](#string) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="protowire.RpcTransactionInput"></a>
|
||||
|
||||
### RpcTransactionInput
|
||||
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| previousOutpoint | [RpcOutpoint](#protowire.RpcOutpoint) | | |
|
||||
| signatureScript | [string](#string) | | |
|
||||
| sequence | [uint64](#uint64) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="protowire.RpcScriptPublicKey"></a>
|
||||
|
||||
### RpcScriptPublicKey
|
||||
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| version | [uint32](#uint32) | | |
|
||||
| scriptPublicKey | [string](#string) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="protowire.RpcTransactionOutput"></a>
|
||||
|
||||
### RpcTransactionOutput
|
||||
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| amount | [uint64](#uint64) | | |
|
||||
| scriptPublicKey | [RpcScriptPublicKey](#protowire.RpcScriptPublicKey) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="protowire.RpcOutpoint"></a>
|
||||
|
||||
### RpcOutpoint
|
||||
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| transactionId | [string](#string) | | |
|
||||
| index | [uint32](#uint32) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="protowire.RpcUtxoEntry"></a>
|
||||
|
||||
### RpcUtxoEntry
|
||||
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| amount | [uint64](#uint64) | | |
|
||||
| scriptPublicKey | [RpcScriptPublicKey](#protowire.RpcScriptPublicKey) | | |
|
||||
| blockDaaScore | [uint64](#uint64) | | |
|
||||
| isCoinbase | [bool](#bool) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="protowire.GetUtxosByAddressesRequestMessage"></a>
|
||||
|
||||
### GetUtxosByAddressesRequestMessage
|
||||
@@ -1351,6 +1376,52 @@ See NotifyVirtualSelectedParentBlueScoreChangedRequestMessage
|
||||
|
||||
|
||||
|
||||
<a name="protowire.NotifyVirtualDaaScoreChangedRequestMessage"></a>
|
||||
|
||||
### NotifyVirtualDaaScoreChangedRequestMessage
|
||||
NotifyVirtualDaaScoreChangedRequestMessage registers this connection for
|
||||
virtualDaaScoreChanged notifications.
|
||||
|
||||
See: VirtualDaaScoreChangedNotificationMessage
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="protowire.NotifyVirtualDaaScoreChangedResponseMessage"></a>
|
||||
|
||||
### NotifyVirtualDaaScoreChangedResponseMessage
|
||||
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| error | [RPCError](#protowire.RPCError) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="protowire.VirtualDaaScoreChangedNotificationMessage"></a>
|
||||
|
||||
### VirtualDaaScoreChangedNotificationMessage
|
||||
VirtualDaaScoreChangedNotificationMessage is sent whenever the DAA score
|
||||
of the virtual changes.
|
||||
|
||||
See NotifyVirtualDaaScoreChangedRequestMessage
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| virtualDaaScore | [uint64](#uint64) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="protowire.NotifyPruningPointUTXOSetOverrideRequestMessage"></a>
|
||||
|
||||
### NotifyPruningPointUTXOSetOverrideRequestMessage
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -395,6 +395,7 @@ message GetBlockDagInfoResponseMessage{
|
||||
int64 pastMedianTime = 6;
|
||||
repeated string virtualParentHashes = 7;
|
||||
string pruningPointHash = 8;
|
||||
uint64 virtualDaaScore = 9;
|
||||
RPCError error = 1000;
|
||||
}
|
||||
|
||||
@@ -527,6 +528,25 @@ message VirtualSelectedParentBlueScoreChangedNotificationMessage {
|
||||
uint64 virtualSelectedParentBlueScore = 1;
|
||||
}
|
||||
|
||||
// NotifyVirtualDaaScoreChangedRequestMessage registers this connection for
|
||||
// virtualDaaScoreChanged notifications.
|
||||
//
|
||||
// See: VirtualDaaScoreChangedNotificationMessage
|
||||
message NotifyVirtualDaaScoreChangedRequestMessage {
|
||||
}
|
||||
|
||||
message NotifyVirtualDaaScoreChangedResponseMessage {
|
||||
RPCError error = 1000;
|
||||
}
|
||||
|
||||
// VirtualDaaScoreChangedNotificationMessage is sent whenever the DAA score
|
||||
// of the virtual changes.
|
||||
//
|
||||
// See NotifyVirtualDaaScoreChangedRequestMessage
|
||||
message VirtualDaaScoreChangedNotificationMessage {
|
||||
uint64 virtualDaaScore = 1;
|
||||
}
|
||||
|
||||
// NotifyPruningPointUTXOSetOverrideRequestMessage registers this connection for
|
||||
// pruning point UTXO set override notifications.
|
||||
//
|
||||
|
||||
@@ -45,6 +45,7 @@ func (x *GetBlockDagInfoResponseMessage) toAppMessage() (appmessage.Message, err
|
||||
Difficulty: x.Difficulty,
|
||||
PastMedianTime: x.PastMedianTime,
|
||||
PruningPointHash: x.PruningPointHash,
|
||||
VirtualDAAScore: x.VirtualDaaScore,
|
||||
Error: rpcErr,
|
||||
}, nil
|
||||
}
|
||||
@@ -63,6 +64,7 @@ func (x *KaspadMessage_GetBlockDagInfoResponse) fromAppMessage(message *appmessa
|
||||
Difficulty: message.Difficulty,
|
||||
PastMedianTime: message.PastMedianTime,
|
||||
PruningPointHash: message.PruningPointHash,
|
||||
VirtualDaaScore: message.VirtualDAAScore,
|
||||
Error: err,
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
package protowire
|
||||
|
||||
import (
|
||||
"github.com/kaspanet/kaspad/app/appmessage"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func (x *KaspadMessage_NotifyVirtualDaaScoreChangedRequest) toAppMessage() (appmessage.Message, error) {
|
||||
if x == nil {
|
||||
return nil, errors.Wrapf(errorNil, "KaspadMessage_NotifyVirtualDaaScoreChangedRequest is nil")
|
||||
}
|
||||
return &appmessage.NotifyVirtualDaaScoreChangedRequestMessage{}, nil
|
||||
}
|
||||
|
||||
func (x *KaspadMessage_NotifyVirtualDaaScoreChangedRequest) fromAppMessage(_ *appmessage.NotifyVirtualDaaScoreChangedRequestMessage) error {
|
||||
x.NotifyVirtualDaaScoreChangedRequest = &NotifyVirtualDaaScoreChangedRequestMessage{}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *KaspadMessage_NotifyVirtualDaaScoreChangedResponse) toAppMessage() (appmessage.Message, error) {
|
||||
if x == nil {
|
||||
return nil, errors.Wrapf(errorNil, "KaspadMessage_NotifyVirtualDaaScoreChangedResponse is nil")
|
||||
}
|
||||
return x.NotifyVirtualDaaScoreChangedResponse.toAppMessage()
|
||||
}
|
||||
|
||||
func (x *KaspadMessage_NotifyVirtualDaaScoreChangedResponse) fromAppMessage(message *appmessage.NotifyVirtualDaaScoreChangedResponseMessage) error {
|
||||
var err *RPCError
|
||||
if message.Error != nil {
|
||||
err = &RPCError{Message: message.Error.Message}
|
||||
}
|
||||
x.NotifyVirtualDaaScoreChangedResponse = &NotifyVirtualDaaScoreChangedResponseMessage{
|
||||
Error: err,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *NotifyVirtualDaaScoreChangedResponseMessage) toAppMessage() (appmessage.Message, error) {
|
||||
if x == nil {
|
||||
return nil, errors.Wrapf(errorNil, "NotifyVirtualDaaScoreChangedResponseMessage is nil")
|
||||
}
|
||||
rpcErr, err := x.Error.toAppMessage()
|
||||
// Error is an optional field
|
||||
if err != nil && !errors.Is(err, errorNil) {
|
||||
return nil, err
|
||||
}
|
||||
return &appmessage.NotifyVirtualDaaScoreChangedResponseMessage{
|
||||
Error: rpcErr,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (x *KaspadMessage_VirtualDaaScoreChangedNotification) toAppMessage() (appmessage.Message, error) {
|
||||
if x == nil {
|
||||
return nil, errors.Wrapf(errorNil, "KaspadMessage_VirtualDaaScoreChangedNotification is nil")
|
||||
}
|
||||
return x.VirtualDaaScoreChangedNotification.toAppMessage()
|
||||
}
|
||||
|
||||
func (x *KaspadMessage_VirtualDaaScoreChangedNotification) fromAppMessage(message *appmessage.VirtualDaaScoreChangedNotificationMessage) error {
|
||||
x.VirtualDaaScoreChangedNotification = &VirtualDaaScoreChangedNotificationMessage{
|
||||
VirtualDaaScore: message.VirtualDaaScore,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *VirtualDaaScoreChangedNotificationMessage) toAppMessage() (appmessage.Message, error) {
|
||||
if x == nil {
|
||||
return nil, errors.Wrapf(errorNil, "VirtualDaaScoreChangedNotificationMessage is nil")
|
||||
}
|
||||
return &appmessage.VirtualDaaScoreChangedNotificationMessage{
|
||||
VirtualDaaScore: x.VirtualDaaScore,
|
||||
}, nil
|
||||
}
|
||||
@@ -779,6 +779,27 @@ func toRPCPayload(message appmessage.Message) (isKaspadMessage_Payload, error) {
|
||||
return nil, err
|
||||
}
|
||||
return payload, nil
|
||||
case *appmessage.NotifyVirtualDaaScoreChangedRequestMessage:
|
||||
payload := new(KaspadMessage_NotifyVirtualDaaScoreChangedRequest)
|
||||
err := payload.fromAppMessage(message)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return payload, nil
|
||||
case *appmessage.NotifyVirtualDaaScoreChangedResponseMessage:
|
||||
payload := new(KaspadMessage_NotifyVirtualDaaScoreChangedResponse)
|
||||
err := payload.fromAppMessage(message)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return payload, nil
|
||||
case *appmessage.VirtualDaaScoreChangedNotificationMessage:
|
||||
payload := new(KaspadMessage_VirtualDaaScoreChangedNotification)
|
||||
err := payload.fromAppMessage(message)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return payload, nil
|
||||
default:
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package rpcclient
|
||||
|
||||
import (
|
||||
"github.com/kaspanet/kaspad/app/appmessage"
|
||||
routerpkg "github.com/kaspanet/kaspad/infrastructure/network/netadapter/router"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// RegisterForVirtualDaaScoreChangedNotifications sends an RPC request respective to the function's
|
||||
// name and returns the RPC server's response. Additionally, it starts listening for the appropriate notification
|
||||
// using the given handler function
|
||||
func (c *RPCClient) RegisterForVirtualDaaScoreChangedNotifications(
|
||||
onVirtualDaaScoreChanged func(notification *appmessage.VirtualDaaScoreChangedNotificationMessage)) error {
|
||||
|
||||
err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewNotifyVirtualDaaScoreChangedRequestMessage())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
response, err := c.route(appmessage.CmdNotifyVirtualDaaScoreChangedResponseMessage).DequeueWithTimeout(c.timeout)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
notifyVirtualDaaScoreChangedResponse := response.(*appmessage.NotifyVirtualDaaScoreChangedResponseMessage)
|
||||
if notifyVirtualDaaScoreChangedResponse.Error != nil {
|
||||
return c.convertRPCError(notifyVirtualDaaScoreChangedResponse.Error)
|
||||
}
|
||||
spawn("RegisterForVirtualDaaScoreChangedNotifications", func() {
|
||||
for {
|
||||
notification, err := c.route(appmessage.CmdVirtualDaaScoreChangedNotificationMessage).Dequeue()
|
||||
if err != nil {
|
||||
if errors.Is(err, routerpkg.ErrRouteClosed) {
|
||||
break
|
||||
}
|
||||
panic(err)
|
||||
}
|
||||
VirtualDaaScoreChangedNotification := notification.(*appmessage.VirtualDaaScoreChangedNotificationMessage)
|
||||
onVirtualDaaScoreChanged(VirtualDaaScoreChangedNotification)
|
||||
}
|
||||
})
|
||||
return nil
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestVirtualSelectedParentBlueScore(t *testing.T) {
|
||||
func TestVirtualSelectedParentBlueScoreAndVirtualDAAScore(t *testing.T) {
|
||||
// Setup a single kaspad instance
|
||||
harnessParams := &harnessParams{
|
||||
p2pAddress: p2pAddress1,
|
||||
@@ -38,15 +38,30 @@ func TestVirtualSelectedParentBlueScore(t *testing.T) {
|
||||
"blue score change notifications: %s", err)
|
||||
}
|
||||
|
||||
// Register to virtual DAA score changes
|
||||
onVirtualDaaScoreChangedChan := make(chan *appmessage.VirtualDaaScoreChangedNotificationMessage)
|
||||
err = kaspad.rpcClient.RegisterForVirtualDaaScoreChangedNotifications(
|
||||
func(notification *appmessage.VirtualDaaScoreChangedNotificationMessage) {
|
||||
onVirtualDaaScoreChangedChan <- notification
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to register for virtual DAA score change notifications: %s", err)
|
||||
}
|
||||
|
||||
// Mine some blocks and make sure that the notifications
|
||||
// report correct blue score values
|
||||
// report correct values
|
||||
const blockAmountToMine = 100
|
||||
for i := 0; i < blockAmountToMine; i++ {
|
||||
mineNextBlock(t, kaspad)
|
||||
notification := <-onVirtualSelectedParentBlueScoreChangedChan
|
||||
if notification.VirtualSelectedParentBlueScore != 1+uint64(i) {
|
||||
blueScoreChangedNotification := <-onVirtualSelectedParentBlueScoreChangedChan
|
||||
if blueScoreChangedNotification.VirtualSelectedParentBlueScore != 1+uint64(i) {
|
||||
t.Fatalf("Unexpected virtual selected parent blue score. Want: %d, got: %d",
|
||||
1+uint64(i), notification.VirtualSelectedParentBlueScore)
|
||||
1+uint64(i), blueScoreChangedNotification.VirtualSelectedParentBlueScore)
|
||||
}
|
||||
daaScoreChangedNotification := <-onVirtualDaaScoreChangedChan
|
||||
if daaScoreChangedNotification.VirtualDaaScore > 1+uint64(i) {
|
||||
t.Fatalf("Unexpected virtual DAA score. Want: %d, got: %d",
|
||||
1+uint64(i), daaScoreChangedNotification.VirtualDaaScore)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ const validCharacters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrs
|
||||
const (
|
||||
appMajor uint = 0
|
||||
appMinor uint = 10
|
||||
appPatch uint = 0
|
||||
appPatch uint = 4
|
||||
)
|
||||
|
||||
// appBuild is defined as a variable so it can be overridden during the build
|
||||
|
||||
Reference in New Issue
Block a user