Add an RPC command: EstimateNetworkHashesPerSecond (#1686)

* Implement EstimateNetworkHashesPerSecond.

* Fix failing tests.

* Add request/response messages to the .proto files.

* Add the EstimateNetworkHashesPerSecond RPC command.

* Add the EstimateNetworkHashesPerSecond RPC client function.

* Add the EstimateNetworkHashesPerSecond RPC command to kaspactl.

* Disallow windowSize lesser than 2.

* Fix wrong scale (milliseconds instead of seconds).

* Handle windowHashes being 0.
This commit is contained in:
stasatdaglabs 2021-04-22 15:18:21 +03:00 committed by GitHub
parent 13a6b4cc51
commit 1f56a68a28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 689 additions and 301 deletions

View File

@ -137,6 +137,8 @@ const (
CmdPruningPointUTXOSetOverrideNotificationMessage
CmdStopNotifyingPruningPointUTXOSetOverrideRequestMessage
CmdStopNotifyingPruningPointUTXOSetOverrideResponseMessage
CmdEstimateNetworkHashesPerSecondRequestMessage
CmdEstimateNetworkHashesPerSecondResponseMessage
)
// ProtocolMessageCommandToString maps all MessageCommands to their string representation
@ -248,6 +250,8 @@ var RPCMessageCommandToString = map[MessageCommand]string{
CmdPruningPointUTXOSetOverrideNotificationMessage: "PruningPointUTXOSetOverrideNotification",
CmdStopNotifyingPruningPointUTXOSetOverrideRequestMessage: "StopNotifyingPruningPointUTXOSetOverrideRequest",
CmdStopNotifyingPruningPointUTXOSetOverrideResponseMessage: "StopNotifyingPruningPointUTXOSetOverrideResponse",
CmdEstimateNetworkHashesPerSecondRequestMessage: "EstimateNetworkHashesPerSecondRequest",
CmdEstimateNetworkHashesPerSecondResponseMessage: "EstimateNetworkHashesPerSecondResponse",
}
// Message is an interface that describes a kaspa message. A type that

View File

@ -0,0 +1,41 @@
package appmessage
// EstimateNetworkHashesPerSecondRequestMessage is an appmessage corresponding to
// its respective RPC message
type EstimateNetworkHashesPerSecondRequestMessage struct {
baseMessage
WindowSize uint32
}
// Command returns the protocol command string for the message
func (msg *EstimateNetworkHashesPerSecondRequestMessage) Command() MessageCommand {
return CmdEstimateNetworkHashesPerSecondRequestMessage
}
// NewEstimateNetworkHashesPerSecondRequestMessage returns a instance of the message
func NewEstimateNetworkHashesPerSecondRequestMessage(windowSize uint32) *EstimateNetworkHashesPerSecondRequestMessage {
return &EstimateNetworkHashesPerSecondRequestMessage{
WindowSize: windowSize,
}
}
// EstimateNetworkHashesPerSecondResponseMessage is an appmessage corresponding to
// its respective RPC message
type EstimateNetworkHashesPerSecondResponseMessage struct {
baseMessage
NetworkHashesPerSecond uint64
Error *RPCError
}
// Command returns the protocol command string for the message
func (msg *EstimateNetworkHashesPerSecondResponseMessage) Command() MessageCommand {
return CmdEstimateNetworkHashesPerSecondResponseMessage
}
// NewEstimateNetworkHashesPerSecondResponseMessage returns a instance of the message
func NewEstimateNetworkHashesPerSecondResponseMessage(networkHashesPerSecond uint64) *EstimateNetworkHashesPerSecondResponseMessage {
return &EstimateNetworkHashesPerSecondResponseMessage{
NetworkHashesPerSecond: networkHashesPerSecond,
}
}

View File

@ -130,6 +130,10 @@ type fakeRelayInvsContext struct {
rwLock sync.RWMutex
}
func (f *fakeRelayInvsContext) EstimateNetworkHashesPerSecond(windowSize int) (uint64, error) {
panic(errors.Errorf("called unimplemented function from test '%s'", f.testName))
}
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))
}

View File

