forked from TrueCloudLab/neoneo-go
*: switch from fixed8 to int64 in (Blockchain).CalculateClaimable
This commit is contained in:
parent
73b630db9b
commit
0aaaf7f787
5 changed files with 10 additions and 10 deletions
|
@ -1062,8 +1062,8 @@ func (bc *Blockchain) UnsubscribeFromExecutions(ch chan<- *state.AppExecResult)
|
|||
// amount of NEO between specified blocks. The amount of NEO being passed is in
|
||||
// its natural non-divisible form (1 NEO as 1, 2 NEO as 2, no multiplication by
|
||||
// 10⁸ is neeeded as for Fixed8).
|
||||
func (bc *Blockchain) CalculateClaimable(value int64, startHeight, endHeight uint32) util.Fixed8 {
|
||||
var amount util.Fixed8
|
||||
func (bc *Blockchain) CalculateClaimable(value int64, startHeight, endHeight uint32) int64 {
|
||||
var amount int64
|
||||
di := uint32(bc.decrementInterval)
|
||||
|
||||
ustart := startHeight / di
|
||||
|
@ -1080,15 +1080,15 @@ func (bc *Blockchain) CalculateClaimable(value int64, startHeight, endHeight uin
|
|||
|
||||
istart := startHeight % di
|
||||
for ustart < uend {
|
||||
amount += util.Fixed8(di-istart) * util.Fixed8(bc.generationAmount[ustart])
|
||||
amount += int64(di-istart) * int64(bc.generationAmount[ustart])
|
||||
ustart++
|
||||
istart = 0
|
||||
}
|
||||
|
||||
amount += util.Fixed8(iend-istart) * util.Fixed8(bc.generationAmount[ustart])
|
||||
amount += int64(iend-istart) * int64(bc.generationAmount[ustart])
|
||||
}
|
||||
|
||||
return amount * util.Fixed8(value)
|
||||
return amount * value
|
||||
}
|
||||
|
||||
// FeePerByte returns transaction network fee per byte.
|
||||
|
|
|
@ -19,7 +19,7 @@ type Blockchainer interface {
|
|||
AddHeaders(...*block.Header) error
|
||||
AddBlock(*block.Block) error
|
||||
BlockHeight() uint32
|
||||
CalculateClaimable(value int64, startHeight, endHeight uint32) util.Fixed8
|
||||
CalculateClaimable(value int64, startHeight, endHeight uint32) int64
|
||||
Close()
|
||||
HeaderHeight() uint32
|
||||
GetBlock(hash util.Uint256) (*block.Block, error)
|
||||
|
|
|
@ -199,7 +199,7 @@ func (n *NEO) distributeGas(ic *interop.Context, h util.Uint160, acc *state.NEOB
|
|||
}
|
||||
gen := ic.Chain.CalculateClaimable(acc.Balance.Int64(), acc.BalanceHeight, ic.Block.Index)
|
||||
acc.BalanceHeight = ic.Block.Index
|
||||
n.GAS.mint(ic, h, big.NewInt(int64(gen)))
|
||||
n.GAS.mint(ic, h, big.NewInt(gen))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -213,7 +213,7 @@ func (n *NEO) unclaimedGas(ic *interop.Context, args []stackitem.Item) stackitem
|
|||
tr := bs.Trackers[n.Hash]
|
||||
|
||||
gen := ic.Chain.CalculateClaimable(tr.Balance, tr.LastUpdatedBlock, end)
|
||||
return stackitem.NewBigInteger(big.NewInt(int64(gen)))
|
||||
return stackitem.NewBigInteger(big.NewInt(gen))
|
||||
}
|
||||
|
||||
func (n *NEO) registerValidator(ic *interop.Context, args []stackitem.Item) stackitem.Item {
|
||||
|
|
|
@ -31,7 +31,7 @@ func (chain testChain) ApplyPolicyToTxSet([]*transaction.Transaction) []*transac
|
|||
func (chain testChain) GetConfig() config.ProtocolConfiguration {
|
||||
panic("TODO")
|
||||
}
|
||||
func (chain testChain) CalculateClaimable(int64, uint32, uint32) util.Fixed8 {
|
||||
func (chain testChain) CalculateClaimable(int64, uint32, uint32) int64 {
|
||||
panic("TODO")
|
||||
}
|
||||
|
||||
|
|
|
@ -787,7 +787,7 @@ func (s *Server) getUnclaimedGas(ps request.Params) (interface{}, *response.Erro
|
|||
return "0", nil
|
||||
}
|
||||
gas := s.chain.CalculateClaimable(neo, neoHeight, s.chain.BlockHeight()+1) // +1 as in C#, for the next block.
|
||||
return strconv.FormatInt(int64(gas), 10), nil // It's not represented as Fixed8 in C#.
|
||||
return strconv.FormatInt(gas, 10), nil
|
||||
}
|
||||
|
||||
// getValidators returns the current NEO consensus nodes information and voting status.
|
||||
|
|
Loading…
Reference in a new issue