por

package
v0.8.1-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2019 License: Apache-2.0 Imports: 27 Imported by: 13

Documentation

Index

Constants

View Source
const (
	// The height of signature chain which run for block proposer should be (local block height -1 + 5)
	// -1 means that:
	//  local block height may heigher than neighbor node at most 1
	// +5 means that:
	// if local block height is n, then n + 3 signature chain is in consensus) +
	//  1 (since local node height may lower than neighbors at most 1) +
	//  1 (for fully propagate)
	SigChainBlockHeightOffset  = 1
	SigChainMiningHeightOffset = 4
)

Variables

View Source
var (
	ErrInvalidLengthPorpackage = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowPorpackage   = fmt.Errorf("proto: integer overflow")
)
View Source
var (
	ErrInvalidLengthSigchain = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowSigchain   = fmt.Errorf("proto: integer overflow")
)
View Source
var SigAlgo_name = map[int32]string{
	0: "ECDSA",
}
View Source
var SigAlgo_value = map[string]int32{
	"ECDSA": 0,
}

Functions

func InitPorServer

func InitPorServer(account *vault.Account, id []byte) error

Types

type PorPackage

type PorPackage struct {
	VoteForHeight uint32    `protobuf:"varint,1,opt,name=VoteForHeight,proto3" json:"VoteForHeight,omitempty"`
	Owner         []byte    `protobuf:"bytes,2,opt,name=Owner,proto3" json:"Owner,omitempty"`
	BlockHash     []byte    `protobuf:"bytes,3,opt,name=BlockHash,proto3" json:"BlockHash,omitempty"`
	TxHash        []byte    `protobuf:"bytes,4,opt,name=TxHash,proto3" json:"TxHash,omitempty"`
	SigHash       []byte    `protobuf:"bytes,5,opt,name=SigHash,proto3" json:"SigHash,omitempty"`
	SigChain      *SigChain `protobuf:"bytes,6,opt,name=SigChain" json:"SigChain,omitempty"`
}

func NewPopulatedPorPackage

func NewPopulatedPorPackage(r randyPorpackage, easy bool) *PorPackage

func NewPorPackage

func NewPorPackage(txn *transaction.Transaction) (*PorPackage, error)

func (*PorPackage) CompareTo

func (pp *PorPackage) CompareTo(o *PorPackage) int

func (*PorPackage) Descriptor

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

func (*PorPackage) DumpInfo

func (pp *PorPackage) DumpInfo()

func (*PorPackage) Equal

func (this *PorPackage) Equal(that interface{}) bool

func (*PorPackage) GetBlockHash

func (m *PorPackage) GetBlockHash() []byte

func (*PorPackage) GetOwner

func (m *PorPackage) GetOwner() []byte

func (*PorPackage) GetSigChain

func (m *PorPackage) GetSigChain() *SigChain

func (*PorPackage) GetSigHash

func (m *PorPackage) GetSigHash() []byte

func (*PorPackage) GetTxHash

func (m *PorPackage) GetTxHash() []byte

func (*PorPackage) GetVoteForHeight

func (m *PorPackage) GetVoteForHeight() uint32

func (*PorPackage) GoString

func (this *PorPackage) GoString() string

func (*PorPackage) Marshal

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

func (*PorPackage) MarshalTo

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

func (*PorPackage) ProtoMessage

func (*PorPackage) ProtoMessage()

func (*PorPackage) Reset

func (m *PorPackage) Reset()

func (*PorPackage) Size

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

func (*PorPackage) String

func (this *PorPackage) String() string

func (*PorPackage) Unmarshal

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

func (*PorPackage) XXX_DiscardUnknown

func (m *PorPackage) XXX_DiscardUnknown()

func (*PorPackage) XXX_Marshal

func (m *PorPackage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PorPackage) XXX_Merge

func (dst *PorPackage) XXX_Merge(src proto.Message)

func (*PorPackage) XXX_Size

func (m *PorPackage) XXX_Size() int

func (*PorPackage) XXX_Unmarshal

func (m *PorPackage) XXX_Unmarshal(b []byte) error

type PorPackages

type PorPackages []*PorPackage

func (PorPackages) Len

func (c PorPackages) Len() int

func (PorPackages) Less

func (c PorPackages) Less(i, j int) bool

func (PorPackages) Swap

func (c PorPackages) Swap(i, j int)

type PorServer

type PorServer struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func GetPorServer

func GetPorServer() *PorServer

func NewPorServer

func NewPorServer(account *vault.Account, id []byte) *PorServer

func (*PorServer) AddSigChainFromTx

func (ps *PorServer) AddSigChainFromTx(txn *transaction.Transaction, currentHeight uint32) (bool, error)

func (*PorServer) CreateSigChain

func (ps *PorServer) CreateSigChain(dataSize uint32, dataHash, blockHash *common.Uint256, srcID,
	destPubkey, nextPubkey []byte, mining bool) (*SigChain, error)

