Merge pull request #2287 from flicker-harmony/pr_supply

Supply
pull/2297/head
Minh Doan 5 years ago committed by GitHub
commit df525d69df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      internal/hmyapi/apiv1/blockchain.go
  2. 14
      internal/hmyapi/apiv2/blockchain.go

@ -14,6 +14,7 @@ import (
"github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/bls/ffi/go/bls"
"github.com/harmony-one/harmony/common/denominations" "github.com/harmony-one/harmony/common/denominations"
"github.com/harmony-one/harmony/consensus/quorum" "github.com/harmony-one/harmony/consensus/quorum"
"github.com/harmony-one/harmony/consensus/reward"
"github.com/harmony-one/harmony/core" "github.com/harmony-one/harmony/core"
"github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/core/vm" "github.com/harmony-one/harmony/core/vm"
@ -21,6 +22,7 @@ import (
internal_common "github.com/harmony-one/harmony/internal/common" internal_common "github.com/harmony-one/harmony/internal/common"
"github.com/harmony-one/harmony/internal/params" "github.com/harmony-one/harmony/internal/params"
"github.com/harmony-one/harmony/internal/utils" "github.com/harmony-one/harmony/internal/utils"
"github.com/harmony-one/harmony/numeric"
"github.com/harmony-one/harmony/shard" "github.com/harmony-one/harmony/shard"
"github.com/harmony-one/harmony/staking/network" "github.com/harmony-one/harmony/staking/network"
staking "github.com/harmony-one/harmony/staking/types" staking "github.com/harmony-one/harmony/staking/types"
@ -31,6 +33,7 @@ const (
defaultFromAddress = "0x0000000000000000000000000000000000000000" defaultFromAddress = "0x0000000000000000000000000000000000000000"
defaultBlocksPeriod = 15000 defaultBlocksPeriod = 15000
validatorsPageSize = 100 validatorsPageSize = 100
initSupply = int64(12600000000)
) )
// PublicBlockChainAPI provides an API to access the Harmony blockchain. // PublicBlockChainAPI provides an API to access the Harmony blockchain.
@ -799,3 +802,14 @@ func (s *PublicBlockChainAPI) GetSuperCommittees() (*quorum.Transition, error) {
} }
return nil, errNotBeaconChainShard return nil, errNotBeaconChainShard
} }
// GetTotalSupply ..
func (s *PublicBlockChainAPI) GetTotalSupply() numeric.Dec {
return numeric.NewDec(initSupply)
}
// GetCirculatingSupply ..
func (s *PublicBlockChainAPI) GetCirculatingSupply() numeric.Dec {
timestamp := time.Now()
return numeric.NewDec(initSupply).Mul(reward.PercentageForTimeStamp(timestamp.Unix()))
}

@ -14,6 +14,7 @@ import (
"github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/bls/ffi/go/bls"
"github.com/harmony-one/harmony/common/denominations" "github.com/harmony-one/harmony/common/denominations"
"github.com/harmony-one/harmony/consensus/quorum" "github.com/harmony-one/harmony/consensus/quorum"
"github.com/harmony-one/harmony/consensus/reward"
"github.com/harmony-one/harmony/core" "github.com/harmony-one/harmony/core"
"github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/core/vm" "github.com/harmony-one/harmony/core/vm"
@ -21,6 +22,7 @@ import (
internal_common "github.com/harmony-one/harmony/internal/common" internal_common "github.com/harmony-one/harmony/internal/common"
"github.com/harmony-one/harmony/internal/params" "github.com/harmony-one/harmony/internal/params"
"github.com/harmony-one/harmony/internal/utils" "github.com/harmony-one/harmony/internal/utils"
"github.com/harmony-one/harmony/numeric"
"github.com/harmony-one/harmony/shard" "github.com/harmony-one/harmony/shard"
"github.com/harmony-one/harmony/staking/network" "github.com/harmony-one/harmony/staking/network"
staking "github.com/harmony-one/harmony/staking/types" staking "github.com/harmony-one/harmony/staking/types"
@ -31,6 +33,7 @@ const (
defaultFromAddress = "0x0000000000000000000000000000000000000000" defaultFromAddress = "0x0000000000000000000000000000000000000000"
defaultBlocksPeriod = 15000 defaultBlocksPeriod = 15000
validatorsPageSize = 100 validatorsPageSize = 100
initSupply = int64(12600000000)
) )
// PublicBlockChainAPI provides an API to access the Harmony blockchain. // PublicBlockChainAPI provides an API to access the Harmony blockchain.
@ -764,3 +767,14 @@ func (s *PublicBlockChainAPI) GetSuperCommittees() (*quorum.Transition, error) {
} }
return nil, errNotBeaconChainShard return nil, errNotBeaconChainShard
} }
// GetTotalSupply ..
func (s *PublicBlockChainAPI) GetTotalSupply() numeric.Dec {
return numeric.NewDec(initSupply)
}
// GetCirculatingSupply ..
func (s *PublicBlockChainAPI) GetCirculatingSupply() numeric.Dec {
timestamp := time.Now()
return numeric.NewDec(initSupply).Mul(reward.PercentageForTimeStamp(timestamp.Unix()))
}

Loading…
Cancel
Save