Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // Permutation returns a random permutation of [0‥n) that is used to // query servers in a random order. If nil, a sensible default is used. Permutation func(n int) []int // MaxRadiusUs is the maximum interval radius that will be accepted // from a server. If zero, a sensible default is used. MaxRadius time.Duration // MaxDifference is the maximum difference in time between any sample // from a server and the quorum-agreed time before that sample is // considered suspect. If zero, a sensible default is used. MaxDifference time.Duration // QueryTimeout is the amount of time a server has to reply to a query. // If zero, a sensible default will be used. QueryTimeout time.Duration // NumQueries is the maximum number of times a query will be sent to a // specific server before giving up. If <= zero, a sensible default // will be used. NumQueries int // contains filtered or unexported fields }
Client represents a Roughtime client and exposes a number of members that can be set in order to configure it. The zero value of a Client is always ready to use and will set sensible defaults.
func (*Client) EstablishTime ¶
func (c *Client) EstablishTime(chain *config.Chain, quorum int, servers []config.Server, localAddr *snet.Addr) (TimeResult, error)
EstablishTime queries a number of servers until it has a quorum of overlapping results, or it runs out of servers. Results from the querying the servers are appended to chain. TODO: Save local snet addr in Client object, remove from arguments
type ServerInfo ¶
type ServerInfo struct { // QueryDuration is the amount of time that the server took to answer. QueryDuration time.Duration // Min and Max specify the time window given by the server. These // values have been adjusted so that they are comparible across // servers, even though they are queried at different times. Min, Max *big.Int }
ServerInfo contains information from a specific server.
type TimeResult ¶
type TimeResult struct { // MonoUTCDelta may be nil, in which case a time could not be // established. Otherwise it contains the difference between the // Roughtime epoch and the monotonic clock. MonoUTCDelta *time.Duration // ServerErrors maps from server name to query error. ServerErrors map[string]error // ServerInfo contains information about each server that was queried. ServerInfo map[string]ServerInfo // OutOfRangeAnswer is true if one or more of the queries contained a // significantly incorrect time, as defined by MaxDifference. In this // case, the reply will have been recorded in the chain. OutOfRangeAnswer bool // Overlapping midpoint time from server replies Midpoint *big.Int }
TimeResult is the result of trying to establish the current time by querying a number of servers.
Click to show internal directories.
Click to hide internal directories.