Documentation ¶
Index ¶
- Variables
- type TxID
- func (x *TxID) Account() *URL
- func (x *TxID) AsUrl() *URL
- func (x *TxID) Compare(y *TxID) int
- func (x *TxID) Equal(y *TxID) bool
- func (x *TxID) Hash() [32]byte
- func (x *TxID) HashSlice() []byte
- func (x *TxID) MarshalJSON() ([]byte, error)
- func (x *TxID) RawString() string
- func (x *TxID) ShortString() string
- func (x *TxID) String() string
- func (x *TxID) UnmarshalJSON(data []byte) error
- type URL
- func (u *URL) AccountID() []byte
- func (u *URL) AccountID32() [32]byte
- func (u *URL) AsTxID() (*TxID, error)
- func (u *URL) Compare(v *URL) int
- func (u *URL) Equal(v *URL) bool
- func (u *URL) Hash() []byte
- func (u *URL) Hash32() [32]byte
- func (u *URL) Hostname() string
- func (u *URL) Identity() *URL
- func (u *URL) IdentityAccountID() []byte
- func (u *URL) IdentityAccountID32() [32]byte
- func (u *URL) IsRootIdentity() bool
- func (u *URL) JoinPath(s ...string) *URL
- func (u *URL) LocalTo(v *URL) bool
- func (u *URL) MarshalJSON() ([]byte, error)
- func (u *URL) Parent() (*URL, bool)
- func (u *URL) ParentOf(v *URL) bool
- func (u *URL) Password() string
- func (u *URL) PathEqual(v string) bool
- func (u *URL) Port() string
- func (u *URL) PrefixOf(v *URL) bool
- func (u *URL) QueryValues() Values
- func (u *URL) RawString() string
- func (u *URL) RootIdentity() *URL
- func (u *URL) Routing() uint64
- func (u *URL) ShortString() string
- func (u *URL) String() string
- func (u *URL) StripExtras() *URL
- func (u *URL) URL() *url.URL
- func (u *URL) UnmarshalJSON(data []byte) error
- func (u *URL) Username() string
- func (u *URL) ValidUTF8() bool
- func (u *URL) WithAuthority(s string) *URL
- func (u *URL) WithFragment(s string) *URL
- func (u *URL) WithPath(s string) *URL
- func (u *URL) WithQuery(s string) *URL
- func (u *URL) WithTxID(hash [32]byte) *TxID
- func (u *URL) WithUserInfo(s string) *URL
- type Values
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidHash = errors.New("invalid hash")
ErrInvalidHash means that a transaction ID did not include a valid hash.
var ErrMissingHash = errors.New("missing hash")
ErrMissingHash means that a transaction ID did not include a hash.
var ErrMissingHost = errors.New("missing host")
ErrMissingHost means that a URL did not include a hostname.
var ErrWrongScheme = errors.New("wrong scheme")
ErrWrongScheme means that a URL included a scheme other than the Accumulate scheme.
Functions ¶
This section is empty.
Types ¶
type TxID ¶
type TxID struct {
// contains filtered or unexported fields
}
TxID is a transaction identifier.
func MustParseTxID ¶
MustParseTxID calls ParseTxID and panics if it returns an error.
func ParseTxID ¶
ParseTxID parses the string as a URL and parses the URL's user info as a transaction hash.
func (*TxID) MarshalJSON ¶
MarshalJSON marshals the transaction ID to JSON as a string.
func (*TxID) RawString ¶
RawString reassembles the URL into a valid URL string without encoding any component.
func (*TxID) ShortString ¶
ShortString returns String without the scheme prefix.
func (*TxID) String ¶
String reassembles the transaction ID into a valid URL string. See net/url.URL.String().
func (*TxID) UnmarshalJSON ¶
UnmarshalJSON unmarshals the transaction ID from JSON as a string.
type URL ¶
type URL struct { UserInfo string Authority string Path string Query string Fragment string // contains filtered or unexported fields }
URL is an Accumulate URL.
func Parse ¶
Parse parses the string as an Accumulate URL. The scheme may be omitted, in which case `acc://` will be added, but if present it must be `acc`. The hostname must be non-empty. RawPath, ForceQuery, and RawFragment are not preserved.
func (*URL) AccountID ¶
AccountID constructs an account identifier from the lower case hostname and path. The port is not included. If the path does not begin with `/`, `/` is added between the hostname and the path.
ID = Hash(LowerCase(Sprintf("%s/%s", u.Host(), u.Path)))
func (*URL) AccountID32 ¶
AccountID32 returns AccountID as a [32]byte.
func (*URL) Compare ¶
Compare returns an integer comparing two URLs as lower case strings. The result will be 0 if u == v, -1 if u < v, and +1 if u > v.
func (*URL) Equal ¶
Equal reports whether u and v, converted to strings and interpreted as UTF-8, are equal under Unicode case-folding.
func (*URL) Hash ¶
Hash calculates a hash of the URL starting with AccountID, hashing and concatenating Query unless it is empty, and hashing and concatenating Fragment unless it is empty. If Query and Fragment are both non-empty, with H defined as the SHA-256 hash of the lower case of the operand, the result is H(H(AccountID + H(Query)) + H(Fragment)).
func (*URL) IdentityAccountID ¶
IdentityAccountID constructs an account identifier from the lower case hostname. The port is not included.
ID = Hash(LowerCase(u.Host()))
func (*URL) IdentityAccountID32 ¶
IdentityAccountID32 returns IdentityAccountID as a [32]byte.
func (*URL) IsRootIdentity ¶
IsRootIdentity returns true if the URL is a root identity.
func (*URL) LocalTo ¶
LocalTo returns true if U is local to V, that is if they have the same root identity.
func (*URL) MarshalJSON ¶
MarshalJSON marshals the URL to JSON as a string.
func (*URL) PathEqual ¶
PathEqual reports whether u.Path and v, normalized and interpreted as UTF-8, are equal under Unicode case-folding.
func (*URL) QueryValues ¶
QueryValues parses Query and returns the corresponding values. It silently discards malformed value pairs. To check errors use net/url.ParseQuery.
func (*URL) RawString ¶
RawString reassembles the URL into a valid URL string without encoding any component.
func (*URL) RootIdentity ¶
RootIdentity returns a copy of the URL with an empty path.
func (*URL) Routing ¶
Routing returns the first 8 bytes of the identity account ID as an integer.
Routing = uint64(u.IdentityAccountID()[:8])
func (*URL) ShortString ¶
ShortString returns String without the scheme prefix.
func (*URL) StripExtras ¶
StripExtras returns a URL with everything except the authority and path stripped. The receiver is returned if it meets the criteria.
func (*URL) UnmarshalJSON ¶
UnmarshalJSON unmarshals the URL from JSON as a string.
func (*URL) WithAuthority ¶
WithAuthority creates a copy of the URL with Authority set to the given value.
func (*URL) WithFragment ¶
WithFragment creates a copy of the URL with Fragment set to the given value.
func (*URL) WithUserInfo ¶
WithUserInfo creates a copy of the URL with UserInfo set to the given value.