> ## Documentation Index
> Fetch the complete documentation index at: https://solana.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> This page is part of the Solana developer documentation at https://solana.com/developers/docs. Append `.md` to any docs URL, or send `Accept: text/markdown`, to get the page as Markdown.
> Index of all pages: https://solana.com/llms.txt. Per-section indexes such as https://solana.com/developers/docs/payments/llms.txt are smaller; prefer them when working on one task.
> Coding agents: install the official Solana skill for current APIs and conventions with `npx skills add https://github.com/solana-foundation/solana-dev-skill` (also served at https://solana.com/SKILL.md).
> Code in the cookbook and task pages comes from tested example files. Prefer it over writing API calls from memory.

# Χρόνος & Sysvars

> Χειρισμός του ρολογιού και πρόσβαση σε sysvar στη Go

Μέθοδοι για τον χειρισμό του χρόνου και την πρόσβαση σε μεταβλητές συστήματος. Κάθε getter ενός sysvar
έχει αντίστοιχο setter. Οι τύποι προέρχονται από το πακέτο
[`github.com/gagliardetto/solana-go/sysvar`](https://pkg.go.dev/github.com/gagliardetto/solana-go/sysvar)
(εισάγεται ως `sysvar`), και οι getters επιστρέφουν δείκτες (ή slices) που
μπορείτε να τροποποιήσετε και να περάσετε πίσω στον setter.

## Χειρισμός ρολογιού

### WarpToSlot

```go
func (s *LiteSVM) WarpToSlot(slot uint64) error
```

Προωθεί το εσωτερικό ρολόι σε ένα συγκεκριμένο slot.

```go
before, err := svm.Clock()
if err != nil {
    t.Fatal(err)
}
t.Logf("current slot: %d", before.Slot)

if err := svm.WarpToSlot(10_000_000); err != nil {
    t.Fatal(err)
}

after, err := svm.Clock()
if err != nil {
    t.Fatal(err)
}
t.Logf("new slot:     %d", after.Slot)
```

### Clock

```go
// sysvar is github.com/gagliardetto/solana-go/sysvar
type Clock struct {
    Slot                uint64
    EpochStartTimestamp int64
    Epoch               uint64
    LeaderScheduleEpoch uint64
    UnixTimestamp       int64
}

func (s *LiteSVM) Clock() (*sysvar.Clock, error)
```

Διαβάζει το sysvar Clock.

```go
c, err := svm.Clock()
if err != nil {
    t.Fatal(err)
}
t.Logf("slot=%d epoch=%d unix=%d", c.Slot, c.Epoch, c.UnixTimestamp)
```

### SetClock

```go
func (s *LiteSVM) SetClock(c *sysvar.Clock) error
```

Αντικαθιστά το sysvar Clock. Διαβάστε το, τροποποιήστε τα πεδία και γράψτε το ξανά όταν χρειάζεστε
έλεγχο των `Epoch` ή `UnixTimestamp` (τα οποία το `WarpToSlot` δεν ενημερώνει).

```go
c, err := svm.Clock()
if err != nil {
    t.Fatal(err)
}
c.Slot = 1_000
c.Epoch = 10
c.UnixTimestamp = 1_735_689_600
if err := svm.SetClock(c); err != nil {
    t.Fatal(err)
}
```

<Info>
  Το `WarpToSlot` ενημερώνει μόνο το `Slot`. Χρησιμοποιήστε το `SetClock` όταν το πρόγραμμά σας διαβάζει
  `Epoch` ή `UnixTimestamp` από το sysvar Clock.
</Info>

## Rent

### Rent / SetRent

```go
type Rent struct {
    LamportsPerByte    uint64
    ExemptionThreshold float64
    BurnPercent        uint8
}

func (s *LiteSVM) Rent() (*sysvar.Rent, error)
func (s *LiteSVM) SetRent(r *sysvar.Rent) error
```

```go
r, err := svm.Rent()
if err != nil {
    t.Fatal(err)
}
t.Logf("lamports/byte: %d", r.LamportsPerByte)
t.Logf("exemption threshold: %.2f", r.ExemptionThreshold)
t.Logf("burn percent: %d", r.BurnPercent)
```

### MinimumBalanceForRentExemption

```go
func (s *LiteSVM) MinimumBalanceForRentExemption(dataLen int) (uint64, error)
```

```go
for _, size := range []int{0, 100, 1024} {
    min, err := svm.MinimumBalanceForRentExemption(size)
    if err != nil {
        t.Fatal(err)
    }
    t.Logf("%4d bytes -> %d lamports", size, min)
}
```

## Χρονοδιάγραμμα Epoch

```go
type EpochSchedule struct {
    SlotsPerEpoch            uint64
    LeaderScheduleSlotOffset uint64
    Warmup                   bool
    FirstNormalEpoch         uint64
    FirstNormalSlot          uint64
}

func (s *LiteSVM) EpochSchedule() (*sysvar.EpochSchedule, error)
func (s *LiteSVM) SetEpochSchedule(e *sysvar.EpochSchedule) error
```

```go
es, err := svm.EpochSchedule()
if err != nil {
    t.Fatal(err)
}
t.Logf("slots per epoch: %d", es.SlotsPerEpoch)
t.Logf("first normal epoch: %d", es.FirstNormalEpoch)
t.Logf("first normal slot:  %d", es.FirstNormalSlot)
```

## Ανταμοιβές Epoch

```go
type EpochRewards struct {
    DistributionStartingBlockHeight uint64
    NumPartitions                   uint64
    ParentBlockhash                 solana.Hash
    TotalPoints                     bin.Uint128 // u128 total_points
    TotalRewards                    uint64
    DistributedRewards              uint64
    Active                          bool
}

func (s *LiteSVM) EpochRewards() (*sysvar.EpochRewards, error)
func (s *LiteSVM) SetEpochRewards(e *sysvar.EpochRewards) error
```

Το `total_points` είναι `u128` στην πλευρά του Solana και εκτίθεται ως
`bin.Uint128` (από το `github.com/gagliardetto/binary`) με μισά `Lo` και `Hi`.

## Πληροφορίες Slot

### LastRestartSlot / SetLastRestartSlot

```go
type LastRestartSlot struct {
    LastRestartSlot uint64
}

func (s *LiteSVM) LastRestartSlot() (*sysvar.LastRestartSlot, error)
func (s *LiteSVM) SetLastRestartSlot(l *sysvar.LastRestartSlot) error
```

```go
last, err := svm.LastRestartSlot()
if err != nil {
    t.Fatal(err)
}
if err := svm.SetLastRestartSlot(&sysvar.LastRestartSlot{LastRestartSlot: last.LastRestartSlot + 1}); err != nil {
    t.Fatal(err)
}
```

### SlotHashes / SetSlotHashes

```go
type SlotHash struct {
    Slot uint64
    Hash solana.Hash
}

type SlotHashes []SlotHash

func (s *LiteSVM) SlotHashes() (sysvar.SlotHashes, error)
func (s *LiteSVM) SetSlotHashes(items sysvar.SlotHashes) error
```

### SlotHistory

Το `SlotHistory` είναι ένα bitvec περίπου 128 KB. Το `sysvar.SlotHistory` είναι μια απλή τιμή Go, επομένως
δεν χρειάζεται να κλείσει τίποτα.

```go
sh := sysvar.NewSlotHistory()

sh.Add(42)

switch sh.Check(42) {
case sysvar.SlotHistoryFound:
    // ...
case sysvar.SlotHistoryNotFound:
    // ...
case sysvar.SlotHistoryTooOld:
    // ...
case sysvar.SlotHistoryFuture:
    // ...
}

if err := svm.SetSlotHistory(sh); err != nil {
    t.Fatal(err)
}
```

| Μέθοδος                                           | Περιγραφή                                |
| ------------------------------------------------ | ------------------------------------------ |
| `sysvar.NewSlotHistory() *sysvar.SlotHistory`    | Νέο ιστορικό slot                           |
| `sh.Add(slot uint64)`                            | Καταγράφει ένα slot                              |
| `sh.Check(slot uint64) SlotHistoryCheck`         | `Future` / `TooOld` / `Found` / `NotFound` |
| `sh.Oldest() uint64`                             | Παλαιότερο slot που παρακολουθείται                        |
| `sh.Newest() uint64`                             | Νεότερο slot που παρακολουθείται                        |
| `sh.NextSlot`                                    | Πεδίο: το επόμενο slot προς καταγραφή                 |
| `svm.SlotHistory() (*sysvar.SlotHistory, error)` | Ανάγνωση του sysvar                            |
| `svm.SetSlotHistory(*sysvar.SlotHistory) error`  | Εγκατάσταση στο SVM                         |

## Ιστορικό Stake

```go
type StakeHistoryEntry struct {
    Effective    uint64
    Activating   uint64
    Deactivating uint64
}

type StakeHistoryItem struct {
    Epoch uint64
    Entry StakeHistoryEntry
}

type StakeHistory []StakeHistoryItem

func (s *LiteSVM) StakeHistory() (sysvar.StakeHistory, error)
func (s *LiteSVM) SetStakeHistory(items sysvar.StakeHistory) error
```

## Δοκιμή λογικής που εξαρτάται από τον χρόνο

Χρησιμοποιήστε το `WarpToSlot` για απλή προώθηση βάσει slot και το `SetClock` για πλήρη έλεγχο:

```go
func TestTimeLockedVault(t *testing.T) {
    svm, err := litesvm.New()
    if err != nil {
        t.Fatal(err)
    }
    defer svm.Close()

    const unlockSlot = uint64(10_000)

    // Setup: create the time-locked account ...

    // Test 1: Try to withdraw before unlock (should fail)
    before, err := svm.Clock()
    if err != nil {
        t.Fatal(err)
    }
    t.Logf("current slot: %d", before.Slot)
    // ... attempt withdrawal, expect failure ...

    // Warp time forward past unlock slot
    if err := svm.WarpToSlot(unlockSlot + 1); err != nil {
        t.Fatal(err)
    }

    // Test 2: Try to withdraw after unlock (should succeed)
    after, err := svm.Clock()
    if err != nil {
        t.Fatal(err)
    }
    t.Logf("new slot: %d", after.Slot)
    // ... attempt withdrawal, expect success ...
}
```
