block

package
v0.0.0-...-c638c98 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package block is a generated protocol buffer package.

It is generated from these files:

block/block.proto

It has these top-level messages:

Signature
Transaction
Block
PublicKey
PrivateKey

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidBlock = errors.New("Block Not Valid")
)
View Source
var Transaction_Type_name = map[int32]string{
	0: "Raw",
	1: "PublicKey",
}
View Source
var Transaction_Type_value = map[string]int32{
	"Raw":       0,
	"PublicKey": 1,
}

Functions

func GenerateKey

func GenerateKey() (*ecdsa.PrivateKey, error)

func MarshalKey

func MarshalKey(key *ecdsa.PrivateKey) ([]byte, error)

func NewCurve

func NewCurve() elliptic.Curve

func NewHash

func NewHash() hash.Hash

func UnmarshalKey

func UnmarshalKey(buff []byte, key *ecdsa.PrivateKey) error

Types

type Block

type Block struct {
	Timestamp    int64          `protobuf:"varint,1,opt,name=timestamp" json:"timestamp,omitempty"`
	Parent       []byte         `protobuf:"bytes,2,opt,name=parent,proto3" json:"parent,omitempty"`
	Hash         []byte         `protobuf:"bytes,3,opt,name=hash,proto3" json:"hash,omitempty"`
	Transactions []*Transaction `protobuf:"bytes,4,rep,name=transactions" json:"transactions,omitempty"`
}

Metadata about a block

func NewBlock

func NewBlock(parent []byte, transactions []*Transaction) *Block

func (*Block) Descriptor

func (*Block) Descriptor() ([]byte, []int)

func (*Block) First

func (b *Block) First() bool

func (*Block) GetHash

func (m *Block) GetHash() []byte

func (*Block) GetParent

func (m *Block) GetParent() []byte

func (*Block) GetTimestamp

func (m *Block) GetTimestamp() int64

func (*Block) GetTransactions

func (m *Block) GetTransactions() []*Transaction

func (*Block) ProtoMessage

func (*Block) ProtoMessage()

func (*Block) Reset

func (m *Block) Reset()

func (*Block) String

func (m *Block) String() string

func (*Block) Valid

func (b *Block) Valid(pubs []ecdsa.PublicKey) bool

type PrivateKey

type PrivateKey struct {
	Public *PublicKey `protobuf:"bytes,1,opt,name=public" json:"public,omitempty"`
	D      []byte     `protobuf:"bytes,2,opt,name=d,proto3" json:"d,omitempty"`
}

func (*PrivateKey) Descriptor

func (*PrivateKey) Descriptor() ([]byte, []int)

func (*PrivateKey) GetD

func (m *PrivateKey) GetD() []byte

func (*PrivateKey) GetPublic

func (m *PrivateKey) GetPublic() *PublicKey

func (*PrivateKey) ProtoMessage

func (*PrivateKey) ProtoMessage()

func (*PrivateKey) Reset

func (m *PrivateKey) Reset()

func (*PrivateKey) String

func (m *PrivateKey) String() string

type PublicKey

type PublicKey struct {
	X    []byte `protobuf:"bytes,1,opt,name=x,proto3" json:"x,omitempty"`
	Y    []byte `protobuf:"bytes,2,opt,name=y,proto3" json:"y,omitempty"`
	Hint string `protobuf:"bytes,3,opt,name=hint" json:"hint,omitempty"`
}

func (*PublicKey) Descriptor

func (*PublicKey) Descriptor() ([]byte, []int)

func (*PublicKey) GetHint

func (m *PublicKey) GetHint() string

func (*PublicKey) GetX

func (m *PublicKey) GetX() []byte

func (*PublicKey) GetY

func (m *PublicKey) GetY() []byte

func (*PublicKey) ProtoMessage

func (*PublicKey) ProtoMessage()

func (*PublicKey) Reset

func (m *PublicKey) Reset()

func (*PublicKey) String

func (m *PublicKey) String() string

type Signature

type Signature struct {
	Timestamp  int64  `protobuf:"varint,1,opt,name=timestamp" json:"timestamp,omitempty"`
	Hash       []byte `protobuf:"bytes,2,opt,name=hash,proto3" json:"hash,omitempty"`
	SignatureA []byte `protobuf:"bytes,3,opt,name=signatureA,proto3" json:"signatureA,omitempty"`
	SignatureB []byte `protobuf:"bytes,4,opt,name=signatureB,proto3" json:"signatureB,omitempty"`
}

metadat about a block signature

func NewSignature

func NewSignature(priv *ecdsa.PrivateKey, h hash.Hash) (*Signature, error)

func (*Signature) Descriptor

func (*Signature) Descriptor() ([]byte, []int)

func (*Signature) GetA

func (s *Signature) GetA() *big.Int

func (*Signature) GetB

func (s *Signature) GetB() *big.Int

func (*Signature) GetHash

func (m *Signature) GetHash() []byte

func (*Signature) GetSignatureA

func (m *Signature) GetSignatureA() []byte

func (*Signature) GetSignatureB

func (m *Signature) GetSignatureB() []byte

func (*Signature) GetTimestamp

func (m *Signature) GetTimestamp() int64

func (*Signature) ProtoMessage

func (*Signature) ProtoMessage()

func (*Signature) Reset

func (m *Signature) Reset()

func (*Signature) String

func (m *Signature) String() string

type Transaction

type Transaction struct {
	Signature *Signature       `protobuf:"bytes,1,opt,name=signature" json:"signature,omitempty"`
	Type      Transaction_Type `protobuf:"varint,2,opt,name=type,enum=block.Transaction_Type" json:"type,omitempty"`
	Payload   []byte           `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload,omitempty"`
}

func NewTransaction

func NewTransaction(priv *ecdsa.PrivateKey, payload []byte, t Transaction_Type) (*Transaction, error)

func (*Transaction) Descriptor

func (*Transaction) Descriptor() ([]byte, []int)

func (*Transaction) GetPayload

func (m *Transaction) GetPayload() []byte

func (*Transaction) GetSignature

func (m *Transaction) GetSignature() *Signature

func (*Transaction) GetType

func (m *Transaction) GetType() Transaction_Type

func (*Transaction) ProtoMessage

func (*Transaction) ProtoMessage()

func (*Transaction) Reset

func (m *Transaction) Reset()

func (*Transaction) String

func (m *Transaction) String() string

func (*Transaction) Valid

func (t *Transaction) Valid(keys []ecdsa.PublicKey) bool

type Transaction_Type

type Transaction_Type int32
const (
	Transaction_Raw       Transaction_Type = 0
	Transaction_PublicKey Transaction_Type = 1
)

func (Transaction_Type) EnumDescriptor

func (Transaction_Type) EnumDescriptor() ([]byte, []int)

func (Transaction_Type) String

func (x Transaction_Type) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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