core: set free GAS limit via config

This commit is contained in:
Evgenii Stratonikov 2020-01-21 16:39:48 +03:00
parent 54e0b5a4a7
commit 303b82cc44
4 changed files with 7 additions and 3 deletions

View file

@ -54,6 +54,8 @@ type (
VerifyBlocks bool `yaml:"VerifyBlocks"` VerifyBlocks bool `yaml:"VerifyBlocks"`
// Whether to verify transactions in received blocks. // Whether to verify transactions in received blocks.
VerifyTransactions bool `yaml:"VerifyTransactions"` VerifyTransactions bool `yaml:"VerifyTransactions"`
// FreeGasLimit is an amount of GAS which can be spent for free.
FreeGasLimit util.Fixed8 `yaml:"FreeGasLimit"`
} }
// SystemFee fees related to system. // SystemFee fees related to system.

View file

@ -29,6 +29,7 @@ ProtocolConfiguration:
RegisterTransaction: 10000 RegisterTransaction: 10000
VerifyBlocks: true VerifyBlocks: true
VerifyTransactions: false VerifyTransactions: false
FreeGasLimit: 10.0
ApplicationConfiguration: ApplicationConfiguration:
# LogPath could be set up in case you need stdout logs to some proper file. # LogPath could be set up in case you need stdout logs to some proper file.

View file

@ -29,6 +29,7 @@ ProtocolConfiguration:
RegisterTransaction: 100 RegisterTransaction: 100
VerifyBlocks: true VerifyBlocks: true
VerifyTransactions: false VerifyTransactions: false
FreeGasLimit: 10.0
ApplicationConfiguration: ApplicationConfiguration:
# LogPath could be set up in case you need stdout logs to some proper file. # LogPath could be set up in case you need stdout logs to some proper file.

View file

@ -515,9 +515,9 @@ func (bc *Blockchain) storeBlock(block *block.Block) error {
v.SetCheckedHash(tx.VerificationHash().BytesBE()) v.SetCheckedHash(tx.VerificationHash().BytesBE())
v.LoadScript(t.Script) v.LoadScript(t.Script)
v.SetPriceGetter(getPrice) v.SetPriceGetter(getPrice)
if bc.config.FreeGasLimit >= 0 {
gasAmount := util.Fixed8FromInt64(10) + t.Gas v.SetGasLimit(bc.config.FreeGasLimit + t.Gas)
v.SetGasLimit(gasAmount) }
err := v.Run() err := v.Run()
if !v.HasFailed() { if !v.HasFailed() {