func (*PorServer) CreateSigChainForClient

func (ps *PorServer) CreateSigChainForClient(dataSize uint32, dataHash, blockHash *common.Uint256, srcID,
	srcPubkey, destPubkey, signature []byte, sigAlgo SigAlgo) (*SigChain, error)

func (*PorServer) GetMiningSigChain

func (ps *PorServer) GetMiningSigChain(height uint32) (*SigChain, error)

func (*PorServer) GetMiningSigChainTxn

func (ps *PorServer) GetMiningSigChainTxn(txnHash common.Uint256) (*transaction.Transaction, error)

func (*PorServer) GetMiningSigChainTxnHash

func (ps *PorServer) GetMiningSigChainTxnHash(height uint32) (common.Uint256, error)

func (*PorServer) GetSignature

func (ps *PorServer) GetSignature(sc *SigChain) ([]byte, error)

func (*PorServer) GetThreshold

func (ps *PorServer) GetThreshold() common.Uint256

func (*PorServer) IsFinal

func (ps *PorServer) IsFinal(sc *SigChain) bool

func (*PorServer) IsSatisfyThreshold

func (ps *PorServer) IsSatisfyThreshold() bool

func (*PorServer) LenOfSigChain

func (ps *PorServer) LenOfSigChain(sc *SigChain) int

func (*PorServer) Sign

func (ps *PorServer) Sign(sc *SigChain, nextPubkey []byte, mining bool) error

func (*PorServer) UpdateThreshold

func (ps *PorServer) UpdateThreshold() common.Uint256

func (*PorServer) Verify

func (ps *PorServer) Verify(sc *SigChain) error

type PorStore

type PorStore interface {
	GetHeightByBlockHash(hash Uint256) (uint32, error)
}
var Store PorStore

type SigAlgo

type SigAlgo int32
const (
	ECDSA SigAlgo = 0
)

func (SigAlgo) EnumDescriptor

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

func (SigAlgo) String

func (x SigAlgo) String() string

type SigChain

type SigChain struct {
	Nonce      uint32          `protobuf:"varint,1,opt,name=Nonce,proto3" json:"Nonce,omitempty"`
	DataSize   uint32          `protobuf:"varint,2,opt,name=DataSize,proto3" json:"DataSize,omitempty"`
	DataHash   []byte          `protobuf:"bytes,3,opt,name=DataHash,proto3" json:"DataHash,omitempty"`
	BlockHash  []byte          `protobuf:"bytes,4,opt,name=BlockHash,proto3" json:"BlockHash,omitempty"`
	SrcPubkey  []byte          `protobuf:"bytes,5,opt,name=SrcPubkey,proto3" json:"SrcPubkey,omitempty"`
	DestPubkey []byte          `protobuf:"bytes,6,opt,name=DestPubkey,proto3" json:"DestPubkey,omitempty"`
	Elems      []*SigChainElem `protobuf:"bytes,7,rep,name=Elems" json:"Elems,omitempty"`
}

func NewPopulatedSigChain

func NewPopulatedSigChain(r randySigchain, easy bool) *SigChain

func NewSigChain

func NewSigChain(srcAccount *vault.Account, dataSize uint32, dataHash, blockHash, srcID,
	destPubkey, nextPubkey []byte, mining bool) (*SigChain, error)

first relay node starts a new signature chain which consists of meta data and the first element.

func NewSigChainWithSignature

func NewSigChainWithSignature(dataSize uint32, dataHash, blockHash, srcID, srcPubkey, destPubkey, nextPubkey,
	signature []byte, algo SigAlgo, mining bool) (*SigChain, error)

func (*SigChain) AddLastSignature

func (sc *SigChain) AddLastSignature(signature []byte) error

func (*SigChain) Descriptor

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

func (*SigChain) DumpInfo

func (sc *SigChain) DumpInfo()

func (*SigChain) Equal

func (this *SigChain) Equal(that interface{}) bool

func (*SigChain) ExtendElement

func (sc *SigChain) ExtendElement(addr, nextPubkey []byte, mining bool) ([]byte, error)

func (*SigChain) GetBlockHash

func (m *SigChain) GetBlockHash() []byte

func (*SigChain) GetDataHash

func (m *SigChain) GetDataHash() []byte

func (*SigChain) GetDataSize

func (m *SigChain) GetDataSize() uint32

func (*SigChain) GetDestPubkey

func (m *SigChain) GetDestPubkey() []byte

func (*SigChain) GetElems

func (m *SigChain) GetElems() []*SigChainElem

func (*SigChain) GetLastPubkey

func (sc *SigChain) GetLastPubkey() ([]byte, error)

func (*SigChain) GetMiner

func (sc *SigChain) GetMiner() ([]byte, []byte, error)

func (*SigChain) GetNonce

func (m *SigChain) GetNonce() uint32

func (*SigChain) GetOwner

