re: Added contract fees
This commit is contained in:
parent
ed05779adb
commit
06ea7fc830
|
@ -336,19 +336,23 @@ out:
|
||||||
op := OpCode(o)
|
op := OpCode(o)
|
||||||
|
|
||||||
var fee *big.Int = new(big.Int)
|
var fee *big.Int = new(big.Int)
|
||||||
|
var fee2 *big.Int = new(big.Int)
|
||||||
if stepcount > 16 {
|
if stepcount > 16 {
|
||||||
fee.Add(fee, StepFee)
|
fee.Add(fee, StepFee)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate the fees
|
// Calculate the fees
|
||||||
switch op {
|
switch op {
|
||||||
/*
|
case oSSTORE:
|
||||||
FIXME (testnet requires no funds yet)
|
y, x := bm.stack.Peekn()
|
||||||
case oSSTORE:
|
val := contract.Addr(ethutil.BigToBytes(x, 256))
|
||||||
fee.Add(fee, StoreFee)
|
if val.IsEmpty() && len(y.Bytes()) > 0 {
|
||||||
case oSLOAD:
|
fee2.Add(DataFee, StoreFee)
|
||||||
fee.Add(fee, StoreFee)
|
} else {
|
||||||
*/
|
fee2.Sub(DataFee, StoreFee)
|
||||||
|
}
|
||||||
|
case oSLOAD:
|
||||||
|
fee.Add(fee, StoreFee)
|
||||||
case oEXTRO, oBALANCE:
|
case oEXTRO, oBALANCE:
|
||||||
fee.Add(fee, ExtroFee)
|
fee.Add(fee, ExtroFee)
|
||||||
case oSHA256, oRIPEMD160, oECMUL, oECADD, oECSIGN, oECRECOVER, oECVALID:
|
case oSHA256, oRIPEMD160, oECMUL, oECADD, oECSIGN, oECRECOVER, oECVALID:
|
||||||
|
@ -357,11 +361,12 @@ out:
|
||||||
fee.Add(fee, ContractFee)
|
fee.Add(fee, ContractFee)
|
||||||
}
|
}
|
||||||
|
|
||||||
if contract.Amount.Cmp(fee) < 0 {
|
tf := new(big.Int).Add(fee, fee2)
|
||||||
|
if contract.Amount.Cmp(tf) < 0 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
// Add the fee to the total fee. It's subtracted when we're done looping
|
// Add the fee to the total fee. It's subtracted when we're done looping
|
||||||
totalFee.Add(totalFee, fee)
|
totalFee.Add(totalFee, tf)
|
||||||
|
|
||||||
if !cb(0) {
|
if !cb(0) {
|
||||||
break
|
break
|
||||||
|
@ -608,9 +613,10 @@ out:
|
||||||
case oSSTORE:
|
case oSSTORE:
|
||||||
// Store Y at index X
|
// Store Y at index X
|
||||||
y, x := bm.stack.Popn()
|
y, x := bm.stack.Popn()
|
||||||
idx := ethutil.BigToBytes(x, 256)
|
addr := ethutil.BigToBytes(x, 256)
|
||||||
fmt.Printf(" => %x (%v) @ %v", y.Bytes(), y, ethutil.BigD(idx))
|
fmt.Printf(" => %x (%v) @ %v", y.Bytes(), y, ethutil.BigD(addr))
|
||||||
contract.State().Update(string(idx), string(y.Bytes()))
|
contract.SetAddr(addr, y)
|
||||||
|
//contract.State().Update(string(idx), string(y))
|
||||||
case oJMP:
|
case oJMP:
|
||||||
x := int(bm.stack.Pop().Uint64())
|
x := int(bm.stack.Pop().Uint64())
|
||||||
// Set pc to x - 1 (minus one so the incrementing at the end won't effect it)
|
// Set pc to x - 1 (minus one so the incrementing at the end won't effect it)
|
||||||
|
|
Loading…
Reference in New Issue