From 4f4a8934e74e836f3823cbbbb07ee97d67e0e02e Mon Sep 17 00:00:00 2001 From: Svarog Date: Thu, 27 May 2021 14:59:29 +0300 Subject: [PATCH] Add option to specify blockHash in EstimateNetworkHashesPerSecond (#1731) * Add BlockHash optional parameter to EstimateNetworkBlockHashesPerSecond * Allow to pass '-' for optional values in kaspactl * Solve a division-by-zero in estimateNetworkHashesPerSecond * Add BlockHash to toAppMessage/fromAppMessage functions * Rename: topHash -> StartHash * Return proper error message if provided startHash doesn't deserialize into a hash --- .../rpc_estimate_network_hashes_per_second.go | 4 +- .../flows/testing/handle_relay_invs_test.go | 2 +- .../estimate_network_hashes_per_second.go | 22 ++++++++-- cmd/kaspactl/command_parser.go | 4 ++ cmd/kaspactl/config.go | 3 +- domain/consensus/consensus.go | 4 +- .../consensus/model/externalapi/consensus.go | 2 +- .../interface_processes_difficultymanager.go | 2 +- ...ation_proof_of_work_and_difficulty_test.go | 2 +- .../processes/difficultymanager/hashrate.go | 26 ++++++++---- .../server/grpcserver/protowire/rpc.pb.go | 42 ++++++++++++------- .../server/grpcserver/protowire/rpc.proto | 1 + .../rpc_estimate_network_hashes_per_second.go | 2 + .../rpc_estimate_network_hashes_per_second.go | 4 +- 14 files changed, 83 insertions(+), 37 deletions(-) diff --git a/app/appmessage/rpc_estimate_network_hashes_per_second.go b/app/appmessage/rpc_estimate_network_hashes_per_second.go index 48fe6c46e..d298c91bc 100644 --- a/app/appmessage/rpc_estimate_network_hashes_per_second.go +++ b/app/appmessage/rpc_estimate_network_hashes_per_second.go @@ -4,6 +4,7 @@ package appmessage // its respective RPC message type EstimateNetworkHashesPerSecondRequestMessage struct { baseMessage + StartHash string WindowSize uint32 } @@ -13,8 +14,9 @@ func (msg *EstimateNetworkHashesPerSecondRequestMessage) Command() MessageComman } // NewEstimateNetworkHashesPerSecondRequestMessage returns a instance of the message -func NewEstimateNetworkHashesPerSecondRequestMessage(windowSize uint32) *EstimateNetworkHashesPerSecondRequestMessage { +func NewEstimateNetworkHashesPerSecondRequestMessage(startHash string, windowSize uint32) *EstimateNetworkHashesPerSecondRequestMessage { return &EstimateNetworkHashesPerSecondRequestMessage{ + StartHash: startHash, WindowSize: windowSize, } } diff --git a/app/protocol/flows/testing/handle_relay_invs_test.go b/app/protocol/flows/testing/handle_relay_invs_test.go index cf753ab36..230638a01 100644 --- a/app/protocol/flows/testing/handle_relay_invs_test.go +++ b/app/protocol/flows/testing/handle_relay_invs_test.go @@ -130,7 +130,7 @@ type fakeRelayInvsContext struct { rwLock sync.RWMutex } -func (f *fakeRelayInvsContext) EstimateNetworkHashesPerSecond(windowSize int) (uint64, error) { +func (f *fakeRelayInvsContext) EstimateNetworkHashesPerSecond(startHash *externalapi.DomainHash, windowSize int) (uint64, error) { panic(errors.Errorf("called unimplemented function from test '%s'", f.testName)) } diff --git a/app/rpc/rpchandlers/estimate_network_hashes_per_second.go b/app/rpc/rpchandlers/estimate_network_hashes_per_second.go index 41e359a5f..505c62b2a 100644 --- a/app/rpc/rpchandlers/estimate_network_hashes_per_second.go +++ b/app/rpc/rpchandlers/estimate_network_hashes_per_second.go @@ -3,19 +3,35 @@ package rpchandlers import ( "github.com/kaspanet/kaspad/app/appmessage" "github.com/kaspanet/kaspad/app/rpc/rpccontext" + "github.com/kaspanet/kaspad/domain/consensus/model" + "github.com/kaspanet/kaspad/domain/consensus/model/externalapi" "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) { +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) + startHash := model.VirtualBlockHash + if estimateNetworkHashesPerSecondRequest.StartHash != "" { + var err error + startHash, err = externalapi.NewDomainHashFromString(estimateNetworkHashesPerSecondRequest.StartHash) + if err != nil { + response := &appmessage.EstimateNetworkHashesPerSecondResponseMessage{} + response.Error = appmessage.RPCErrorf("StartHash '%s' is not a valid block hash", + estimateNetworkHashesPerSecondRequest.StartHash) + return response, nil + } + } + + networkHashesPerSecond, err := context.Domain.Consensus().EstimateNetworkHashesPerSecond(startHash, 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) + "second for startHash %s and window size %d: %s", startHash, windowSize, err) return response, nil } diff --git a/cmd/kaspactl/command_parser.go b/cmd/kaspactl/command_parser.go index ee74bfc6b..6c174d9df 100644 --- a/cmd/kaspactl/command_parser.go +++ b/cmd/kaspactl/command_parser.go @@ -48,6 +48,10 @@ func setField(commandValue reflect.Value, parameterValue reflect.Value, paramete } func stringToValue(parameterDesc *parameterDescription, valueStr string) (reflect.Value, error) { + if valueStr == "-" { + return reflect.Zero(parameterDesc.typeof), nil + } + var value interface{} var err error switch parameterDesc.typeof.Kind() { diff --git a/cmd/kaspactl/config.go b/cmd/kaspactl/config.go index 0b240529a..7053d4573 100644 --- a/cmd/kaspactl/config.go +++ b/cmd/kaspactl/config.go @@ -27,7 +27,8 @@ func parseConfig() (*configFlags, error) { } parser := flags.NewParser(cfg, flags.HelpFlag) parser.Usage = "kaspactl [OPTIONS] [COMMAND] [COMMAND PARAMETERS].\n\nCommand can be supplied only if --json is not used." + - "\n\nUse `kaspactl --list-commands` to get a list of all commands and their parameters" + "\n\nUse `kaspactl --list-commands` to get a list of all commands and their parameters." + + "\nFor optional parameters- use '-' without quotes to not pass the parameter.\n" remainingArgs, err := parser.Parse() if err != nil { return nil, err diff --git a/domain/consensus/consensus.go b/domain/consensus/consensus.go index fa0d7c1b7..425a9b808 100644 --- a/domain/consensus/consensus.go +++ b/domain/consensus/consensus.go @@ -536,9 +536,9 @@ func (s *consensus) Anticone(blockHash *externalapi.DomainHash) ([]*externalapi. return s.dagTraversalManager.Anticone(stagingArea, blockHash) } -func (s *consensus) EstimateNetworkHashesPerSecond(windowSize int) (uint64, error) { +func (s *consensus) EstimateNetworkHashesPerSecond(startHash *externalapi.DomainHash, windowSize int) (uint64, error) { s.lock.Lock() defer s.lock.Unlock() - return s.difficultyManager.EstimateNetworkHashesPerSecond(windowSize) + return s.difficultyManager.EstimateNetworkHashesPerSecond(startHash, windowSize) } diff --git a/domain/consensus/model/externalapi/consensus.go b/domain/consensus/model/externalapi/consensus.go index 64075cf39..c565a0f90 100644 --- a/domain/consensus/model/externalapi/consensus.go +++ b/domain/consensus/model/externalapi/consensus.go @@ -33,5 +33,5 @@ type Consensus interface { IsInSelectedParentChainOf(blockHashA *DomainHash, blockHashB *DomainHash) (bool, error) GetHeadersSelectedTip() (*DomainHash, error) Anticone(blockHash *DomainHash) ([]*DomainHash, error) - EstimateNetworkHashesPerSecond(windowSize int) (uint64, error) + EstimateNetworkHashesPerSecond(startHash *DomainHash, windowSize int) (uint64, error) } diff --git a/domain/consensus/model/interface_processes_difficultymanager.go b/domain/consensus/model/interface_processes_difficultymanager.go index 999e74ec0..704b0b929 100644 --- a/domain/consensus/model/interface_processes_difficultymanager.go +++ b/domain/consensus/model/interface_processes_difficultymanager.go @@ -9,5 +9,5 @@ import ( type DifficultyManager interface { StageDAADataAndReturnRequiredDifficulty(stagingArea *StagingArea, blockHash *externalapi.DomainHash) (uint32, error) RequiredDifficulty(stagingArea *StagingArea, blockHash *externalapi.DomainHash) (uint32, error) - EstimateNetworkHashesPerSecond(windowSize int) (uint64, error) + EstimateNetworkHashesPerSecond(startHash *externalapi.DomainHash, windowSize int) (uint64, error) } diff --git a/domain/consensus/processes/blockvalidator/pruning_violation_proof_of_work_and_difficulty_test.go b/domain/consensus/processes/blockvalidator/pruning_violation_proof_of_work_and_difficulty_test.go index 73b595774..972c8259a 100644 --- a/domain/consensus/processes/blockvalidator/pruning_violation_proof_of_work_and_difficulty_test.go +++ b/domain/consensus/processes/blockvalidator/pruning_violation_proof_of_work_and_difficulty_test.go @@ -313,6 +313,6 @@ func (dm *mocDifficultyManager) StageDAADataAndReturnRequiredDifficulty(stagingA return dm.testDifficulty, nil } -func (dm *mocDifficultyManager) EstimateNetworkHashesPerSecond(windowSize int) (uint64, error) { +func (dm *mocDifficultyManager) EstimateNetworkHashesPerSecond(startHash *externalapi.DomainHash, windowSize int) (uint64, error) { return 0, nil } diff --git a/domain/consensus/processes/difficultymanager/hashrate.go b/domain/consensus/processes/difficultymanager/hashrate.go index 1bd04e10e..b217b8c0f 100644 --- a/domain/consensus/processes/difficultymanager/hashrate.go +++ b/domain/consensus/processes/difficultymanager/hashrate.go @@ -1,26 +1,31 @@ package difficultymanager import ( + "math/big" + "github.com/kaspanet/kaspad/domain/consensus/model" + "github.com/kaspanet/kaspad/domain/consensus/model/externalapi" "github.com/kaspanet/kaspad/infrastructure/logger" "github.com/pkg/errors" - "math/big" ) -func (dm *difficultyManager) EstimateNetworkHashesPerSecond(windowSize int) (uint64, error) { +func (dm *difficultyManager) EstimateNetworkHashesPerSecond(startHash *externalapi.DomainHash, windowSize int) (uint64, error) { onEnd := logger.LogAndMeasureExecutionTime(log, "EstimateNetworkHashesPerSecond") defer onEnd() stagingArea := model.NewStagingArea() - return dm.estimateNetworkHashesPerSecond(stagingArea, windowSize) + return dm.estimateNetworkHashesPerSecond(stagingArea, startHash, 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") +func (dm *difficultyManager) estimateNetworkHashesPerSecond(stagingArea *model.StagingArea, + startHash *externalapi.DomainHash, windowSize int) (uint64, error) { + + const minWindowSize = 1000 + if windowSize < minWindowSize { + return 0, errors.Errorf("windowSize must be equal to or greater than %d", minWindowSize) } - blockWindow, windowHashes, err := dm.blockWindow(stagingArea, model.VirtualBlockHash, windowSize) + blockWindow, windowHashes, err := dm.blockWindow(stagingArea, startHash, windowSize) if err != nil { return 0, err } @@ -57,8 +62,13 @@ func (dm *difficultyManager) estimateNetworkHashesPerSecond(stagingArea *model.S } } + windowsDiff := (maxWindowTimestamp - minWindowTimestamp) / 1000 // Divided by 1000 to convert milliseconds to seconds + if windowsDiff == 0 { + return 0, nil + } + nominator := new(big.Int).Sub(maxWindowBlueWork, minWindowBlueWork) - denominator := big.NewInt((maxWindowTimestamp - minWindowTimestamp) / 1000) // Divided by 1000 to convert milliseconds to seconds + denominator := big.NewInt(windowsDiff) networkHashesPerSecondBigInt := new(big.Int).Div(nominator, denominator) return networkHashesPerSecondBigInt.Uint64(), nil } diff --git a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.pb.go b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.pb.go index c3f210765..742929ad2 100644 --- a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.pb.go +++ b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.pb.go @@ -17,11 +17,12 @@ package protowire import ( + reflect "reflect" + sync "sync" + proto "github.com/golang/protobuf/proto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" ) const ( @@ -5008,6 +5009,7 @@ type EstimateNetworkHashesPerSecondRequestMessage struct { unknownFields protoimpl.UnknownFields WindowSize uint32 `protobuf:"varint,1,opt,name=windowSize,proto3" json:"windowSize,omitempty"` + StartHash string `protobuf:"bytes,2,opt,name=blockHash,proto3" json:"blockHash,omitempty"` } func (x *EstimateNetworkHashesPerSecondRequestMessage) Reset() { @@ -5049,6 +5051,13 @@ func (x *EstimateNetworkHashesPerSecondRequestMessage) GetWindowSize() uint32 { return 0 } +func (x *EstimateNetworkHashesPerSecondRequestMessage) GetBlockHash() string { + if x != nil { + return x.StartHash + } + return "" +} + type EstimateNetworkHashesPerSecondResponseMessage struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -5727,25 +5736,26 @@ var file_rpc_proto_rawDesc = []byte{ 0x01, 0x28, 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, 0x22, 0x4e, 0x0a, 0x2c, + 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x6c, 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, + 0x52, 0x0a, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1c, 0x0a, 0x09, + 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 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, 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, + 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 ( diff --git a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.proto b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.proto index dc0efd00c..d38682449 100644 --- a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.proto +++ b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.proto @@ -592,6 +592,7 @@ message GetInfoResponseMessage{ message EstimateNetworkHashesPerSecondRequestMessage{ uint32 windowSize = 1; + string blockHash = 2; } message EstimateNetworkHashesPerSecondResponseMessage{ diff --git a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_estimate_network_hashes_per_second.go b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_estimate_network_hashes_per_second.go index 8b3a22b46..cee088402 100644 --- a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_estimate_network_hashes_per_second.go +++ b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_estimate_network_hashes_per_second.go @@ -15,6 +15,7 @@ func (x *KaspadMessage_EstimateNetworkHashesPerSecondRequest) toAppMessage() (ap func (x *KaspadMessage_EstimateNetworkHashesPerSecondRequest) fromAppMessage(message *appmessage.EstimateNetworkHashesPerSecondRequestMessage) error { x.EstimateNetworkHashesPerSecondRequest = &EstimateNetworkHashesPerSecondRequestMessage{ WindowSize: message.WindowSize, + StartHash: message.StartHash, } return nil } @@ -25,6 +26,7 @@ func (x *EstimateNetworkHashesPerSecondRequestMessage) toAppMessage() (appmessag } return &appmessage.EstimateNetworkHashesPerSecondRequestMessage{ WindowSize: x.WindowSize, + StartHash: x.StartHash, }, nil } diff --git a/infrastructure/network/rpcclient/rpc_estimate_network_hashes_per_second.go b/infrastructure/network/rpcclient/rpc_estimate_network_hashes_per_second.go index 1776aba31..39c00f3f5 100644 --- a/infrastructure/network/rpcclient/rpc_estimate_network_hashes_per_second.go +++ b/infrastructure/network/rpcclient/rpc_estimate_network_hashes_per_second.go @@ -3,8 +3,8 @@ 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)) +func (c *RPCClient) EstimateNetworkHashesPerSecond(startHash string, windowSize uint32) (*appmessage.EstimateNetworkHashesPerSecondResponseMessage, error) { + err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewEstimateNetworkHashesPerSecondRequestMessage(startHash, windowSize)) if err != nil { return nil, err }