@ -44,6 +44,7 @@ var handlers = map[appmessage.MessageCommand]handler{
appmessage.CmdGetInfoRequestMessage: rpchandlers.HandleGetInfo,
appmessage.CmdNotifyPruningPointUTXOSetOverrideRequestMessage: rpchandlers.HandleNotifyPruningPointUTXOSetOverrideRequest,
appmessage.CmdStopNotifyingPruningPointUTXOSetOverrideRequestMessage: rpchandlers.HandleStopNotifyingPruningPointUTXOSetOverrideRequest,
appmessage.CmdEstimateNetworkHashesPerSecondRequestMessage: rpchandlers.HandleEstimateNetworkHashesPerSecond,
}
func (m *Manager) routerInitializer(router *router.Router, netConnection *netadapter.NetConnection) {

View File

@ -0,0 +1,23 @@
package rpchandlers
import (
"github.com/kaspanet/kaspad/app/appmessage"
"github.com/kaspanet/kaspad/app/rpc/rpccontext"
"github.com/kaspanet/kaspad/infrastructure/network/netadapter/router"
)
// HandleEstimateNetworkHashesPerSecond handles the respectively named RPC command
func HandleEstimateNetworkHashesPerSecond(context *rpccontext.Context, _ *router.Router, request appmessage.Message) (appmessage.Message, error) {
estimateNetworkHashesPerSecondRequest := request.(*appmessage.EstimateNetworkHashesPerSecondRequestMessage)
windowSize := int(estimateNetworkHashesPerSecondRequest.WindowSize)
networkHashesPerSecond, err := context.Domain.Consensus().EstimateNetworkHashesPerSecond(windowSize)
if err != nil {
response := &appmessage.EstimateNetworkHashesPerSecondResponseMessage{}
response.Error = appmessage.RPCErrorf("could not resolve network hashes per "+
"second for window size %d: %s", windowSize, err)
return response, nil
}
return appmessage.NewEstimateNetworkHashesPerSecondResponseMessage(networkHashesPerSecond), nil
}

View File

@ -24,6 +24,7 @@ var commandTypes = []reflect.Type{
reflect.TypeOf(protowire.KaspadMessage_GetVirtualSelectedParentBlueScoreRequest{}),
reflect.TypeOf(protowire.KaspadMessage_GetVirtualSelectedParentChainFromBlockRequest{}),
reflect.TypeOf(protowire.KaspadMessage_ResolveFinalityConflictRequest{}),
reflect.TypeOf(protowire.KaspadMessage_EstimateNetworkHashesPerSecondRequest{}),
reflect.TypeOf(protowire.KaspadMessage_GetBlockTemplateRequest{}),
reflect.TypeOf(protowire.KaspadMessage_SubmitBlockRequest{}),

View File

@ -505,3 +505,10 @@ func (s *consensus) Anticone(blockHash *externalapi.DomainHash) ([]*externalapi.
return s.dagTraversalManager.Anticone(stagingArea, blockHash)
}
func (s *consensus) EstimateNetworkHashesPerSecond(windowSize int) (uint64, error) {
s.lock.Lock()
defer s.lock.Unlock()
return s.difficultyManager.EstimateNetworkHashesPerSecond(windowSize)
}

View File

@ -32,4 +32,5 @@ type Consensus interface {
IsInSelectedParentChainOf(blockHashA *DomainHash, blockHashB *DomainHash) (bool, error)
GetHeadersSelectedTip() (*DomainHash, error)
Anticone(blockHash *DomainHash) ([]*DomainHash, error)
EstimateNetworkHashesPerSecond(windowSize int) (uint64, error)
}

View File

@ -1,10 +1,13 @@
package model
import "github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
import (
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
)
// DifficultyManager provides a method to resolve the
// difficulty value of a block
type DifficultyManager interface {
StageDAADataAndReturnRequiredDifficulty(stagingArea *StagingArea, blockHash *externalapi.DomainHash) (uint32, error)
RequiredDifficulty(stagingArea *StagingArea, blockHash *externalapi.DomainHash) (uint32, error)
EstimateNetworkHashesPerSecond(windowSize int) (uint64, error)
}

View File

@ -312,3 +312,7 @@ func (dm *mocDifficultyManager) StageDAADataAndReturnRequiredDifficulty(stagingA
return dm.testDifficulty, nil
}
func (dm *mocDifficultyManager) EstimateNetworkHashesPerSecond(windowSize int) (uint64, error) {
return 0, nil
}

View File

@ -31,7 +31,7 @@ func (dm *difficultyManager) getDifficultyBlock(
}
// blockWindow returns a blockWindow of the given size that contains the
// blocks in the past of startindNode, the sorting is unspecified.
// blocks in the past of startingNode, the sorting is unspecified.
// If the number of blocks in the past of startingNode is less then windowSize,
// the window will be padded by genesis blocks to achieve a size of windowSize.
func (dm *difficultyManager) blockWindow(stagingArea *model.StagingArea, startingNode *externalapi.DomainHash, windowSize int) (blockWindow,

View File

@ -0,0 +1,64 @@
package difficultymanager
import (
"github.com/kaspanet/kaspad/domain/consensus/model"
"github.com/kaspanet/kaspad/infrastructure/logger"
"github.com/pkg/errors"
"math/big"
)
func (dm *difficultyManager) EstimateNetworkHashesPerSecond(windowSize int) (uint64, error) {
onEnd := logger.LogAndMeasureExecutionTime(log, "EstimateNetworkHashesPerSecond")
defer onEnd()
stagingArea := model.NewStagingArea()
return dm.estimateNetworkHashesPerSecond(stagingArea, windowSize)
}
func (dm *difficultyManager) estimateNetworkHashesPerSecond(stagingArea *model.StagingArea, windowSize int) (uint64, error) {
if windowSize < 2 {
return 0, errors.Errorf("windowSize must be equal to or greater than 2")
}
blockWindow, windowHashes, err := dm.blockWindow(stagingArea, model.VirtualBlockHash, windowSize)
if err != nil {
return 0, err
}
// return 0 if no blocks had been mined yet
if len(windowHashes) == 0 {
return 0, nil
}
minWindowTimestamp, maxWindowTimestamp, _, _ := blockWindow.minMaxTimestamps()
if minWindowTimestamp == maxWindowTimestamp {
return 0, errors.Errorf("min window timestamp is equal to the max window timestamp")
}
firstHash := windowHashes[0]
firstBlockGHOSTDAGData, err := dm.ghostdagStore.Get(dm.databaseContext, stagingArea, firstHash)
if err != nil {
return 0, err
}
firstBlockBlueWork := firstBlockGHOSTDAGData.BlueWork()
minWindowBlueWork := firstBlockBlueWork
maxWindowBlueWork := firstBlockBlueWork
for _, hash := range windowHashes[1:] {
blockGHOSTDAGData, err := dm.ghostdagStore.Get(dm.databaseContext, stagingArea, hash)
if err != nil {
return 0, err
}
blockBlueWork := blockGHOSTDAGData.BlueWork()
if blockBlueWork.Cmp(minWindowBlueWork) < 0 {
minWindowBlueWork = blockBlueWork
}
if blockBlueWork.Cmp(maxWindowBlueWork) > 0 {
maxWindowBlueWork = blockBlueWork
}
}
nominator := new(big.Int).Sub(maxWindowBlueWork, minWindowBlueWork)
denominator := big.NewInt((maxWindowTimestamp - minWindowTimestamp) / 1000) // Divided by 1000 to convert milliseconds to seconds
networkHashesPerSecondBigInt := new(big.Int).Div(nominator, denominator)
return networkHashesPerSecondBigInt.Uint64(), nil
}

View File

@ -134,6 +134,8 @@ type KaspadMessage struct {
// *KaspadMessage_PruningPointUTXOSetOverrideNotification
// *KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideRequest
// *KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideResponse
// *KaspadMessage_EstimateNetworkHashesPerSecondRequest
// *KaspadMessage_EstimateNetworkHashesPerSecondResponse
Payload isKaspadMessage_Payload `protobuf_oneof:"payload"`
}
@ -897,6 +899,20 @@ func (x *KaspadMessage) GetStopNotifyingPruningPointUTXOSetOverrideResponse() *S
return nil
}
func (x *KaspadMessage) GetEstimateNetworkHashesPerSecondRequest() *EstimateNetworkHashesPerSecondRequestMessage {
if x, ok := x.GetPayload().(*KaspadMessage_EstimateNetworkHashesPerSecondRequest); ok {
return x.EstimateNetworkHashesPerSecondRequest
}
return nil
}
func (x *KaspadMessage) GetEstimateNetworkHashesPerSecondResponse() *EstimateNetworkHashesPerSecondResponseMessage {
if x, ok := x.GetPayload().(*KaspadMessage_EstimateNetworkHashesPerSecondResponse); ok {
return x.EstimateNetworkHashesPerSecondResponse
}
return nil
}
type isKaspadMessage_Payload interface {
isKaspadMessage_Payload()
}
@ -1313,6 +1329,14 @@ type KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideResponse struct {
StopNotifyingPruningPointUTXOSetOverrideResponse *StopNotifyingPruningPointUTXOSetOverrideResponseMessage `protobuf:"bytes,1071,opt,name=stopNotifyingPruningPointUTXOSetOverrideResponse,proto3,oneof"`
}
type KaspadMessage_EstimateNetworkHashesPerSecondRequest struct {
EstimateNetworkHashesPerSecondRequest *EstimateNetworkHashesPerSecondRequestMessage `protobuf:"bytes,1072,opt,name=estimateNetworkHashesPerSecondRequest,proto3,oneof"`
}
type KaspadMessage_EstimateNetworkHashesPerSecondResponse struct {
EstimateNetworkHashesPerSecondResponse *EstimateNetworkHashesPerSecondResponseMessage `protobuf:"bytes,1073,opt,name=estimateNetworkHashesPerSecondResponse,proto3,oneof"`
}
func (*KaspadMessage_Addresses) isKaspadMessage_Payload() {}
func (*KaspadMessage_Block) isKaspadMessage_Payload() {}
@ -1519,13 +1543,17 @@ func (*KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideRequest) isKaspadMe
func (*KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideResponse) isKaspadMessage_Payload() {}
func (*KaspadMessage_EstimateNetworkHashesPerSecondRequest) isKaspadMessage_Payload() {}
func (*KaspadMessage_EstimateNetworkHashesPerSecondResponse) 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, 0xcd, 0x57, 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 +2234,40 @@ 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, 0x90, 0x01,
0x0a, 0x25, 0x65, 0x73, 0x74, 0x69, 0x6d, 0x61, 0x74, 0x65, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72,
0x6b, 0x48, 0x61, 0x73, 0x68, 0x65, 0x73, 0x50, 0x65, 0x72, 0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0xb0, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x37,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x45, 0x73, 0x74, 0x69, 0x6d,
0x61, 0x74, 0x65, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x65, 0x73,
0x50, 0x65, 0x72, 0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x00, 0x52, 0x25, 0x65, 0x73, 0x74, 0x69, 0x6d,
0x61, 0x74, 0x65, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x65, 0x73,
0x50, 0x65, 0x72, 0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x12, 0x93, 0x01, 0x0a, 0x26, 0x65, 0x73, 0x74, 0x69, 0x6d, 0x61, 0x74, 0x65, 0x4e, 0x65, 0x74,
0x77, 0x6f, 0x72, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x65, 0x73, 0x50, 0x65, 0x72, 0x53, 0x65, 0x63,
0x6f, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0xb1, 0x08, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x38, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x45,
0x73, 0x74, 0x69, 0x6d, 0x61, 0x74, 0x65, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x48, 0x61,
0x73, 0x68, 0x65, 0x73, 0x50, 0x65, 0x72, 0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x00, 0x52, 0x26,
0x65, 0x73, 0x74, 0x69, 0x6d, 0x61, 0x74, 0x65, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x48,
0x61, 0x73, 0x68, 0x65, 0x73, 0x50, 0x65, 0x72, 0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64, 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,
}
var (
@ -2340,6 +2387,8 @@ var file_messages_proto_goTypes = []interface{}{
(*PruningPointUTXOSetOverrideNotificationMessage)(nil), // 100: protowire.PruningPointUTXOSetOverrideNotificationMessage
(*StopNotifyingPruningPointUTXOSetOverrideRequestMessage)(nil), // 101: protowire.StopNotifyingPruningPointUTXOSetOverrideRequestMessage
(*StopNotifyingPruningPointUTXOSetOverrideResponseMessage)(nil), // 102: protowire.StopNotifyingPruningPointUTXOSetOverrideResponseMessage
(*EstimateNetworkHashesPerSecondRequestMessage)(nil), // 103: protowire.EstimateNetworkHashesPerSecondRequestMessage
(*EstimateNetworkHashesPerSecondResponseMessage)(nil), // 104: protowire.EstimateNetworkHashesPerSecondResponseMessage
}
var file_messages_proto_depIdxs = []int32{
1, // 0: protowire.KaspadMessage.addresses:type_name -> protowire.AddressesMessage
@ -2445,15 +2494,17 @@ 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.estimateNetworkHashesPerSecondRequest:type_name -> protowire.EstimateNetworkHashesPerSecondRequestMessage
104, // 104: protowire.KaspadMessage.estimateNetworkHashesPerSecondResponse:type_name -> protowire.EstimateNetworkHashesPerSecondResponseMessage
0, // 105: protowire.P2P.MessageStream:input_type -> protowire.KaspadMessage
0, // 106: protowire.RPC.MessageStream:input_type -> protowire.KaspadMessage
0, // 107: protowire.P2P.MessageStream:output_type -> protowire.KaspadMessage
0, // 108: protowire.RPC.MessageStream:output_type -> protowire.KaspadMessage
107, // [107:109] is the sub-list for method output_type
105, // [105:107] is the sub-list for method input_type
105, // [105:105] is the sub-list for extension type_name
105, // [105:105] is the sub-list for extension extendee
0, // [0:105] is the sub-list for field type_name
}
func init() { file_messages_proto_init() }
@ -2581,6 +2632,8 @@ func file_messages_proto_init() {
(*KaspadMessage_PruningPointUTXOSetOverrideNotification)(nil),
(*KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideRequest)(nil),
(*KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideResponse)(nil),
(*KaspadMessage_EstimateNetworkHashesPerSecondRequest)(nil),
(*KaspadMessage_EstimateNetworkHashesPerSecondResponse)(nil),
}
type x struct{}
out := protoimpl.TypeBuilder{

View File

@ -112,6 +112,8 @@ message KaspadMessage {
PruningPointUTXOSetOverrideNotificationMessage pruningPointUTXOSetOverrideNotification = 1069;
StopNotifyingPruningPointUTXOSetOverrideRequestMessage stopNotifyingPruningPointUTXOSetOverrideRequest = 1070;
StopNotifyingPruningPointUTXOSetOverrideResponseMessage stopNotifyingPruningPointUTXOSetOverrideResponse = 1071;
EstimateNetworkHashesPerSecondRequestMessage estimateNetworkHashesPerSecondRequest = 1072;
EstimateNetworkHashesPerSecondResponseMessage estimateNetworkHashesPerSecondResponse = 1073;
}
}

View File

@ -5,11 +5,21 @@
- [rpc.proto](#rpc.proto)
- [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)
- [RpcBlock](#protowire.RpcBlock)
- [RpcBlockHeader](#protowire.RpcBlockHeader)
- [SubmitBlockResponseMessage](#protowire.SubmitBlockResponseMessage)
- [GetBlockTemplateRequestMessage](#protowire.GetBlockTemplateRequestMessage)
- [GetBlockTemplateResponseMessage](#protowire.GetBlockTemplateResponseMessage)
@ -30,20 +40,16 @@
- [GetConnectedPeerInfoResponseMessage](#protowire.GetConnectedPeerInfoResponseMessage)
- [GetConnectedPeerInfoMessage](#protowire.GetConnectedPeerInfoMessage)
- [AddPeerRequestMessage](#protowire.AddPeerRequestMessage)
- [AddPeerResponseMessage](#protowire.AddPeerResponseMessage)
- [SubmitTransactionRequestMessage](#protowire.SubmitTransactionRequestMessage)
- [SubmitTransactionResponseMessage](#protowire.SubmitTransactionResponseMessage)
- [NotifyVirtualSelectedParentChainChangedRequestMessage](#protowire.NotifyVirtualSelectedParentChainChangedRequestMessage)
- [NotifyVirtualSelectedParentChainChangedResponseMessage](#protowire.NotifyVirtualSelectedParentChainChangedResponseMessage)
- [VirtualSelectedParentChainChangedNotificationMessage](#protowire.VirtualSelectedParentChainChangedNotificationMessage)
- [ChainBlock](#protowire.ChainBlock)
- [AcceptedBlock](#protowire.AcceptedBlock)
- [GetBlockRequestMessage](#protowire.GetBlockRequestMessage)
- [GetBlockResponseMessage](#protowire.GetBlockResponseMessage)
- [BlockVerboseData](#protowire.BlockVerboseData)
- [TransactionVerboseData](#protowire.TransactionVerboseData)
- [TransactionVerboseInput](#protowire.TransactionVerboseInput)
- [TransactionVerboseOutput](#protowire.TransactionVerboseOutput)
- [AddPeerResponseMessage](#protowire.AddPeerResponseMessage)
- [SubmitTransactionRequestMessage](#protowire.SubmitTransactionRequestMessage)
- [SubmitTransactionResponseMessage](#protowire.SubmitTransactionResponseMessage)
- [NotifyVirtualSelectedParentChainChangedRequestMessage](#protowire.NotifyVirtualSelectedParentChainChangedRequestMessage)
- [NotifyVirtualSelectedParentChainChangedResponseMessage](#protowire.NotifyVirtualSelectedParentChainChangedResponseMessage)
- [VirtualSelectedParentChainChangedNotificationMessage](#protowire.VirtualSelectedParentChainChangedNotificationMessage)
- [ChainBlock](#protowire.ChainBlock)
- [AcceptedBlock](#protowire.AcceptedBlock)
- [GetBlockRequestMessage](#protowire.GetBlockRequestMessage)
- [GetBlockResponseMessage](#protowire.GetBlockResponseMessage)
- [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)
@ -84,18 +84,20 @@
- [NotifyVirtualSelectedParentBlueScoreChangedResponseMessage](#protowire.NotifyVirtualSelectedParentBlueScoreChangedResponseMessage)
- [VirtualSelectedParentBlueScoreChangedNotificationMessage](#protowire.VirtualSelectedParentBlueScoreChangedNotificationMessage)
- [NotifyPruningPointUTXOSetOverrideRequestMessage](#protowire.NotifyPruningPointUTXOSetOverrideRequestMessage)
- [NotifyPruningPointUTXOSetOverrideResponseMessage](#protowire.NotifyPruningPointUTXOSetOverrideResponseMessage)
- [PruningPointUTXOSetOverrideNotificationMessage](#protowire.PruningPointUTXOSetOverrideNotificationMessage)
- [StopNotifyingPruningPointUTXOSetOverrideRequestMessage](#protowire.StopNotifyingPruningPointUTXOSetOverrideRequestMessage)
- [StopNotifyingPruningPointUTXOSetOverrideResponseMessage](#protowire.StopNotifyingPruningPointUTXOSetOverrideResponseMessage)
- [BanRequestMessage](#protowire.BanRequestMessage)
- [BanResponseMessage](#protowire.BanResponseMessage)
- [UnbanRequestMessage](#protowire.UnbanRequestMessage)
- [UnbanResponseMessage](#protowire.UnbanResponseMessage)
- [GetInfoRequestMessage](#protowire.GetInfoRequestMessage)
- [GetInfoResponseMessage](#protowire.GetInfoResponseMessage)
- [SubmitBlockResponseMessage.RejectReason](#protowire.SubmitBlockResponseMessage.RejectReason)
- [NotifyPruningPointUTXOSetOverrideResponseMessage](#protowire.NotifyPruningPointUTXOSetOverrideResponseMessage)
- [PruningPointUTXOSetOverrideNotificationMessage](#protowire.PruningPointUTXOSetOverrideNotificationMessage)
- [StopNotifyingPruningPointUTXOSetOverrideRequestMessage](#protowire.StopNotifyingPruningPointUTXOSetOverrideRequestMessage)
- [StopNotifyingPruningPointUTXOSetOverrideResponseMessage](#protowire.StopNotifyingPruningPointUTXOSetOverrideResponseMessage)
- [BanRequestMessage](#protowire.BanRequestMessage)
- [BanResponseMessage](#protowire.BanResponseMessage)
- [UnbanRequestMessage](#protowire.UnbanRequestMessage)
- [UnbanResponseMessage](#protowire.UnbanResponseMessage)
- [GetInfoRequestMessage](#protowire.GetInfoRequestMessage)
- [GetInfoResponseMessage](#protowire.GetInfoResponseMessage)
- [EstimateNetworkHashesPerSecondRequestMessage](#protowire.EstimateNetworkHashesPerSecondRequestMessage)
- [EstimateNetworkHashesPerSecondResponseMessage](#protowire.EstimateNetworkHashesPerSecondResponseMessage)
- [SubmitBlockResponseMessage.RejectReason](#protowire.SubmitBlockResponseMessage.RejectReason)
- [Scalar Value Types](#scalar-value-types)
@ -127,52 +129,6 @@ Receivers of any ResponseMessage are expected to check whether its error field i
| ----- | ---- | ----- | ----------- |
| message | [string](#string) | | |
<a name="protowire.GetCurrentNetworkRequestMessage"></a>
### GetCurrentNetworkRequestMessage
GetCurrentNetworkRequestMessage requests the network kaspad is currently running against.
Possible networks are: Mainnet, Testnet, Simnet, Devnet
<a name="protowire.GetCurrentNetworkResponseMessage"></a>
### GetCurrentNetworkResponseMessage
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| currentNetwork | [string](#string) | | |
| error | [RPCError](#protowire.RPCError) | | |
<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.
See: GetBlockTemplateRequestMessage
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| block | [RpcBlock](#protowire.RpcBlock) | | |
<a name="protowire.RpcBlock"></a>
### RpcBlock
@ -181,6 +137,7 @@ See: GetBlockTemplateRequestMessage
| ----- | ---- | ----- | ----------- |
| header | [RpcBlockHeader](#protowire.RpcBlockHeader) | | |
| transactions | [RpcTransaction](#protowire.RpcTransaction) | repeated | |
| verboseData | [RpcBlockVerboseData](#protowire.RpcBlockVerboseData) | | |
<a name="protowire.RpcBlockHeader"></a>
@ -197,6 +154,140 @@ See: GetBlockTemplateRequestMessage
| 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
GetCurrentNetworkRequestMessage requests the network kaspad is currently running against.
Possible networks are: Mainnet, Testnet, Simnet, Devnet
<a name="protowire.GetCurrentNetworkResponseMessage"></a>
### GetCurrentNetworkResponseMessage
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| currentNetwork | [string](#string) | | |
| error | [RPCError](#protowire.RPCError) | | |
<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.
See: GetBlockTemplateRequestMessage
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| block | [RpcBlock](#protowire.RpcBlock) | | |
<a name="protowire.SubmitBlockResponseMessage"></a>
### SubmitBlockResponseMessage
@ -284,7 +375,7 @@ See: NotifyBlockAddedRequestMessage
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| blockVerboseData | [BlockVerboseData](#protowire.BlockVerboseData) | | |
| block | [RpcBlock](#protowire.RpcBlock) | | |
@ -429,7 +520,7 @@ currently in the mempool.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| fee | [uint64](#uint64) | | |
| transactionVerboseData | [TransactionVerboseData](#protowire.TransactionVerboseData) | | |
| transaction | [RpcTransaction](#protowire.RpcTransaction) | | |
@ -651,78 +742,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 +826,7 @@ kaspad&#39;s current virtual.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| lowHash | [string](#string) | | |
| includeBlockVerboseData | [bool](#bool) | | |
| includeBlocks | [bool](#bool) | | |
| includeTransactionVerboseData | [bool](#bool) | | |
@ -822,7 +843,7 @@ kaspad&#39;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) | | |
@ -1141,110 +1162,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
@ -1498,26 +1415,33 @@ GetInfoRequestMessage returns info about the node.
### GetInfoResponseMessage
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| p2pId | [string](#string) | | |
| mempoolSize | [uint64](#uint64) | | |
| error | [RPCError](#protowire.RPCError) | | |
<a name="protowire.EstimateNetworkHashesPerSecondRequestMessage"></a>
### EstimateNetworkHashesPerSecondRequestMessage
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| windowSize | [uint32](#uint32) | | |
<a name="protowire.EstimateNetworkHashesPerSecondResponseMessage"></a>
### EstimateNetworkHashesPerSecondResponseMessage
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| networkHashesPerSecond | [uint64](#uint64) | | |
| error | [RPCError](#protowire.RPCError) | | |
<a name="protowire.SubmitBlockResponseMessage.RejectReason"></a>
### SubmitBlockResponseMessage.RejectReason
| Name | Number | Description |
| ---- | ------ | ----------- |
| NONE | 0 | |

View File

@ -4994,6 +4994,108 @@ func (x *GetInfoResponseMessage) GetError() *RPCError {
return nil
}
type EstimateNetworkHashesPerSecondRequestMessage struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
WindowSize uint32 `protobuf:"varint,1,opt,name=windowSize,proto3" json:"windowSize,omitempty"`
}
func (x *EstimateNetworkHashesPerSecondRequestMessage) Reset() {
*x = EstimateNetworkHashesPerSecondRequestMessage{}
if protoimpl.UnsafeEnabled {
mi := &file_rpc_proto_msgTypes[90]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *EstimateNetworkHashesPerSecondRequestMessage) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*EstimateNetworkHashesPerSecondRequestMessage) ProtoMessage() {}
func (x *EstimateNetworkHashesPerSecondRequestMessage) ProtoReflect() protoreflect.Message {
mi := &file_rpc_proto_msgTypes[90]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use EstimateNetworkHashesPerSecondRequestMessage.ProtoReflect.Descriptor instead.
func (*EstimateNetworkHashesPerSecondRequestMessage) Descriptor() ([]byte, []int) {
return file_rpc_proto_rawDescGZIP(), []int{90}
}
func (x *EstimateNetworkHashesPerSecondRequestMessage) GetWindowSize() uint32 {
if x != nil {
return x.WindowSize
}
return 0
}
type EstimateNetworkHashesPerSecondResponseMessage struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
NetworkHashesPerSecond uint64 `protobuf:"varint,1,opt,name=networkHashesPerSecond,proto3" json:"networkHashesPerSecond,omitempty"`
Error *RPCError `protobuf:"bytes,1000,opt,name=error,proto3" json:"error,omitempty"`
}
func (x *EstimateNetworkHashesPerSecondResponseMessage) Reset() {
*x = EstimateNetworkHashesPerSecondResponseMessage{}
if protoimpl.UnsafeEnabled {
mi := &file_rpc_proto_msgTypes[91]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *EstimateNetworkHashesPerSecondResponseMessage) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*EstimateNetworkHashesPerSecondResponseMessage) ProtoMessage() {}
func (x *EstimateNetworkHashesPerSecondResponseMessage) ProtoReflect() protoreflect.Message {
mi := &file_rpc_proto_msgTypes[91]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use EstimateNetworkHashesPerSecondResponseMessage.ProtoReflect.Descriptor instead.
func (*EstimateNetworkHashesPerSecondResponseMessage) Descriptor() ([]byte, []int) {
return file_rpc_proto_rawDescGZIP(), []int{91}
}
func (x *EstimateNetworkHashesPerSecondResponseMessage) GetNetworkHashesPerSecond() uint64 {
if x != nil {
return x.NetworkHashesPerSecond
}
return 0
}
func (x *EstimateNetworkHashesPerSecondResponseMessage) GetError() *RPCError {
if x != nil {
return x.Error
}
return nil
}
var File_rpc_proto protoreflect.FileDescriptor
var file_rpc_proto_rawDesc = []byte{
@ -5617,10 +5719,24 @@ var file_rpc_proto_rawDesc = []byte{
0x04, 0x52, 0x0b, 0x6d, 0x65, 0x6d, 0x70, 0x6f, 0x6f, 0x6c, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x2a,
0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0xe8, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x52, 0x50, 0x43, 0x45, 0x72,
0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 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, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x4e, 0x0a, 0x2c, 0x45, 0x73,
0x74, 0x69, 0x6d, 0x61, 0x74, 0x65, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x48, 0x61, 0x73,
0x68, 0x65, 0x73, 0x50, 0x65, 0x72, 0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x77, 0x69,
0x6e, 0x64, 0x6f, 0x77, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a,
0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x53, 0x69, 0x7a, 0x65, 0x22, 0x93, 0x01, 0x0a, 0x2d, 0x45,
0x73, 0x74, 0x69, 0x6d, 0x61, 0x74, 0x65, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x48, 0x61,
0x73, 0x68, 0x65, 0x73, 0x50, 0x65, 0x72, 0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x36, 0x0a, 0x16,
0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x65, 0x73, 0x50, 0x65, 0x72,
0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x16, 0x6e, 0x65,
0x74, 0x77, 0x6f, 0x72, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x65, 0x73, 0x50, 0x65, 0x72, 0x53, 0x65,
0x63, 0x6f, 0x6e, 0x64, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0xe8, 0x07,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65,
0x2e, 0x52, 0x50, 0x43, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72,
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 (
@ -5636,7 +5752,7 @@ func file_rpc_proto_rawDescGZIP() []byte {
}
var file_rpc_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_rpc_proto_msgTypes = make([]protoimpl.MessageInfo, 90)
var file_rpc_proto_msgTypes = make([]protoimpl.MessageInfo, 92)
var file_rpc_proto_goTypes = []interface{}{
(SubmitBlockResponseMessage_RejectReason)(0), // 0: protowire.SubmitBlockResponseMessage.RejectReason
(*RPCError)(nil), // 1: protowire.RPCError
@ -5729,6 +5845,8 @@ var file_rpc_proto_goTypes = []interface{}{
(*UnbanResponseMessage)(nil), // 88: protowire.UnbanResponseMessage
(*GetInfoRequestMessage)(nil), // 89: protowire.GetInfoRequestMessage
(*GetInfoResponseMessage)(nil), // 90: protowire.GetInfoResponseMessage
(*EstimateNetworkHashesPerSecondRequestMessage)(nil), // 91: protowire.EstimateNetworkHashesPerSecondRequestMessage
(*EstimateNetworkHashesPerSecondResponseMessage)(nil), // 92: protowire.EstimateNetworkHashesPerSecondResponseMessage
}
var file_rpc_proto_depIdxs = []int32{
3, // 0: protowire.RpcBlock.header:type_name -> protowire.RpcBlockHeader
@ -5795,11 +5913,12 @@ var file_rpc_proto_depIdxs = []int32{
1, // 61: protowire.BanResponseMessage.error:type_name -> protowire.RPCError
1, // 62: protowire.UnbanResponseMessage.error:type_name -> protowire.RPCError
1, // 63: protowire.GetInfoResponseMessage.error:type_name -> protowire.RPCError
64, // [64:64] is the sub-list for method output_type
64, // [64:64] is the sub-list for method input_type
64, // [64:64] is the sub-list for extension type_name
64, // [64:64] is the sub-list for extension extendee
0, // [0:64] is the sub-list for field type_name
1, // 64: protowire.EstimateNetworkHashesPerSecondResponseMessage.error:type_name -> protowire.RPCError
65, // [65:65] is the sub-list for method output_type
65, // [65:65] is the sub-list for method input_type
65, // [65:65] is the sub-list for extension type_name
65, // [65:65] is the sub-list for extension extendee
0, // [0:65] is the sub-list for field type_name
}
func init() { file_rpc_proto_init() }
@ -6888,6 +7007,30 @@ func file_rpc_proto_init() {
return nil
}
}
file_rpc_proto_msgTypes[90].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*EstimateNetworkHashesPerSecondRequestMessage); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_rpc_proto_msgTypes[91].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*EstimateNetworkHashesPerSecondResponseMessage); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
@ -6895,7 +7038,7 @@ func file_rpc_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_rpc_proto_rawDesc,
NumEnums: 1,
NumMessages: 90,
NumMessages: 92,
NumExtensions: 0,
NumServices: 0,
},

View File

@ -588,3 +588,14 @@ message GetInfoResponseMessage{
uint64 mempoolSize = 2;
RPCError error = 1000;
}
message EstimateNetworkHashesPerSecondRequestMessage{
uint32 windowSize = 1;
}
message EstimateNetworkHashesPerSecondResponseMessage{
uint64 networkHashesPerSecond = 1;
RPCError error = 1000;
}

View File

@ -0,0 +1,68 @@
package protowire
import (
"github.com/kaspanet/kaspad/app/appmessage"
"github.com/pkg/errors"
)
func (x *KaspadMessage_EstimateNetworkHashesPerSecondRequest) toAppMessage() (appmessage.Message, error) {
if x == nil {
return nil, errors.Wrapf(errorNil, "KaspadMessage_EstimateNetworkHashesPerSecondRequest is nil")
}
return x.EstimateNetworkHashesPerSecondRequest.toAppMessage()
}
func (x *KaspadMessage_EstimateNetworkHashesPerSecondRequest) fromAppMessage(message *appmessage.EstimateNetworkHashesPerSecondRequestMessage) error {
x.EstimateNetworkHashesPerSecondRequest = &EstimateNetworkHashesPerSecondRequestMessage{
WindowSize: message.WindowSize,
}
return nil
}
func (x *EstimateNetworkHashesPerSecondRequestMessage) toAppMessage() (appmessage.Message, error) {
if x == nil {
return nil, errors.Wrapf(errorNil, "EstimateNetworkHashesPerSecondRequestMessage is nil")
}
return &appmessage.EstimateNetworkHashesPerSecondRequestMessage{
WindowSize: x.WindowSize,
}, nil
}
func (x *KaspadMessage_EstimateNetworkHashesPerSecondResponse) toAppMessage() (appmessage.Message, error) {
if x == nil {
return nil, errors.Wrapf(errorNil, "KaspadMessage_EstimateNetworkHashesPerSecondResponse is nil")
}
return x.EstimateNetworkHashesPerSecondResponse.toAppMessage()
}
func (x *KaspadMessage_EstimateNetworkHashesPerSecondResponse) fromAppMessage(message *appmessage.EstimateNetworkHashesPerSecondResponseMessage) error {
var err *RPCError
if message.Error != nil {
err = &RPCError{Message: message.Error.Message}
}
x.EstimateNetworkHashesPerSecondResponse = &EstimateNetworkHashesPerSecondResponseMessage{
NetworkHashesPerSecond: message.NetworkHashesPerSecond,
Error: err,
}
return nil
}
func (x *EstimateNetworkHashesPerSecondResponseMessage) toAppMessage() (appmessage.Message, error) {
if x == nil {
return nil, errors.Wrapf(errorNil, "EstimateNetworkHashesPerSecondResponseMessage is nil")
}
rpcErr, err := x.Error.toAppMessage()
// Error is an optional field
if err != nil && !errors.Is(err, errorNil) {
return nil, err
}
if rpcErr != nil && x.NetworkHashesPerSecond != 0 {
return nil, errors.New("EstimateNetworkHashesPerSecondResponseMessage contains both an error and a response")
}
return &appmessage.EstimateNetworkHashesPerSecondResponseMessage{
NetworkHashesPerSecond: x.NetworkHashesPerSecond,
Error: rpcErr,
}, nil
}

View File

@ -779,6 +779,20 @@ func toRPCPayload(message appmessage.Message) (isKaspadMessage_Payload, error) {
return nil, err
}
return payload, nil
case *appmessage.EstimateNetworkHashesPerSecondRequestMessage:
payload := new(KaspadMessage_EstimateNetworkHashesPerSecondRequest)
err := payload.fromAppMessage(message)
if err != nil {
return nil, err
}
return payload, nil
case *appmessage.EstimateNetworkHashesPerSecondResponseMessage:
payload := new(KaspadMessage_EstimateNetworkHashesPerSecondResponse)
err := payload.fromAppMessage(message)
if err != nil {
return nil, err
}
return payload, nil
default:
return nil, nil
}

View File

@ -0,0 +1,20 @@
package rpcclient
import "github.com/kaspanet/kaspad/app/appmessage"
// EstimateNetworkHashesPerSecond sends an RPC request respective to the function's name and returns the RPC server's response
func (c *RPCClient) EstimateNetworkHashesPerSecond(windowSize uint32) (*appmessage.EstimateNetworkHashesPerSecondResponseMessage, error) {
err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewEstimateNetworkHashesPerSecondRequestMessage(windowSize))
if err != nil {
return nil, err
}
response, err := c.route(appmessage.CmdEstimateNetworkHashesPerSecondResponseMessage).DequeueWithTimeout(c.timeout)
if err != nil {
return nil, err
}
estimateNetworkHashesPerSecondResponse := response.(*appmessage.EstimateNetworkHashesPerSecondResponseMessage)
if estimateNetworkHashesPerSecondResponse.Error != nil {
return nil, c.convertRPCError(estimateNetworkHashesPerSecondResponse.Error)
}
return estimateNetworkHashesPerSecondResponse, nil
}