aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain/block.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-06-17 00:25:24 +0800
committerobscuren <geffobscura@gmail.com>2014-06-17 00:25:24 +0800
commit5a0e75173626704c3d58be582dff318218569ef3 (patch)
tree801ec6d33fe21e46230a3082cd069534f64aa251 /ethchain/block.go
parent006ac772e6c81271a84ff56e00527b2adbc0129c (diff)
parentff0f15f7634ca713b0ce8232a8fa63eec5c3fad7 (diff)
downloaddexon-5a0e75173626704c3d58be582dff318218569ef3.tar.gz
dexon-5a0e75173626704c3d58be582dff318218569ef3.tar.zst
dexon-5a0e75173626704c3d58be582dff318218569ef3.zip
Merge branch 'release/0.5.13'
Diffstat (limited to 'ethchain/block.go')
-rw-r--r--ethchain/block.go30
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")...))