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 }