mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-05-28 09:46:50 +00:00

* include utxoIndex and isNearlySynced in GetInfo * fmt fixing * add missing IsNearlySynced * change `isNearlySynced` -> `isSynced` & `isUtxoIndexSet` ->`isUtxoIndexed` * Add a check for `HasPeers` to make `isSynced` identical to `GetBlockTemplate.isSynced` Co-authored-by: msutton <mikisiton2@gmail.com>
27 lines
812 B
Go
27 lines
812 B
Go
package rpchandlers
|
|
|
|
import (
|
|
"github.com/kaspanet/kaspad/app/appmessage"
|
|
"github.com/kaspanet/kaspad/app/rpc/rpccontext"
|
|
"github.com/kaspanet/kaspad/infrastructure/network/netadapter/router"
|
|
"github.com/kaspanet/kaspad/version"
|
|
)
|
|
|
|
// HandleGetInfo handles the respectively named RPC command
|
|
func HandleGetInfo(context *rpccontext.Context, _ *router.Router, _ appmessage.Message) (appmessage.Message, error) {
|
|
isNearlySynced, err := context.Domain.Consensus().IsNearlySynced()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
response := appmessage.NewGetInfoResponseMessage(
|
|
context.NetAdapter.ID().String(),
|
|
uint64(context.Domain.MiningManager().TransactionCount()),
|
|
version.Version(),
|
|
context.Config.UTXOIndex,
|
|
context.ProtocolManager.Context().HasPeers() && isNearlySynced,
|
|
)
|
|
|
|
return response, nil
|
|
}
|