go-core: github.com/stratumn/go-core/types Index | Files

package types

import "github.com/stratumn/go-core/types"

Package types defines common types.

Index

Package Files

bytes.go error.go evidence.go segment.go transaction.go

Constants

const Bytes20Size = 20

Bytes20Size is the size of a 20-byte long byte array.

const Bytes32Size = 32

Bytes32Size is the size of a 32-byte long byte array.

const (
    // Component name for monitoring.
    Component = "types"
)

Variables

var Bytes32Zero = &Bytes32{}

Bytes32Zero is the default value for a 32-byte long byte array.

type Bytes20 Uses

type Bytes20 [Bytes20Size]byte

Bytes20 is a 20-byte long byte array.

func NewBytes20FromString Uses

func NewBytes20FromString(src string) (*Bytes20, error)

NewBytes20FromString creates a Bytes20 from a hex encoded string.

func (*Bytes20) MarshalJSON Uses

func (b *Bytes20) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.MarshalJSON.

func (*Bytes20) Reverse Uses

func (b *Bytes20) Reverse(rb *ReversedBytes20)

Reverse reverses the bytes order.

func (*Bytes20) String Uses

func (b *Bytes20) String() string

String returns a hex encoded string.

func (*Bytes20) UnmarshalJSON Uses

func (b *Bytes20) UnmarshalJSON(data []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.UnmarshalJSON.

func (*Bytes20) Unstring Uses

func (b *Bytes20) Unstring(src string) error

Unstring sets the value from a hex encoded string.

type Bytes32 Uses

type Bytes32 [Bytes32Size]byte

Bytes32 is a 32-byte long byte array.

func NewBytes32FromBytes Uses

func NewBytes32FromBytes(src []byte) *Bytes32

NewBytes32FromBytes creates a Bytes32 from a byte slice.

func NewBytes32FromString Uses

func NewBytes32FromString(src string) (*Bytes32, error)

NewBytes32FromString creates a Bytes32 from a hex encoded string.

func (*Bytes32) Compare Uses

func (b *Bytes32) Compare(b2 *Bytes32) int

Compare compares two Bytes32

func (*Bytes32) Equals Uses

func (b *Bytes32) Equals(b2 *Bytes32) bool

Equals checks if two Bytes32 are equal

func (*Bytes32) EqualsBytes Uses

func (b *Bytes32) EqualsBytes(b2 []byte) bool

EqualsBytes checks if a byte slice equals a Bytes32

func (*Bytes32) MarshalJSON Uses

func (b *Bytes32) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.MarshalJSON.

func (*Bytes32) Reverse Uses

func (b *Bytes32) Reverse(rb *ReversedBytes32)

Reverse reverses the bytes order.

func (*Bytes32) String Uses

func (b *Bytes32) String() string

String returns a hex encoded string.

func (*Bytes32) UnmarshalJSON Uses

func (b *Bytes32) UnmarshalJSON(data []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.UnmarshalJSON.

func (*Bytes32) Unstring Uses

func (b *Bytes32) Unstring(src string) error

Unstring sets the value from a hex encoded string.

func (*Bytes32) Value Uses

func (b *Bytes32) Value() (driver.Value, error)

Value implements the database.sql.driver.Valuer interface.

func (*Bytes32) Zero Uses

func (b *Bytes32) Zero() bool

Zero checks if a Bytes32 is the default value or nil

type Error Uses

type Error struct {
    Code      int    // Error code (see monitoring/errorcode.go).
    Component string // Component that triggered the error (e.g. "fossilizer").
    Message   string // Custom error message.
    Wrapped   error  // Inner error.
}

Error structure to provide accurate metrics and logs. Errors coming from external dependencies should always be wrapped inside an instance of this structured error type (in particular to capture a stack trace). Errors coming from dependencies inside go-core should either be propagated as-is or wrapped depending on the code's ability to add new relevant context.

func NewError Uses

func NewError(code int, component string, message string) *Error

NewError creates a new error and captures a stack trace.

func NewErrorf Uses

func NewErrorf(code int, component string, format string, args ...interface{}) *Error

NewErrorf creates a new error and captures a stack trace.

func WrapError Uses

func WrapError(err error, code int, component string, message string) *Error

WrapError wraps an error and adds a stack trace.

func WrapErrorf Uses

func WrapErrorf(err error, code int, component string, format string, args ...interface{}) *Error

WrapErrorf wraps an error and adds a stack trace.

func (*Error) Error Uses

func (e *Error) Error() string

Error returns a friendly error message.

func (*Error) Format Uses

func (e *Error) Format(s fmt.State, verb rune)

Format the error when printing. %+v prints the full stack trace of the deepest error in the stack in case an internal error was wrapped.

func (*Error) MarshalJSON Uses

func (e *Error) MarshalJSON() ([]byte, error)

MarshalJSON recursively checks inner errors to marshal them properly.

func (*Error) String Uses

func (e *Error) String() string

String returns a friendly error message.

type EvidenceSlice Uses

type EvidenceSlice []*chainscript.Evidence

EvidenceSlice is a slice of evidences.

func (*EvidenceSlice) AddEvidence Uses

func (e *EvidenceSlice) AddEvidence(evidence *chainscript.Evidence) error

AddEvidence adds an evidence to the slice.

func (EvidenceSlice) FindEvidences Uses

func (e EvidenceSlice) FindEvidences(backend string) (res EvidenceSlice)

FindEvidences find all evidences generated by a specified backend.

func (EvidenceSlice) GetEvidence Uses

func (e EvidenceSlice) GetEvidence(backend, provider string) *chainscript.Evidence

GetEvidence gets an evidence from a backend's provider.

type Link struct {
    Link *chainscript.Link
}

Link simply wraps a chainscript.Link. It can be useful in scenario where you don't want to work directly with the chainscript package. For example directly using chainscript.Link doesn't work in plugins (because the plugin compilation uses GOPATH instead of the vendor directory). Even if your GOPATH and vendor directory have the same version of go-chainscript the runtime will treat them as different types so the cast to a ScriptValidatorFunc will fail.

type PaginatedSegments Uses

type PaginatedSegments struct {
    Segments   SegmentSlice `json:"segments"`
    TotalCount int          `json:"totalCount"`
}

PaginatedSegments is a slice of segments along with the total results count.

type ReversedBytes20 Uses

type ReversedBytes20 [Bytes20Size]byte

ReversedBytes20 is a 20-byte long byte reversed array. While the bytes are reversed, the hex encoded strings are not.

func NewReversedBytes20FromString Uses

func NewReversedBytes20FromString(src string) (*ReversedBytes20, error)

NewReversedBytes20FromString creates a ReversedBytes20 from a hex encoded string.

func (*ReversedBytes20) MarshalJSON Uses

func (rb *ReversedBytes20) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.MarshalJSON.

func (*ReversedBytes20) Reverse Uses

func (rb *ReversedBytes20) Reverse(b *Bytes20)

Reverse reverses the bytes order.

func (*ReversedBytes20) String Uses

func (rb *ReversedBytes20) String() string

String returns a hex encoded string.

func (*ReversedBytes20) UnmarshalJSON Uses

func (rb *ReversedBytes20) UnmarshalJSON(data []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.UnmarshalJSON.

func (*ReversedBytes20) Unstring Uses

func (rb *ReversedBytes20) Unstring(src string) error

Unstring sets the value from a hex encoded string.

type ReversedBytes32 Uses

type ReversedBytes32 [Bytes32Size]byte

ReversedBytes32 is a 32-byte long byte reversed array. While the bytes are reversed, the hex encoded strings are not.

func NewReversedBytes32FromString Uses

func NewReversedBytes32FromString(src string) (*ReversedBytes32, error)

NewReversedBytes32FromString creates a ReversedBytes32 from a hex encoded string.

func (*ReversedBytes32) MarshalJSON Uses

func (rb *ReversedBytes32) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.MarshalJSON.

func (*ReversedBytes32) Reverse Uses

func (rb *ReversedBytes32) Reverse(b *Bytes32)

Reverse reverses the bytes order.

func (*ReversedBytes32) String Uses

func (rb *ReversedBytes32) String() string

String returns a hex encoded string.

func (*ReversedBytes32) UnmarshalJSON Uses

func (rb *ReversedBytes32) UnmarshalJSON(data []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.UnmarshalJSON.

func (*ReversedBytes32) Unstring Uses

func (rb *ReversedBytes32) Unstring(src string) error

Unstring sets the value from a hex encoded string.

type SegmentSlice Uses

type SegmentSlice []*chainscript.Segment

SegmentSlice is a slice of segment pointers.

func (SegmentSlice) Len Uses

func (s SegmentSlice) Len() int

Len implements sort.Interface.Len.

func (SegmentSlice) Less Uses

func (s SegmentSlice) Less(i, j int) bool

Less implements sort.Interface.Less.

func (*SegmentSlice) Sort Uses

func (s *SegmentSlice) Sort(reverse bool)

Sort returns the sorted segment slice.

func (SegmentSlice) Swap Uses

func (s SegmentSlice) Swap(i, j int)

Swap implements sort.Interface.Swap.

type TransactionID Uses

type TransactionID []byte

TransactionID is a blockchain transaction ID.

func (TransactionID) MarshalJSON Uses

func (txid TransactionID) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.MarshalJSON.

func (TransactionID) String Uses

func (txid TransactionID) String() string

String returns a hex encoded string.

func (*TransactionID) UnmarshalJSON Uses

func (txid *TransactionID) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements encoding/json.Unmarshaler.UnmarshalJSON.

Package types imports 10 packages (graph) and is imported by 100 packages. Updated 2018-11-14. Refresh now. Tools for package owners.