mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-05-22 06:46:46 +00:00

* start * pass tests, (cannot get before put!) and clean up. * add rpc call. * create and pass tests, fix bugs. fully implement rpc * As always fmt * remover old test * clean up proto comment * put the logger back in place. * revert back to 10 sec limit. * migration, change utxoChanged removal to whole utxoEntryPair, add methods to update circulating supply, intialize circulating supply from reset. * Update utxoindex.go * ad * rename to max, change comment * one more total to max Co-authored-by: Ori Newman <orinewman1@gmail.com>
30 lines
930 B
Go
30 lines
930 B
Go
package rpchandlers
|
|
|
|
import (
|
|
"github.com/kaspanet/kaspad/app/appmessage"
|
|
"github.com/kaspanet/kaspad/app/rpc/rpccontext"
|
|
"github.com/kaspanet/kaspad/domain/consensus/utils/constants"
|
|
"github.com/kaspanet/kaspad/infrastructure/network/netadapter/router"
|
|
)
|
|
|
|
// HandleGetCoinSupply handles the respectively named RPC command
|
|
func HandleGetCoinSupply(context *rpccontext.Context, _ *router.Router, _ appmessage.Message) (appmessage.Message, error) {
|
|
if !context.Config.UTXOIndex {
|
|
errorMessage := &appmessage.GetCoinSupplyResponseMessage{}
|
|
errorMessage.Error = appmessage.RPCErrorf("Method unavailable when kaspad is run without --utxoindex")
|
|
return errorMessage, nil
|
|
}
|
|
|
|
circulatingSompiSupply, err := context.UTXOIndex.GetCirculatingSompiSupply()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
response := appmessage.NewGetCoinSupplyResponseMessage(
|
|
constants.MaxSompi,
|
|
circulatingSompiSupply,
|
|
)
|
|
|
|
return response, nil
|
|
}
|