Skip to content

About

An Ethereum Wallclock Go package

Resources

Stars

2 stars

Watchers

1 watching

Forks

Repository files navigation

EthWallclock

Go Report Card Release License: GPL v3

An Ethereum Wallclock Go package

Installation

go get github.com/ethpandaops/ethwallclock

Usage

package main

import (
  "fmt"
  "time"

  "github.com/ethpandaops/ethwallclock"
)
 
func main() {
  genesisTime, _ := time.Parse(time.RFC3339, "2020-01-01T12:00:23Z")

  wallclock := ethwallclock.NewEthereumBeaconChain(genesisTime, 12*time.Second, 32)

  slot, epoch, err := wallclock.Now()
  if err != nil {
    panic(err)
  }

  fmt.Println("Slot: ", slot)
  fmt.Println("Epoch: ", epoch)
}

Slot duration change at Heze

Heze changes the slot duration from SLOT_DURATION_MS to SLOT_DURATION_MS_HEZE at HEZE_FORK_EPOCH. Pass both from the beacon spec; slot/epoch numbers, time windows and the OnSlotChanged/OnEpochChanged callbacks follow the change.

wallclock := ethwallclock.NewEthereumBeaconChain(genesisTime, 12*time.Second, 32,
  ethwallclock.WithHezeSlotDuration(hezeForkEpoch, 9*time.Second),
)

About

An Ethereum Wallclock Go package

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages