-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_coin_supply.go
30 lines (24 loc) · 1005 Bytes
/
get_coin_supply.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package rpchandlers
import (
"github.com/karlsend/PYVERT/testfork/karlsend/app/appmessage"
"github.com/karlsend/PYVERT/testfork/karlsend/app/rpc/rpccontext"
"github.com/karlsend/PYVERT/testfork/karlsend/domain/consensus/utils/constants"
"github.com/karlsend/PYVERT/testfork/karlsend/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 karlsend 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
}