coder

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

README

Info

See:

  1. golang/protobuf
  2. gogo/protobutf
  3. libp2p/go-libp2p/examples/multipro

Installation

First, install protobuffs. Then:

$ go get github.com/gogo/protobuf/protoc-gen-gogofast

Usage

$ protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/gogo/protobuf/protobuf --gogofast_out=\
Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types:. \
models.proto

Types

In addition to protocol buffers, bytes arrays are prepended with a single byte that acts as meta data about the bytes array; specifically the serialization method used to create the bytes.

A list of codes and their interpretations are given below. The current serialization method is Proto3.

Type Code
Proto3 0

Documentation

Overview

Package coder is a generated protocol buffer package.

It is generated from these files:

models.proto

It has these top-level messages:

MinedBlock
MerkleTree
MainchainBlock
MinerSig
StatechainBlock
TxSig
Transaction
Diff

Index

Constants

View Source
const CurrentCode = Proto3

CurrentCode is the code currently used by this package

View Source
const (
	// Proto3 is the protobuf syntax=3; https://developers.google.com/protocol-buffers/docs/proto3
	Proto3 byte = iota
)

Variables

View Source
var (
	ErrInvalidLengthModels = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowModels   = fmt.Errorf("proto: integer overflow")
)
View Source
var (
	// ErrNilBytes ...
	ErrNilBytes = errors.New("nil bytes")
)

Functions

func AppendCode

func AppendCode(bytes []byte) []byte

AppendCode ...

func ExtractCode

func ExtractCode(bytes []byte) (byte, error)

ExtractCode ...

func StripCode

func StripCode(bytes []byte) (byte, []byte, error)

StripCode ...

Types

type Diff