func (sc *SigChain) GetOwner() ([]byte, error)

func (*SigChain) GetSignature

func (sc *SigChain) GetSignature() ([]byte, error)

func (*SigChain) GetSignerIndex

func (sc *SigChain) GetSignerIndex(pubkey []byte) (int, error)

func (*SigChain) GetSrcPubkey

func (m *SigChain) GetSrcPubkey() []byte

func (*SigChain) GoString

func (this *SigChain) GoString() string

func (*SigChain) IsFinal

func (sc *SigChain) IsFinal() bool

func (*SigChain) Length

func (sc *SigChain) Length() int

Length returns element num in current signature chain

func (*SigChain) Marshal

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

func (*SigChain) MarshalTo

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

func (*SigChain) Path

func (sc *SigChain) Path() [][]byte

Path returns signer path in signature chain.

func (*SigChain) ProtoMessage

func (*SigChain) ProtoMessage()

func (*SigChain) Reset

func (m *SigChain) Reset()

func (*SigChain) SerializationMetadata

func (sc *SigChain) SerializationMetadata(w io.Writer) error

func (*SigChain) Sign

func (sc *SigChain) Sign(addr, nextPubkey []byte, mining bool, signer *vault.Account) error

Sign new created signature chain with local wallet.

func (*SigChain) SignatureHash

func (sc *SigChain) SignatureHash() ([]byte, error)

func (*SigChain) Size

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

func (*SigChain) String

func (this *SigChain) String() string

func (*SigChain) Unmarshal

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

func (*SigChain) Verify

func (sc *SigChain) Verify() error

Verify returns result of signature chain verification.

func (*SigChain) VerifyPath

func (sc *SigChain) VerifyPath() error

func (*SigChain) XXX_DiscardUnknown

func (m *SigChain) XXX_DiscardUnknown()

func (*SigChain) XXX_Marshal

func (m *SigChain) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SigChain) XXX_Merge

func (dst *SigChain) XXX_Merge(src proto.Message)

func (*SigChain) XXX_Size

func (m *SigChain) XXX_Size() int

func (*SigChain) XXX_Unmarshal

func (m *SigChain) XXX_Unmarshal(b []byte) error

type SigChainElem

type SigChainElem struct {
	Addr       []byte  `protobuf:"bytes,1,opt,name=Addr,proto3" json:"Addr,omitempty"`
	NextPubkey []byte  `protobuf:"bytes,2,opt,name=NextPubkey,proto3" json:"NextPubkey,omitempty"`
	Mining     bool    `protobuf:"varint,3,opt,name=Mining,proto3" json:"Mining,omitempty"`
	SigAlgo    SigAlgo `protobuf:"varint,4,opt,name=SigAlgo,proto3,enum=por.SigAlgo" json:"SigAlgo,omitempty"`
	Signature  []byte  `protobuf:"bytes,5,opt,name=Signature,proto3" json:"Signature,omitempty"`
}

func NewPopulatedSigChainElem

func NewPopulatedSigChainElem(r randySigchain, easy bool) *SigChainElem

func NewSigChainElem

func NewSigChainElem(addr, nextPubkey []byte, mining bool) *SigChainElem

func (*SigChainElem) Descriptor

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

func (*SigChainElem) Equal

func (this *SigChainElem) Equal(that interface{}) bool

func (*SigChainElem) GetAddr

func (m *SigChainElem) GetAddr() []byte

func (*SigChainElem) GetMining

func (m *SigChainElem) GetMining() bool

func (*SigChainElem) GetNextPubkey

func (m *SigChainElem) GetNextPubkey() []byte

func (*SigChainElem) GetSigAlgo

func (m *SigChainElem) GetSigAlgo() SigAlgo

func (*SigChainElem) GetSignature

func (m *SigChainElem) GetSignature() []byte

func (*SigChainElem) GoString

func (this *SigChainElem) GoString() string

func (*SigChainElem) Marshal

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

func (*SigChainElem) MarshalTo

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

func (*SigChainElem) ProtoMessage

func (*SigChainElem) ProtoMessage()

func (*SigChainElem) Reset

func (m *SigChainElem) Reset()

func (*SigChainElem) SerializationUnsigned

func (sce *SigChainElem) SerializationUnsigned(w io.Writer) error

func (*SigChainElem) Size

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

func (*SigChainElem) String

func (this *SigChainElem) String() string

func (*SigChainElem) Unmarshal

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

func (*SigChainElem) XXX_DiscardUnknown

func (m *SigChainElem) XXX_DiscardUnknown()

func (*SigChainElem) XXX_Marshal

func (m *SigChainElem) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SigChainElem) XXX_Merge

func (dst *SigChainElem) XXX_Merge(src proto.Message)

func (*SigChainElem) XXX_Size

func (m *SigChainElem) XXX_Size() int

func (*SigChainElem) XXX_Unmarshal

func (m *SigChainElem) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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