-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add chain_config system contract, add upMaxBlockSize and upGasPrice f…
…unc (#461)
- Loading branch information
1 parent
d92f6fa
commit b2d87a2
Showing
14 changed files
with
341 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package base | ||
|
||
type UpdateCfgManger interface{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package chain_config | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/xuperchain/xupercore/kernel/common/xcontext" | ||
"github.com/xuperchain/xupercore/kernel/contract" | ||
"github.com/xuperchain/xupercore/kernel/contract/proposal/utils" | ||
"github.com/xuperchain/xupercore/kernel/engines/xuperos/common" | ||
"github.com/xuperchain/xupercore/kernel/ledger" | ||
"github.com/xuperchain/xupercore/lib/logs" | ||
"github.com/xuperchain/xupercore/lib/timer" | ||
"github.com/xuperchain/xupercore/protos" | ||
) | ||
|
||
type LedgerRely interface { | ||
GetTipXMSnapshotReader() (ledger.XMSnapshotReader, error) | ||
} | ||
|
||
type ChainConfigCtx struct { | ||
xcontext.BaseCtx | ||
BcName string | ||
Contract contract.Manager | ||
ChainCtx *common.ChainCtx | ||
OldGasPrice *protos.GasPrice | ||
OldMaxBlockSize int64 | ||
} | ||
|
||
func NewChainConfigCtx(chainCtx *common.ChainCtx) (*ChainConfigCtx, error) { | ||
if chainCtx.BCName == "" || chainCtx.Contract == nil { | ||
return nil, NewChainConfigCtxErr | ||
} | ||
|
||
log, err := logs.NewLogger("", utils.ChainConfigKernelContract) | ||
if err != nil { | ||
return nil, fmt.Errorf("new updateConfig ctx faild because new logger error. err: %v", err) | ||
} | ||
meta := chainCtx.State.GetMeta() | ||
ctx := new(ChainConfigCtx) | ||
ctx.XLog = log | ||
ctx.Timer = timer.NewXTimer() | ||
ctx.BcName = chainCtx.BCName | ||
ctx.Contract = chainCtx.Contract | ||
ctx.ChainCtx = chainCtx | ||
ctx.OldGasPrice = meta.GetGasPrice() | ||
ctx.OldMaxBlockSize = meta.GetMaxBlockSize() | ||
return ctx, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package chain_config | ||
|
||
import "errors" | ||
|
||
var ( | ||
NewChainConfigCtxErr = errors.New("new updateConfig ctx faild because param error") | ||
) |
Oops, something went wrong.