mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-25 21:17:16 +00:00
55 lines
1.3 KiB
Go
55 lines
1.3 KiB
Go
package params
|
|
|
|
import (
|
|
"context"
|
|
"math/big"
|
|
)
|
|
|
|
type configKey int
|
|
|
|
const (
|
|
IsHomesteadEnabled configKey = iota
|
|
IsEIP150Enabled
|
|
IsEIP155Enabled
|
|
IsEIP158Enabled
|
|
IsByzantiumEnabled
|
|
IsConstantinopleEnabled
|
|
IsPetersburgEnabled
|
|
BlockNumber
|
|
WithHistoryHighest
|
|
)
|
|
|
|
func (c *ChainConfig) WithEIPsFlags(ctx context.Context, blockNum uint64) context.Context {
|
|
ctx = context.WithValue(ctx, IsHomesteadEnabled, c.IsHomestead(blockNum))
|
|
ctx = context.WithValue(ctx, IsEIP150Enabled, c.IsEIP150(blockNum))
|
|
ctx = context.WithValue(ctx, IsEIP155Enabled, c.IsEIP155(blockNum))
|
|
ctx = context.WithValue(ctx, IsEIP158Enabled, c.IsEIP158(blockNum))
|
|
ctx = context.WithValue(ctx, IsByzantiumEnabled, c.IsByzantium(blockNum))
|
|
ctx = context.WithValue(ctx, IsConstantinopleEnabled, c.IsConstantinople(blockNum))
|
|
ctx = context.WithValue(ctx, IsPetersburgEnabled, c.IsPetersburg(blockNum))
|
|
ctx = context.WithValue(ctx, BlockNumber, blockNum)
|
|
return ctx
|
|
}
|
|
|
|
func GetForkFlag(ctx context.Context, name configKey) bool {
|
|
b := ctx.Value(name)
|
|
if b == nil {
|
|
return false
|
|
}
|
|
if valB, ok := b.(bool); ok {
|
|
return valB
|
|
}
|
|
return false
|
|
}
|
|
|
|
func GetBlockNumber(ctx context.Context) *big.Int {
|
|
b := ctx.Value(BlockNumber)
|
|
if b == nil {
|
|
return nil
|
|
}
|
|
if valB, ok := b.(*big.Int); ok {
|
|
return valB
|
|
}
|
|
return nil
|
|
}
|