Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions blockchain/supply.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package blockchain

import "github.com/deroproject/derohe/config"

func CalcSupply(height uint64) uint64 {
supply := config.PREMINE
remainingBlocks := height
epochStartHeight := uint64(0)

for remainingBlocks > 0 {
blocksInEpoch := RewardReductionInterval
if remainingBlocks < blocksInEpoch {
blocksInEpoch = remainingBlocks
}

supply += CalcBlockReward(epochStartHeight) * blocksInEpoch

remainingBlocks -= blocksInEpoch
epochStartHeight += RewardReductionInterval
}

return supply
}
6 changes: 2 additions & 4 deletions cmd/derod/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func main() {
if _, ok := globals.Arguments["--log-dir"]; ok && globals.Arguments["--log-dir"] != nil {
logdir = globals.Arguments["--log-dir"].(string)
filename = filepath.Base(exename) + ".log"
filename = filepath.Join(logdir,filename)
filename = filepath.Join(logdir, filename)
}

globals.InitializeLog(l.Stdout(), &lumberjack.Logger{
Expand Down Expand Up @@ -860,9 +860,7 @@ restart_loop:
mempool_tx_count := len(chain.Mempool.Mempool_List_TX())
regpool_tx_count := len(chain.Regpool.Regpool_List_TX())

supply := uint64(0)

supply = (config.PREMINE + blockchain.CalcBlockReward(uint64(chain.Get_Height()))*uint64(chain.Get_Height())) // valid for few years
supply := blockchain.CalcSupply(uint64(chain.Get_Height()))

hostname, _ := os.Hostname()
fmt.Printf("STATUS MENU for DERO HE Node - Hostname: %s\n\n", hostname)
Expand Down
4 changes: 2 additions & 2 deletions cmd/derod/rpc/rpc_dero_getinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ func GetInfo(ctx context.Context) (result rpc.GetInfo_Result, err error) {
//result.Dynamic_fee_per_kb = config.FEE_PER_KB
//result.Median_Block_Size = config.CRYPTONOTE_MAX_BLOCK_SIZE

result.Total_Supply = (config.PREMINE + blockchain.CalcBlockReward(uint64(result.TopoHeight))*uint64(result.TopoHeight)) // valid for few years
result.Total_Supply = result.Total_Supply / 100000 // only give deros remove fractional part
result.Total_Supply = blockchain.CalcSupply(uint64(chain.Get_Height()))
result.Total_Supply = result.Total_Supply / 100000 // only give deros remove fractional part

if globals.Config.Name != config.Mainnet.Name { // anything other than mainnet is testnet at this point in time
result.Testnet = true
Expand Down