clockmap

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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