Block

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2018 License: MIT Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTypeFromJSON

func GetTypeFromJSON(jsn []byte) string

Types

type BlockHash

type BlockHash []byte

func (BlockHash) MarshalJSON

func (d BlockHash) MarshalJSON() ([]byte, error)

func (*BlockHash) UnmarshalJSON

func (d *BlockHash) UnmarshalJSON(data []byte) (err error)

type BlockTransaction

type BlockTransaction interface {
	Serialize() ([]byte, error)
	CreateProof() []byte
	Hash() BlockHash

	GetType() string

	SetWork([]byte)
	SetSignature([]byte)
	SetFrontier(BlockHash)
	SetBalance(*Numbers.RawAmount)
}

func CreateSignedReceiveOrOpenBlock

func CreateSignedReceiveOrOpenBlock(sk *Wallet.SecretKey, source, previous []byte) (blk BlockTransaction, err error)

type ChangeBlock

type ChangeBlock struct {
	Previous       []byte
	Representative Wallet.PublicKey
	DefaultBlock
}

func CreateSignedChangeBlock

func CreateSignedChangeBlock(sk *Wallet.SecretKey, previous []byte, representative *Wallet.Address) (blk *ChangeBlock, err error)

func (*ChangeBlock) CreateProof

func (s *ChangeBlock) CreateProof() []byte

func (*ChangeBlock) Hash

func (s *ChangeBlock) Hash() BlockHash

func (*ChangeBlock) Serialize

func (s *ChangeBlock) Serialize() ([]byte, error)

func (*ChangeBlock) SetBalance

func (s *ChangeBlock) SetBalance(n *Numbers.RawAmount)

func (*ChangeBlock) SetFrontier

func (s *ChangeBlock) SetFrontier(h BlockHash)

type DefaultBlock

type DefaultBlock struct {
	Type      string `json:"type" serialize:"string"`
	Work      []byte `json:"work" serialize:"hex"`
	Signature []byte `json:"signature" serialize:"hex"`
}

func (*DefaultBlock) GetType

func (d *DefaultBlock) GetType() string

func (*DefaultBlock) SetSignature

func (d *DefaultBlock) SetSignature(s []byte)

func (*DefaultBlock) SetWork

func (d *DefaultBlock) SetWork(w []byte)

type OpenBlock

type OpenBlock struct {
	Source         []byte
	Representative Wallet.PublicKey
	Account        Wallet.PublicKey
	DefaultBlock
}

func CreateSignedOpenBlock

func CreateSignedOpenBlock(sk *Wallet.SecretKey, source []byte) (blk *OpenBlock, err error)

func (*OpenBlock) CreateProof

func (s *OpenBlock) CreateProof() []byte

func (*OpenBlock) Hash

func (s *OpenBlock) Hash() BlockHash

func (*OpenBlock) Serialize

func (s *OpenBlock) Serialize() ([]byte, error)

func (*OpenBlock) SetBalance

func (s *OpenBlock) SetBalance(n *Numbers.RawAmount)

func (*OpenBlock) SetFrontier

func (s *OpenBlock) SetFrontier(h BlockHash)

type ReceiveBlock

type ReceiveBlock struct {
	Previous []byte
	Source   []byte
	DefaultBlock
}

func CreateSignedReceiveBlock

func CreateSignedReceiveBlock(sk *Wallet.SecretKey, source, previous []byte) (blk *ReceiveBlock, err error)

func (*ReceiveBlock) CreateProof

func (s *ReceiveBlock) CreateProof() []byte

func (*ReceiveBlock) Hash

func (s *ReceiveBlock) Hash() BlockHash

func (*ReceiveBlock) Serialize

func (s *ReceiveBlock) Serialize() ([]byte, error)

func (*ReceiveBlock) SetBalance

func (s *ReceiveBlock) SetBalance(n *Numbers.RawAmount)

func (*ReceiveBlock) SetFrontier

func (s *ReceiveBlock) SetFrontier(h BlockHash)

type SendBlock

type SendBlock struct {
	Previous    []byte
	Destination Wallet.PublicKey
	Balance     *Numbers.RawAmount
	DefaultBlock
}

func CreateSignedSendBlock

func CreateSignedSendBlock(sk *Wallet.SecretKey, sending, balance *Numbers.RawAmount, previous []byte, destination *Wallet.Address) (blk *SendBlock, err error)

func (*SendBlock) CreateProof

func (s *SendBlock) CreateProof() []byte

func (*SendBlock) Hash

func (s *SendBlock) Hash() BlockHash

func (*SendBlock) Serialize

func (s *SendBlock) Serialize() ([]byte, error)

func (*SendBlock) SetBalance

func (s *SendBlock) SetBalance(n *Numbers.RawAmount)

func (*SendBlock) SetFrontier

func (s *SendBlock) SetFrontier(h BlockHash)

type SerializedChangeBlock

type SerializedChangeBlock struct {
	Previous       string `json:"previous" serialize:"hex"`
	Representative string `json:"representative" serialize:"hex"`
	SerializedDefaultBlock
}

type SerializedDefaultBlock

type SerializedDefaultBlock struct {
	Type      string `json:"type"`
	Work      string `json:"work" serialize:"hex"`
	Signature string `json:"signature" serialize:"hex"`
}

type SerializedOpenBlock

type SerializedOpenBlock struct {
	Source         string `json:"source" serialize:"hex"`
	Representative string `json:"representative" serialize:"hex"`
	Account        string `json:"account" serialize:"hex"`
	SerializedDefaultBlock
}

type SerializedReceiveBlock

type SerializedReceiveBlock struct {
	Previous string `json:"previous" serialize:"hex"`
	Source   string `json:"source" serialize:"hex"`
	SerializedDefaultBlock
}

type SerializedSendBlock

type SerializedSendBlock struct {
	Previous    string `json:"previous" serialize:"hex"`
	Destination string `json:"destination"`
	Balance     string `json:"balance" serialize:"hex"`
	SerializedDefaultBlock
}

type SerializedUniversalBlock

type SerializedUniversalBlock struct {
	Account        string `json:"account" serialize:"hex"`
	Previous       string `json:"previous" serialize:"hex"`
	Representative string `json:"representative" serialize:"hex"`
	Balance        string `json:"balance" serialize:"hex"`
	Amount         string `json:"amount" serialize:"hex"`

	Link string `json:"link" serialize:"hex"` // Link or Target?!

	Destination string `json:"destination"`
	Source      string `json:"source" serialize:"hex"`

	SerializedDefaultBlock
}

type UniversalBlock

type UniversalBlock struct {
	Account        Wallet.PublicKey
	Previous       []byte
	Representative Wallet.PublicKey
	Balance        *Numbers.RawAmount
	Amount         *Numbers.RawAmount

	Destination Wallet.PublicKey `json:"destination"`
	Source      []byte           `json:"source" serialize:"hex"`

	DefaultBlock
}

func NewBlockFromJSON

func NewBlockFromJSON(jsn []byte) (blk UniversalBlock, err error)

@TODO Create use JSONMarshal instead

func (*UniversalBlock) Hash

func (u *UniversalBlock) Hash() BlockHash

It can change in the future, consider "Destination" as "Target".

func (*UniversalBlock) HashAsChange

func (u *UniversalBlock) HashAsChange() BlockHash

func (*UniversalBlock) HashAsOpen

func (u *UniversalBlock) HashAsOpen() BlockHash

func (*UniversalBlock) HashAsReceive

func (u *UniversalBlock) HashAsReceive() BlockHash

func (*UniversalBlock) HashAsSend

func (u *UniversalBlock) HashAsSend() BlockHash

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL