Documentation ¶
Overview ¶
Package okatype_length (i.e., Okanero type length) provides the okatype_length.Type and okatype_length.NullableType types.
With the Okanero protocol, there is a message-oriented layer to it.
The Okanero protocol calls its messages "datum".
(In Golang, we can think of serialized Okanero datum as a []byte.)
(You could probably safely conflate an Okanero datum with a "block" in a "blockchain".)
A Okanero datum is variable length, thus there is a mechanism to specify the length of a Okanero datum.
The third 8 bytes (after the magic and the version) of a Okanero datum is the Okanero datum length.
Those 8 bytes are interpreted as a little-endian 64 bit integer.
This can be understood as:
[8]byte{203,255,0,0,0,0,0,0}
... begin interpreted as:
(203 × 256^0) + (255 × 256^1) = (203 × 1) + (255 × 256) = 203 + 65280 = 65513
So, continuing our example, if we include the magic and version also, the first 32 bytes in that example would be:
[32]byte{ 7,'o','k','a','n','e','r','o' // <-- magic, as a Pascal-string 1,0,0,0,0,0,0,0, // <-- version, as a little-endian 64 bit integer. 203,255,0,0,0,0,0,0, // <-- length, as a little-endian 64 bit integer. }
The okatype_length.Type is a way of representing this "length" in a Golang struct. I.e.,
struct Datum { Magic okatype_magic.Type Version okatype_version.Type Length okatype_length.Type // ... }
MOST LIKELY YOU WOULD NOT CREATE YOUR OWN okatype_length.Type, BUT INSTEAD USE IT FROM AN okatype_datum.Type.
Index ¶
- type NullableType
- func (receiver NullableType) Int64() (int64, error)
- func (receiver NullableType) MarshalJSON() ([]byte, error)
- func (receiver *NullableType) Scan(src interface{}) error
- func (receiver NullableType) String() string
- func (receiver *NullableType) UnmarshalJSON(b []byte) error
- func (receiver NullableType) Value() (driver.Value, error)
- func (receiver NullableType) WhenNone(fn func())
- func (receiver NullableType) WhenNull(fn func())
- func (receiver NullableType) WhenSome(fn func(int64))
- type Type
- func (receiver Type) Int64() (int64, error)
- func (receiver Type) MarshalJSON() ([]byte, error)
- func (receiver *Type) Scan(src interface{}) error
- func (receiver Type) String() string
- func (receiver *Type) UnmarshalJSON(b []byte) error
- func (receiver Type) Value() (driver.Value, error)
- func (receiver Type) WhenNone(fn func())
- func (receiver Type) WhenSome(fn func(int64))
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NullableType ¶
type NullableType struct {
// contains filtered or unexported fields
}
func NoneNullable ¶
func NoneNullable() NullableType
func Null ¶
func Null() NullableType
func SomeNullable ¶
func SomeNullable(value int64) NullableType
func (NullableType) Int64 ¶
func (receiver NullableType) Int64() (int64, error)
func (NullableType) MarshalJSON ¶
func (receiver NullableType) MarshalJSON() ([]byte, error)
func (*NullableType) Scan ¶
func (receiver *NullableType) Scan(src interface{}) error
func (NullableType) String ¶
func (receiver NullableType) String() string
func (*NullableType) UnmarshalJSON ¶
func (receiver *NullableType) UnmarshalJSON(b []byte) error
func (NullableType) WhenNone ¶
func (receiver NullableType) WhenNone(fn func())
func (NullableType) WhenNull ¶
func (receiver NullableType) WhenNull(fn func())
func (NullableType) WhenSome ¶
func (receiver NullableType) WhenSome(fn func(int64))
type Type ¶
type Type struct {
// contains filtered or unexported fields
}