clockmap

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package clockmap maps monotonic timestamps between WireHop peers.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidSample indicates an impossible four-timestamp clock sample.
	ErrInvalidSample = errors.New("invalid clock sample")
	// ErrTimestampOverflow indicates a timestamp outside safe signed arithmetic.
	ErrTimestampOverflow = errors.New("timestamp overflow")
)

Functions

This section is empty.

Types

type Mapping

type Mapping struct {
	OffsetMicros      int64
	UncertaintyMicros uint64
}

Mapping translates local monotonic timestamps into remote monotonic timestamps.

func Estimate

func Estimate(sample Sample) (Mapping, error)

Estimate derives a remote-minus-local mapping and uncertainty from sample.

func (Mapping) DeadlineBounds

func (m Mapping) DeadlineBounds(localDeadlineMicros uint64) (uint64, uint64, error)

DeadlineBounds returns the earliest and latest remote times supported for a local deadline.

func (Mapping) Inverse

func (m Mapping) Inverse() Mapping

Inverse returns the mapping from the former remote clock back to the local clock.

func (Mapping) Translate

func (m Mapping) Translate(localMicros uint64) (uint64, error)

Translate maps a local monotonic timestamp into the remote clock domain.

type Sample

type Sample struct {
	LocalSendMicros     uint64
	RemoteReceiveMicros uint64
	RemoteSendMicros    uint64
	LocalReceiveMicros  uint64
}

Sample is a four-timestamp exchange from one local clock to one remote clock.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL