Documentation ¶
Overview ¶
Package block provides implementations for Nano's block types.
Index ¶
- Constants
- Variables
- func Name(id byte) string
- type Block
- type ChangeBlock
- type Frontier
- type Hash
- type OpenBlock
- type ReceiveBlock
- func (b *ReceiveBlock) Hash() Hash
- func (b *ReceiveBlock) ID() byte
- func (b *ReceiveBlock) MarshalBinary() ([]byte, error)
- func (b *ReceiveBlock) Root() Hash
- func (b *ReceiveBlock) Size() int
- func (b *ReceiveBlock) UnmarshalBinary(data []byte) error
- func (b *ReceiveBlock) Valid(threshold uint64) bool
- type SendBlock
- type Signature
- type StateBlock
- func (b *StateBlock) Hash() Hash
- func (b *StateBlock) ID() byte
- func (b *StateBlock) IsOpen() bool
- func (b *StateBlock) MarshalBinary() ([]byte, error)
- func (b *StateBlock) Root() Hash
- func (b *StateBlock) Size() int
- func (b *StateBlock) UnmarshalBinary(data []byte) error
- func (b *StateBlock) Valid(threshold uint64) bool
- type Vote
- type Work
- type Worker
Constants ¶
const (
FrontierSize = nano.AddressSize + HashSize
)
const (
HashSize = blake2b.Size256
)
const (
SignatureSize = ed25519.SignatureSize
)
const (
WorkSize = 8
)
Variables ¶
var ( ErrBadBlockType = errors.New("bad block type") ErrNotABlock = errors.New("block type is not_a_block") )
Functions ¶
Types ¶
type Block ¶
type Block interface { encoding.BinaryMarshaler encoding.BinaryUnmarshaler Hash() Hash Root() Hash Size() int ID() byte Valid(threshold uint64) bool }
type ChangeBlock ¶
type ChangeBlock struct { PreviousHash Hash `json:"previous"` Representative nano.Address `json:"representative"` Signature Signature `json:"signature"` Work Work `json:"work"` }
func (*ChangeBlock) Hash ¶
func (b *ChangeBlock) Hash() Hash
func (*ChangeBlock) ID ¶
func (b *ChangeBlock) ID() byte
func (*ChangeBlock) MarshalBinary ¶
func (b *ChangeBlock) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*ChangeBlock) Root ¶
func (b *ChangeBlock) Root() Hash
func (*ChangeBlock) Size ¶
func (b *ChangeBlock) Size() int
func (*ChangeBlock) UnmarshalBinary ¶
func (b *ChangeBlock) UnmarshalBinary(data []byte) error
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
func (*ChangeBlock) Valid ¶
func (b *ChangeBlock) Valid(threshold uint64) bool
type Frontier ¶
func (*Frontier) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*Frontier) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
type Hash ¶
func (Hash) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*Hash) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type OpenBlock ¶
type OpenBlock struct { SourceHash Hash `json:"source"` Representative nano.Address `json:"representative"` Address nano.Address `json:"address"` Signature Signature `json:"signature"` Work Work `json:"work"` }
func (*OpenBlock) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*OpenBlock) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
type ReceiveBlock ¶
type ReceiveBlock struct { PreviousHash Hash `json:"previous"` SourceHash Hash `json:"source"` Signature Signature `json:"signature"` Work Work `json:"work"` }
func (*ReceiveBlock) Hash ¶
func (b *ReceiveBlock) Hash() Hash
func (*ReceiveBlock) ID ¶
func (b *ReceiveBlock) ID() byte
func (*ReceiveBlock) MarshalBinary ¶
func (b *ReceiveBlock) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*ReceiveBlock) Root ¶
func (b *ReceiveBlock) Root() Hash
func (*ReceiveBlock) Size ¶
func (b *ReceiveBlock) Size() int
func (*ReceiveBlock) UnmarshalBinary ¶
func (b *ReceiveBlock) UnmarshalBinary(data []byte) error
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
func (*ReceiveBlock) Valid ¶
func (b *ReceiveBlock) Valid(threshold uint64) bool
type SendBlock ¶
type SendBlock struct { PreviousHash Hash `json:"previous"` Destination nano.Address `json:"destination"` Balance nano.Balance `json:"balance"` Signature Signature `json:"signature"` Work Work `json:"work"` }
func (*SendBlock) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*SendBlock) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
type Signature ¶
type Signature [SignatureSize]byte
func (Signature) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*Signature) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type StateBlock ¶
type StateBlock struct { Address nano.Address `json:"address"` PreviousHash Hash `json:"previous"` Representative nano.Address `json:"representative"` Balance nano.Balance `json:"balance"` Link Hash `json:"link"` Signature Signature `json:"signature"` Work Work `json:"work"` }
func (*StateBlock) Hash ¶
func (b *StateBlock) Hash() Hash
func (*StateBlock) ID ¶
func (b *StateBlock) ID() byte
func (*StateBlock) IsOpen ¶
func (b *StateBlock) IsOpen() bool
func (*StateBlock) MarshalBinary ¶
func (b *StateBlock) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*StateBlock) Root ¶
func (b *StateBlock) Root() Hash
func (*StateBlock) Size ¶
func (b *StateBlock) Size() int
func (*StateBlock) UnmarshalBinary ¶
func (b *StateBlock) UnmarshalBinary(data []byte) error
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
func (*StateBlock) Valid ¶
func (b *StateBlock) Valid(threshold uint64) bool
type Vote ¶
func (*Vote) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*Vote) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
type Work ¶
type Work uint64
func (Work) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*Work) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.