diff options
author | obscuren <geffobscura@gmail.com> | 2014-06-17 00:25:24 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-06-17 00:25:24 +0800 |
commit | 5a0e75173626704c3d58be582dff318218569ef3 (patch) | |
tree | 801ec6d33fe21e46230a3082cd069534f64aa251 /ethchain/block.go | |
parent | 006ac772e6c81271a84ff56e00527b2adbc0129c (diff) | |
parent | ff0f15f7634ca713b0ce8232a8fa63eec5c3fad7 (diff) | |
download | go-tangerine-5a0e75173626704c3d58be582dff318218569ef3.tar go-tangerine-5a0e75173626704c3d58be582dff318218569ef3.tar.gz go-tangerine-5a0e75173626704c3d58be582dff318218569ef3.tar.bz2 go-tangerine-5a0e75173626704c3d58be582dff318218569ef3.tar.lz go-tangerine-5a0e75173626704c3d58be582dff318218569ef3.tar.xz go-tangerine-5a0e75173626704c3d58be582dff318218569ef3.tar.zst go-tangerine-5a0e75173626704c3d58be582dff318218569ef3.zip |
Merge branch 'release/0.5.13'
Diffstat (limited to 'ethchain/block.go')
-rw-r--r-- | ethchain/block.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/ethchain/block.go b/ethchain/block.go index 73e29f878..fee4a2d59 100644 --- a/ethchain/block.go +++ b/ethchain/block.go @@ -154,6 +154,36 @@ func (block *Block) PayFee(addr []byte, fee *big.Int) bool { return true } +func (block *Block) CalcGasLimit(parent *Block) *big.Int { + if block.Number.Cmp(big.NewInt(0)) == 0 { + return ethutil.BigPow(10, 6) + } + + previous := new(big.Int).Mul(big.NewInt(1023), parent.GasLimit) + current := new(big.Rat).Mul(new(big.Rat).SetInt(block.GasUsed), big.NewRat(6, 5)) + curInt := new(big.Int).Div(current.Num(), current.Denom()) + + result := new(big.Int).Add(previous, curInt) + result.Div(result, big.NewInt(1024)) + + min := ethutil.BigPow(10, 4) + + return ethutil.BigMax(min, result) + /* + base := new(big.Int) + base2 := new(big.Int) + parentGL := bc.CurrentBlock.GasLimit + parentUsed := bc.CurrentBlock.GasUsed + + base.Mul(parentGL, big.NewInt(1024-1)) + base2.Mul(parentUsed, big.NewInt(6)) + base2.Div(base2, big.NewInt(5)) + base.Add(base, base2) + base.Div(base, big.NewInt(1024)) + */ + +} + func (block *Block) BlockInfo() BlockInfo { bi := BlockInfo{} data, _ := ethutil.Config.Db.Get(append(block.Hash(), []byte("Info")...)) |