type Diff struct {
	DiffHash string `protobuf:"bytes,1,opt,name=diffHash,proto3" json:"diffHash,omitempty"`
	Data     string `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
}

func (*Diff) Descriptor

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

func (*Diff) GetData

func (m *Diff) GetData() string

func (*Diff) GetDiffHash

func (m *Diff) GetDiffHash() string

func (*Diff) Marshal

func (m *Diff) Marshal() (dAtA []byte, err error)

func (*Diff) MarshalTo

func (m *Diff) MarshalTo(dAtA []byte) (int, error)

func (*Diff) ProtoMessage

func (*Diff) ProtoMessage()

func (*Diff) Reset

func (m *Diff) Reset()

func (*Diff) Size

func (m *Diff) Size() (n int)

func (*Diff) String

func (m *Diff) String() string

func (*Diff) Unmarshal

func (m *Diff) Unmarshal(dAtA []byte) error

type MainchainBlock

type MainchainBlock struct {
	BlockHash             string    `protobuf:"bytes,1,opt,name=blockHash,proto3" json:"blockHash,omitempty"`
	BlockNumber           string    `protobuf:"bytes,2,opt,name=blockNumber,proto3" json:"blockNumber,omitempty"`
	BlockTime             string    `protobuf:"bytes,3,opt,name=blockTime,proto3" json:"blockTime,omitempty"`
	ImageHash             string    `protobuf:"bytes,4,opt,name=imageHash,proto3" json:"imageHash,omitempty"`
	StateBlocksMerkleHash string    `protobuf:"bytes,5,opt,name=stateBlocksMerkleHash,proto3" json:"stateBlocksMerkleHash,omitempty"`
	PrevBlockHash         string    `protobuf:"bytes,6,opt,name=prevBlockHash,proto3" json:"prevBlockHash,omitempty"`
	Nonce                 string    `protobuf:"bytes,7,opt,name=nonce,proto3" json:"nonce,omitempty"`
	Difficulty            string    `protobuf:"bytes,8,opt,name=difficulty,proto3" json:"difficulty,omitempty"`
	MinerAddress          string    `protobuf:"bytes,9,opt,name=minerAddress,proto3" json:"minerAddress,omitempty"`
	MinerSig              *MinerSig `protobuf:"bytes,10,opt,name=minerSig" json:"minerSig,omitempty"`
}

func (*MainchainBlock) Descriptor

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

func (*MainchainBlock) GetBlockHash

func (m *MainchainBlock) GetBlockHash() string

func (*MainchainBlock) GetBlockNumber

func (m *MainchainBlock) GetBlockNumber() string

func (*MainchainBlock) GetBlockTime

func (m *MainchainBlock) GetBlockTime() string

func (*MainchainBlock) GetDifficulty

func (m *MainchainBlock) GetDifficulty() string

func (*MainchainBlock) GetImageHash

func (m *MainchainBlock) GetImageHash() string

func (*MainchainBlock) GetMinerAddress

func (m *MainchainBlock) GetMinerAddress() string

func (*MainchainBlock) GetMinerSig

func (m *MainchainBlock) GetMinerSig() *MinerSig

func (*MainchainBlock) GetNonce

func (m *MainchainBlock) GetNonce() string

func (*MainchainBlock) GetPrevBlockHash

func (m *MainchainBlock) GetPrevBlockHash() string

func (*MainchainBlock) GetStateBlocksMerkleHash

func (m *MainchainBlock) GetStateBlocksMerkleHash() string

func (*MainchainBlock) Marshal

func (m *MainchainBlock) Marshal() (dAtA []byte, err error)

func (*MainchainBlock) MarshalTo

func (m *MainchainBlock) MarshalTo(dAtA []byte) (int, error)

func (*MainchainBlock) ProtoMessage

func (*MainchainBlock) ProtoMessage()

func (*MainchainBlock) Reset

func (m *MainchainBlock) Reset()

func (*MainchainBlock) Size

func (m *MainchainBlock) Size() (n int)

func (*MainchainBlock) String

func (m *MainchainBlock) String() string

func (*MainchainBlock) Unmarshal

func (m *MainchainBlock) Unmarshal(dAtA []byte) error

type MerkleTree

type MerkleTree struct {
	MerkleTreeRootHash string   `protobuf:"bytes,1,opt,name=merkleTreeRootHash,proto3" json:"merkleTreeRootHash,omitempty"`
	Kind               string   `protobuf:"bytes,2,opt,name=kind,proto3" json:"kind,omitempty"`
	Hashes             []string `protobuf:"bytes,3,rep,name=hashes" json:"hashes,omitempty"`
}

func (*MerkleTree) Descriptor

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

func (*MerkleTree) GetHashes

func (m *MerkleTree) GetHashes() []string

func (*MerkleTree) GetKind

func (m *MerkleTree) GetKind() string

func (*MerkleTree) GetMerkleTreeRootHash

func (m *MerkleTree) GetMerkleTreeRootHash() string

func (*MerkleTree) Marshal

func (m *MerkleTree) Marshal() (dAtA []byte, err error)

func (*MerkleTree) MarshalTo

func (m *MerkleTree) MarshalTo(dAtA []byte) (int, error)

func (*MerkleTree) ProtoMessage

func (*MerkleTree) ProtoMessage()

func (*MerkleTree) Reset

func (m *MerkleTree) Reset()

func (*MerkleTree) Size

func (m *MerkleTree) Size() (n int)

func (*MerkleTree) String

func (m *MerkleTree) String() string

func (*MerkleTree) Unmarshal

func (m *MerkleTree) Unmarshal(dAtA []byte) error

type MinedBlock

type MinedBlock struct {
	NextBlock           *MainchainBlock             `protobuf:"bytes,1,opt,name=nextBlock" json:"nextBlock,omitempty"`
	PreviousBlock       *MainchainBlock             `protobuf:"bytes,2,opt,name=previousBlock" json:"previousBlock,omitempty"`
	StatechainBlocksMap map[string]*StatechainBlock `` /* 165-byte string literal not displayed */
	TransactionsMap     map[string]*Transaction     `` /* 157-byte string literal not displayed */
	DiffsMap            map[string]*Diff            `` /* 143-byte string literal not displayed */
	MerkleTreesMap      map[string]*MerkleTree      `` /* 155-byte string literal not displayed */
}

func (*MinedBlock) Descriptor

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

func (*MinedBlock) GetDiffsMap

func (m *MinedBlock) GetDiffsMap() map[string]*Diff

func (*MinedBlock) GetMerkleTreesMap

func (m *MinedBlock) GetMerkleTreesMap() map[string]*MerkleTree

func (*MinedBlock) GetNextBlock

func (m *MinedBlock) GetNextBlock() *MainchainBlock

func (*MinedBlock) GetPreviousBlock

func (m *MinedBlock) GetPreviousBlock() *MainchainBlock

func (*MinedBlock) GetStatechainBlocksMap

func (m *MinedBlock) GetStatechainBlocksMap() map[string]*StatechainBlock

func (*MinedBlock) GetTransactionsMap

func (m *MinedBlock) GetTransactionsMap() map[string]*Transaction

func (*MinedBlock) Marshal

func (m *MinedBlock) Marshal() (dAtA []byte, err error)

func (*MinedBlock) MarshalTo

func (m *MinedBlock) MarshalTo(dAtA []byte) (int, error)

func (*MinedBlock) ProtoMessage

func (*MinedBlock) ProtoMessage()

func (*MinedBlock) Reset

func (m *MinedBlock) Reset()

func (*MinedBlock) Size

func (m *MinedBlock) Size() (n int)

func (*MinedBlock) String

func (m *MinedBlock) String() string

func (*MinedBlock) Unmarshal

func (m *MinedBlock) Unmarshal(dAtA []byte) error

type MinerSig

type MinerSig struct {
	R string `protobuf:"bytes,1,opt,name=r,proto3" json:"r,omitempty"`
	S string `protobuf:"bytes,2,opt,name=s,proto3" json:"s,omitempty"`
}

func (*MinerSig) Descriptor

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

func (*MinerSig) GetR

func (m *MinerSig) GetR() string

func (*MinerSig) GetS

func (m *MinerSig) GetS() string

func (*MinerSig) Marshal

func (m *MinerSig) Marshal() (dAtA []byte, err error)

func (*MinerSig) MarshalTo

func (m *MinerSig) MarshalTo(dAtA []byte) (int, error)

func (*MinerSig) ProtoMessage

func (*MinerSig) ProtoMessage()

func (*MinerSig) Reset

func (m *MinerSig) Reset()

func (*MinerSig) Size

func (m *MinerSig) Size() (n int)

func (*MinerSig) String

func (m *MinerSig) String() string

func (*MinerSig) Unmarshal

func (m *MinerSig) Unmarshal(dAtA []byte) error

type StatechainBlock

type StatechainBlock struct {
	BlockHash         string `protobuf:"bytes,1,opt,name=blockHash,proto3" json:"blockHash,omitempty"`
	BlockNumber       string `protobuf:"bytes,2,opt,name=blockNumber,proto3" json:"blockNumber,omitempty"`
	BlockTime         string `protobuf:"bytes,3,opt,name=blockTime,proto3" json:"blockTime,omitempty"`
	ImageHash         string `protobuf:"bytes,4,opt,name=imageHash,proto3" json:"imageHash,omitempty"`
	TxHash            string `protobuf:"bytes,5,opt,name=txHash,proto3" json:"txHash,omitempty"`
	PrevBlockHash     string `protobuf:"bytes,6,opt,name=prevBlockHash,proto3" json:"prevBlockHash,omitempty"`
	StatePrevDiffHash string `protobuf:"bytes,7,opt,name=statePrevDiffHash,proto3" json:"statePrevDiffHash,omitempty"`
	StateCurrentHash  string `protobuf:"bytes,8,opt,name=stateCurrentHash,proto3" json:"stateCurrentHash,omitempty"`
}

func (*StatechainBlock) Descriptor

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

func (*StatechainBlock) GetBlockHash

func (m *StatechainBlock) GetBlockHash() string

func (*StatechainBlock) GetBlockNumber

func (m *StatechainBlock) GetBlockNumber() string

func (*StatechainBlock) GetBlockTime

func (m *StatechainBlock) GetBlockTime() string

func (*StatechainBlock) GetImageHash

func (m *StatechainBlock) GetImageHash() string

func (*StatechainBlock) GetPrevBlockHash

func (m *StatechainBlock) GetPrevBlockHash() string

func (*StatechainBlock) GetStateCurrentHash

func (m *StatechainBlock) GetStateCurrentHash() string

func (*StatechainBlock) GetStatePrevDiffHash

func (m *StatechainBlock) GetStatePrevDiffHash() string

func (*StatechainBlock) GetTxHash

func (m *StatechainBlock) GetTxHash() string

func (*StatechainBlock) Marshal

func (m *StatechainBlock) Marshal() (dAtA []byte, err error)

func (*StatechainBlock) MarshalTo

func (m *StatechainBlock) MarshalTo(dAtA []byte) (int, error)

func (*StatechainBlock) ProtoMessage

func (*StatechainBlock) ProtoMessage()

func (*StatechainBlock) Reset

func (m *StatechainBlock) Reset()

func (*StatechainBlock) Size

func (m *StatechainBlock) Size() (n int)

func (*StatechainBlock) String

func (m *StatechainBlock) String() string

func (*StatechainBlock) Unmarshal

func (m *StatechainBlock) Unmarshal(dAtA []byte) error

type Transaction

type Transaction struct {
	TxHash    string `protobuf:"bytes,1,opt,name=txHash,proto3" json:"txHash,omitempty"`
	ImageHash string `protobuf:"bytes,2,opt,name=imageHash,proto3" json:"imageHash,omitempty"`
	Method    string `protobuf:"bytes,3,opt,name=method,proto3" json:"method,omitempty"`
	// google.protobuf.Any payload = 4;
	Payload []byte `protobuf:"bytes,4,opt,name=payload,proto3" json:"payload,omitempty"`
	From    string `protobuf:"bytes,5,opt,name=from,proto3" json:"from,omitempty"`
	Sig     *TxSig `protobuf:"bytes,6,opt,name=sig" json:"sig,omitempty"`
}

func (*Transaction) Descriptor

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

func (*Transaction) GetFrom

func (m *Transaction) GetFrom() string

func (*Transaction) GetImageHash

func (m *Transaction) GetImageHash() string

func (*Transaction) GetMethod

func (m *Transaction) GetMethod() string

func (*Transaction) GetPayload

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

func (*Transaction) GetSig

func (m *Transaction) GetSig() *TxSig

func (*Transaction) GetTxHash

func (m *Transaction) GetTxHash() string

func (*Transaction) Marshal

func (m *Transaction) Marshal() (dAtA []byte, err error)

func (*Transaction) MarshalTo

func (m *Transaction) MarshalTo(dAtA []byte) (int, error)

func (*Transaction) ProtoMessage

func (*Transaction) ProtoMessage()

func (*Transaction) Reset

func (m *Transaction) Reset()

func (*Transaction) Size

func (m *Transaction) Size() (n int)

func (*Transaction) String

func (m *Transaction) String() string

func (*Transaction) Unmarshal

func (m *Transaction) Unmarshal(dAtA []byte) error

type TxSig

type TxSig struct {
	R string `protobuf:"bytes,1,opt,name=r,proto3" json:"r,omitempty"`
	S string `protobuf:"bytes,2,opt,name=s,proto3" json:"s,omitempty"`
}

func (*TxSig) Descriptor

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

func (*TxSig) GetR

func (m *TxSig) GetR() string

func (*TxSig) GetS

func (m *TxSig) GetS() string

func (*TxSig) Marshal

func (m *TxSig) Marshal() (dAtA []byte, err error)

func (*TxSig) MarshalTo

func (m *TxSig) MarshalTo(dAtA []byte) (int, error)

func (*TxSig) ProtoMessage

func (*TxSig) ProtoMessage()

func (*TxSig) Reset

func (m *TxSig) Reset()

func (*TxSig) Size

func (m *TxSig) Size() (n int)

func (*TxSig) String

func (m *TxSig) String() string

func (*TxSig) Unmarshal

func (m *TxSig) Unmarshal(dAtA []byte) error

Jump to

Keyboard shortcuts

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