Merge pull request #955 from alajko/removeEther2

moving denominations under common
pull/956/head
alajko 6 years ago committed by GitHub
commit 09890f438b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      api/service/staking/service.go
  2. 2
      cmd/client/txgen/main.go
  3. 14
      cmd/client/wallet/main.go
  4. 8
      common/denominations/denominations.go
  5. 2
      consensus/consensus.go
  6. 32
      core/denominations/denominations.go
  7. 2
      core/genesis.go
  8. 4
      core/genesis_block_test.json
  9. 2
      core/genesis_util.go
  10. 2
      core/tx_pool_test.go
  11. 2
      internal/hmyapi/blockchain.go
  12. 2
      node/contract.go
  13. 2
      node/node_genesis.go
  14. 2
      node/worker/worker_test.go

@ -19,9 +19,9 @@ import (
proto_common "github.com/harmony-one/harmony/api/proto"
"github.com/harmony-one/harmony/api/proto/message"
msg_pb "github.com/harmony-one/harmony/api/proto/message"
"github.com/harmony-one/harmony/common/denominations"
"github.com/harmony-one/harmony/contracts"
"github.com/harmony-one/harmony/core"
"github.com/harmony-one/harmony/core/denominations"
"github.com/harmony-one/harmony/core/types"
hmykey "github.com/harmony-one/harmony/internal/keystore"
"github.com/harmony-one/harmony/internal/utils"

@ -22,7 +22,7 @@ import (
"github.com/harmony-one/harmony/api/client"
proto_node "github.com/harmony-one/harmony/api/proto/node"
"github.com/harmony-one/harmony/core/denominations"
"github.com/harmony-one/harmony/common/denominations"
"github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/crypto/bls"
nodeconfig "github.com/harmony-one/harmony/internal/configs/node"

@ -14,11 +14,11 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"github.com/harmony-one/harmony/api/client"
clientService "github.com/harmony-one/harmony/api/client/service"
proto_node "github.com/harmony-one/harmony/api/proto/node"
"github.com/harmony-one/harmony/common/denominations"
"github.com/harmony-one/harmony/core"
"github.com/harmony-one/harmony/core/types"
nodeconfig "github.com/harmony-one/harmony/internal/configs/node"
@ -432,14 +432,14 @@ func processTransferCommand() {
}
balance := state.balance
balance = balance.Div(balance, big.NewInt(params.GWei))
if amount > float64(balance.Uint64())/params.GWei {
fmt.Printf("Balance is not enough for the transfer, current balance is %.6f\n", float64(balance.Uint64())/params.GWei)
balance = balance.Div(balance, big.NewInt(denominations.Nano))
if amount > float64(balance.Uint64())/denominations.Nano {
fmt.Printf("Balance is not enough for the transfer, current balance is %.6f\n", float64(balance.Uint64())/denominations.Nano)
return
}
amountBigInt := big.NewInt(int64(amount * params.GWei))
amountBigInt = amountBigInt.Mul(amountBigInt, big.NewInt(params.GWei))
amountBigInt := big.NewInt(int64(amount * denominations.Nano))
amountBigInt = amountBigInt.Mul(amountBigInt, big.NewInt(denominations.Nano))
gas, err := core.IntrinsicGas(inputData, false, true)
if err != nil {
fmt.Printf("cannot calculate required gas: %v\n", err)
@ -474,7 +474,7 @@ func processTransferCommand() {
}
func convertBalanceIntoReadableFormat(balance *big.Int) string {
balance = balance.Div(balance, big.NewInt(params.GWei))
balance = balance.Div(balance, big.NewInt(denominations.Nano))
strBalance := fmt.Sprintf("%d", balance.Uint64())
bytes := []byte(strBalance)

@ -0,0 +1,8 @@
package denominations
//ONE Units
const (
Atto = 1
Nano = 1e9
One = 1e18
)

@ -9,9 +9,9 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/log"
"github.com/harmony-one/bls/ffi/go/bls"
"github.com/harmony-one/harmony/common/denominations"
consensus_engine "github.com/harmony-one/harmony/consensus/engine"
"github.com/harmony-one/harmony/contracts/structs"
"github.com/harmony-one/harmony/core/denominations"
"github.com/harmony-one/harmony/core/state"
"github.com/harmony-one/harmony/core/types"
bls_cosi "github.com/harmony-one/harmony/crypto/bls"

@ -1,32 +0,0 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
package denominations
// These are the multipliers for ether denominations.
// Example: To get the wei value of an amount in 'gwei', use
//
// new(big.Int).Mul(value, big.NewInt(params.GWei))
// These are the multipliers for ether denominations.
// Example: To get the wei value of an amount in 'gwei', use
//
// new(big.Int).Mul(value, big.NewInt(params.GWei))
//
const (
Wei = 1
GWei = 1e9
One = 1e18
)

@ -299,7 +299,7 @@ func (g *Genesis) MustCommit(db ethdb.Database) *types.Block {
return block
}
// GenesisBlockForTesting creates and writes a block in which addr has the given wei balance.
// GenesisBlockForTesting creates and writes a block in which addr has the given Nano balance.
func GenesisBlockForTesting(db ethdb.Database, addr common.Address, balance *big.Int) *types.Block {
g := Genesis{Alloc: GenesisAlloc{addr: {Balance: balance}}}
return g.MustCommit(db)

@ -1,8 +1,8 @@
{
"b7a2c103728b7305b5ae6e961c94ee99c9fe8e2b": {
"wei": "50000000000000000000000"
"nano": "50000000000000000000000"
},
"b498bb0f520005b6216a4425b75aa9adc52d622b": {
"wei": "4000000000000000000000"
"nano": "4000000000000000000000"
}
}

@ -54,7 +54,7 @@ func StringToBigInt(s string, base int) *big.Int {
func convertToGenesisItems(gc genesisConfig) []GenesisItem {
gi := []GenesisItem{}
for k, v := range gc {
gi = append(gi, GenesisItem{StringToBigInt(k, 16), StringToBigInt(v["wei"], 10)})
gi = append(gi, GenesisItem{StringToBigInt(k, 16), StringToBigInt(v["nano"], 10)})
}
sort.Slice(gi, func(i, j int) bool {
return gi[i].Addr.Cmp(gi[j].Addr) == -1

@ -31,7 +31,7 @@ import (
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/params"
"github.com/harmony-one/harmony/core/denominations"
"github.com/harmony-one/harmony/common/denominations"
"github.com/harmony-one/harmony/core/state"
"github.com/harmony-one/harmony/core/types"
)

@ -68,7 +68,7 @@ func (s *PublicBlockChainAPI) GetStorageAt(ctx context.Context, address common.A
return res[:], state.Error()
}
// GetBalance returns the amount of wei for the given address in the state of the
// GetBalance returns the amount of Nano for the given address in the state of the
// given block number. The rpc.LatestBlockNumber and rpc.PendingBlockNumber meta
// block numbers are also allowed.
func (s *PublicBlockChainAPI) GetBalance(ctx context.Context, address common.Address, blockNr rpc.BlockNumber) (*hexutil.Big, error) {

@ -12,9 +12,9 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"github.com/harmony-one/harmony/common/denominations"
"github.com/harmony-one/harmony/contracts"
"github.com/harmony-one/harmony/contracts/structs"
"github.com/harmony-one/harmony/core/denominations"
"github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/internal/utils"
contract_constants "github.com/harmony-one/harmony/internal/utils/contract"

@ -12,8 +12,8 @@ import (
"github.com/ethereum/go-ethereum/params"
"github.com/pkg/errors"
"github.com/harmony-one/harmony/common/denominations"
"github.com/harmony-one/harmony/core"
"github.com/harmony-one/harmony/core/denominations"
"github.com/harmony-one/harmony/core/rawdb"
"github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/internal/ctxerror"

@ -8,9 +8,9 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/params"
"github.com/harmony-one/harmony/common/denominations"
"github.com/harmony-one/harmony/consensus"
"github.com/harmony-one/harmony/core"
"github.com/harmony-one/harmony/core/denominations"
"github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/core/vm"
)

Loading…
Cancel
Save