mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-12 21:01:21 +00:00
uint* to int* whereever appropriate; https://www.reddit.com/r/golang/comments/2q5vdu/int_vs_uint/
This commit is contained in:
@ -44,7 +44,7 @@ func execBlock(s *State, block *types.Block, blockPartsHeader types.PartSetHeade
|
||||
return errors.New("Block at height 1 (first block) should have no LastValidation precommits")
|
||||
}
|
||||
} else {
|
||||
if uint(len(block.LastValidation.Precommits)) != s.LastBondedValidators.Size() {
|
||||
if len(block.LastValidation.Precommits) != s.LastBondedValidators.Size() {
|
||||
return errors.New(Fmt("Invalid block validation size. Expected %v, got %v",
|
||||
s.LastBondedValidators.Size(), len(block.LastValidation.Precommits)))
|
||||
}
|
||||
@ -60,7 +60,7 @@ func execBlock(s *State, block *types.Block, blockPartsHeader types.PartSetHeade
|
||||
if precommit == nil {
|
||||
continue
|
||||
}
|
||||
_, val := s.LastBondedValidators.GetByIndex(uint(i))
|
||||
_, val := s.LastBondedValidators.GetByIndex(i)
|
||||
if val == nil {
|
||||
panic(Fmt("Failed to fetch validator at index %v", i))
|
||||
}
|
||||
@ -101,7 +101,7 @@ func execBlock(s *State, block *types.Block, blockPartsHeader types.PartSetHeade
|
||||
// If any unbonding periods are over,
|
||||
// reward account with bonded coins.
|
||||
toRelease := []*Validator{}
|
||||
s.UnbondingValidators.Iterate(func(index uint, val *Validator) bool {
|
||||
s.UnbondingValidators.Iterate(func(index int, val *Validator) bool {
|
||||
if val.UnbondHeight+unbondingPeriodBlocks < block.Height {
|
||||
toRelease = append(toRelease, val)
|
||||
}
|
||||
@ -114,8 +114,8 @@ func execBlock(s *State, block *types.Block, blockPartsHeader types.PartSetHeade
|
||||
// If any validators haven't signed in a while,
|
||||
// unbond them, they have timed out.
|
||||
toTimeout := []*Validator{}
|
||||
s.BondedValidators.Iterate(func(index uint, val *Validator) bool {
|
||||
lastActivityHeight := MaxUint(val.BondHeight, val.LastCommitHeight)
|
||||
s.BondedValidators.Iterate(func(index int, val *Validator) bool {
|
||||
lastActivityHeight := MaxInt(val.BondHeight, val.LastCommitHeight)
|
||||
if lastActivityHeight+validatorTimeoutBlocks < block.Height {
|
||||
log.Info("Validator timeout", "validator", val, "height", block.Height)
|
||||
toTimeout = append(toTimeout, val)
|
||||
@ -191,7 +191,7 @@ func checkInputPubKey(acc *account.Account, in *types.TxInput) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateInputs(accounts map[string]*account.Account, signBytes []byte, ins []*types.TxInput) (total uint64, err error) {
|
||||
func validateInputs(accounts map[string]*account.Account, signBytes []byte, ins []*types.TxInput) (total int64, err error) {
|
||||
for _, in := range ins {
|
||||
acc := accounts[string(in.Address)]
|
||||
if acc == nil {
|
||||
@ -219,8 +219,8 @@ func validateInput(acc *account.Account, signBytes []byte, in *types.TxInput) (e
|
||||
// Check sequences
|
||||
if acc.Sequence+1 != in.Sequence {
|
||||
return types.ErrTxInvalidSequence{
|
||||
Got: uint64(in.Sequence),
|
||||
Expected: uint64(acc.Sequence + 1),
|
||||
Got: in.Sequence,
|
||||
Expected: acc.Sequence + 1,
|
||||
}
|
||||
}
|
||||
// Check amount
|
||||
@ -230,7 +230,7 @@ func validateInput(acc *account.Account, signBytes []byte, in *types.TxInput) (e
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateOutputs(outs []*types.TxOutput) (total uint64, err error) {
|
||||
func validateOutputs(outs []*types.TxOutput) (total int64, err error) {
|
||||
for _, out := range outs {
|
||||
// Check TxOutput basic
|
||||
if err := out.ValidateBasic(); err != nil {
|
||||
@ -271,7 +271,7 @@ func adjustByOutputs(accounts map[string]*account.Account, outs []*types.TxOutpu
|
||||
func ExecTx(blockCache *BlockCache, tx_ types.Tx, runCall bool, evc events.Fireable) error {
|
||||
|
||||
// TODO: do something with fees
|
||||
fees := uint64(0)
|
||||
fees := int64(0)
|
||||
_s := blockCache.State() // hack to access validators and block height
|
||||
|
||||
// Exec tx
|
||||
@ -362,14 +362,14 @@ func ExecTx(blockCache *BlockCache, tx_ types.Tx, runCall bool, evc events.Firea
|
||||
if runCall {
|
||||
|
||||
var (
|
||||
gas uint64 = tx.GasLimit
|
||||
gas int64 = tx.GasLimit
|
||||
err error = nil
|
||||
caller *vm.Account = toVMAccount(inAcc)
|
||||
callee *vm.Account = nil
|
||||
code []byte = nil
|
||||
txCache = NewTxCache(blockCache)
|
||||
params = vm.Params{
|
||||
BlockHeight: uint64(_s.LastBlockHeight),
|
||||
BlockHeight: int64(_s.LastBlockHeight),
|
||||
BlockHash: LeftPadWord256(_s.LastBlockHash),
|
||||
BlockTime: _s.LastBlockTime.Unix(),
|
||||
GasLimit: 10000000,
|
||||
@ -490,8 +490,8 @@ func ExecTx(blockCache *BlockCache, tx_ types.Tx, runCall bool, evc events.Firea
|
||||
|
||||
// let's say cost of a name for one block is len(data) + 32
|
||||
costPerBlock := types.NameCostPerBlock * types.NameCostPerByte * tx.BaseEntryCost()
|
||||
expiresIn := value / uint64(costPerBlock)
|
||||
lastBlockHeight := uint64(_s.LastBlockHeight)
|
||||
expiresIn := int(value / costPerBlock)
|
||||
lastBlockHeight := _s.LastBlockHeight
|
||||
|
||||
log.Debug("New NameTx", "value", value, "costPerBlock", costPerBlock, "expiresIn", expiresIn, "lastBlock", lastBlockHeight)
|
||||
|
||||
@ -530,9 +530,9 @@ func ExecTx(blockCache *BlockCache, tx_ types.Tx, runCall bool, evc events.Firea
|
||||
} else {
|
||||
// since the size of the data may have changed
|
||||
// we use the total amount of "credit"
|
||||
oldCredit := (entry.Expires - lastBlockHeight) * types.BaseEntryCost(entry.Name, entry.Data)
|
||||
oldCredit := int64(entry.Expires-lastBlockHeight) * types.BaseEntryCost(entry.Name, entry.Data)
|
||||
credit := oldCredit + value
|
||||
expiresIn = credit / costPerBlock
|
||||
expiresIn = int(credit / costPerBlock)
|
||||
if expiresIn < types.MinNameRegistrationPeriod {
|
||||
return fmt.Errorf("Names must be registered for at least %d blocks", types.MinNameRegistrationPeriod)
|
||||
}
|
||||
|
Reference in New Issue
Block a user