...

Package naive

import "github.com/SmartBFT-Go/consensus/examples/naive_chain"
Overview
Index

Overview ▾

Index ▾

type Block
type BlockData
    func BlockDataFromBytes(rawBlock []byte) *BlockData
    func (b BlockData) ToBytes() []byte
type BlockHeader
    func BlockHeaderFromBytes(rawHeader []byte) *BlockHeader
    func (header BlockHeader) ToBytes() []byte
type Chain
    func NewChain(id uint64, in Ingress, out Egress, logger smart.Logger, opts NetworkOptions, testDir string) *Chain
    func (chain *Chain) Listen() Block
    func (chain *Chain) Order(txn Transaction) error
type Egress
type FwdMessage
    func (*FwdMessage) Descriptor() ([]byte, []int)
    func (m *FwdMessage) GetPayload() []byte
    func (m *FwdMessage) GetSender() uint64
    func (*FwdMessage) ProtoMessage()
    func (m *FwdMessage) Reset()
    func (m *FwdMessage) String() string
    func (m *FwdMessage) XXX_DiscardUnknown()
    func (m *FwdMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
    func (m *FwdMessage) XXX_Merge(src proto.Message)
    func (m *FwdMessage) XXX_Size() int
    func (m *FwdMessage) XXX_Unmarshal(b []byte) error
type Ingress
type NetworkOptions
type Node
    func NewNode(id uint64, in Ingress, out Egress, deliverChan chan<- *Block, logger smart.Logger, opts NetworkOptions, testDir string) *Node
    func (n *Node) AssembleProposal(metadata []byte, requests [][]byte) bft.Proposal
    func (n *Node) Deliver(proposal bft.Proposal, signature []bft.Signature) bft.Reconfig
    func (n *Node) Nodes() []uint64
    func (*Node) RequestID(req []byte) bft.RequestInfo
    func (*Node) RequestsFromProposal(proposal bft.Proposal) []bft.RequestInfo
    func (n *Node) SendConsensus(targetID uint64, message *smartbftprotos.Message)
    func (n *Node) SendTransaction(targetID uint64, request []byte)
    func (*Node) Sign(msg []byte) []byte
    func (n *Node) SignProposal(bft.Proposal) *bft.Signature
    func (n *Node) Start()
    func (n *Node) Stop()
    func (*Node) Sync() bft.SyncResponse
    func (*Node) VerificationSequence() uint64
    func (*Node) VerifyConsenterSig(_ bft.Signature, prop bft.Proposal) error
    func (*Node) VerifyProposal(proposal bft.Proposal) ([]bft.RequestInfo, error)
    func (*Node) VerifyRequest(val []byte) (bft.RequestInfo, error)
    func (*Node) VerifySignature(signature bft.Signature) error
type Transaction
    func TransactionFromBytes(rawTxn []byte) *Transaction
    func (txn Transaction) ToBytes() []byte

Package files

chain.go node.go test_message.pb.go

type Block

type Block struct {
    Sequence     uint64
    PrevHash     string
    Transactions []Transaction
}

type BlockData

type BlockData struct {
    Transactions [][]byte
}

func BlockDataFromBytes

func BlockDataFromBytes(rawBlock []byte) *BlockData

func (BlockData) ToBytes

func (b BlockData) ToBytes() []byte

type BlockHeader

type BlockHeader struct {
    Sequence int64
    PrevHash string
    DataHash string
}

func BlockHeaderFromBytes

func BlockHeaderFromBytes(rawHeader []byte) *BlockHeader

func (BlockHeader) ToBytes

func (header BlockHeader) ToBytes() []byte

type Chain

type Chain struct {
    // contains filtered or unexported fields
}

func NewChain

func NewChain(id uint64, in Ingress, out Egress, logger smart.Logger, opts NetworkOptions, testDir string) *Chain

func (*Chain) Listen

func (chain *Chain) Listen() Block

func (*Chain) Order

func (chain *Chain) Order(txn Transaction) error

type Egress

type Egress map[int]chan<- proto.Message

type FwdMessage

type FwdMessage struct {
    Sender               uint64   `protobuf:"varint,1,opt,name=sender,proto3" json:"sender,omitempty"`
    Payload              []byte   `protobuf:"bytes,2,opt,name=payload,proto3" json:"payload,omitempty"`
    XXX_NoUnkeyedLiteral struct{} `json:"-"`
    XXX_unrecognized     []byte   `json:"-"`
    XXX_sizecache        int32    `json:"-"`
}

func (*FwdMessage) Descriptor

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

func (*FwdMessage) GetPayload

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

func (*FwdMessage) GetSender

func (m *FwdMessage) GetSender() uint64

func (*FwdMessage) ProtoMessage

func (*FwdMessage) ProtoMessage()

func (*FwdMessage) Reset

func (m *FwdMessage) Reset()

func (*FwdMessage) String

func (m *FwdMessage) String() string

func (*FwdMessage) XXX_DiscardUnknown

func (m *FwdMessage) XXX_DiscardUnknown()

func (*FwdMessage) XXX_Marshal

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

func (*FwdMessage) XXX_Merge

func (m *FwdMessage) XXX_Merge(src proto.Message)

func (*FwdMessage) XXX_Size

func (m *FwdMessage) XXX_Size() int

func (*FwdMessage) XXX_Unmarshal

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

type Ingress

type Ingress map[int]<-chan proto.Message

type NetworkOptions

type NetworkOptions struct {
    NumNodes     int
    BatchSize    uint64
    BatchTimeout time.Duration
}

type Node

type Node struct {
    // contains filtered or unexported fields
}

func NewNode

func NewNode(id uint64, in Ingress, out Egress, deliverChan chan<- *Block, logger smart.Logger, opts NetworkOptions, testDir string) *Node

func (*Node) AssembleProposal

func (n *Node) AssembleProposal(metadata []byte, requests [][]byte) bft.Proposal

func (*Node) Deliver

func (n *Node) Deliver(proposal bft.Proposal, signature []bft.Signature) bft.Reconfig

func (*Node) Nodes

func (n *Node) Nodes() []uint64

func (*Node) RequestID

func (*Node) RequestID(req []byte) bft.RequestInfo

func (*Node) RequestsFromProposal

func (*Node) RequestsFromProposal(proposal bft.Proposal) []bft.RequestInfo

func (*Node) SendConsensus

func (n *Node) SendConsensus(targetID uint64, message *smartbftprotos.Message)

func (*Node) SendTransaction

func (n *Node) SendTransaction(targetID uint64, request []byte)

func (*Node) Sign

func (*Node) Sign(msg []byte) []byte

func (*Node) SignProposal

func (n *Node) SignProposal(bft.Proposal) *bft.Signature

func (*Node) Start

func (n *Node) Start()

func (*Node) Stop

func (n *Node) Stop()

func (*Node) Sync

func (*Node) Sync() bft.SyncResponse

func (*Node) VerificationSequence

func (*Node) VerificationSequence() uint64

func (*Node) VerifyConsenterSig

func (*Node) VerifyConsenterSig(_ bft.Signature, prop bft.Proposal) error

func (*Node) VerifyProposal

func (*Node) VerifyProposal(proposal bft.Proposal) ([]bft.RequestInfo, error)

func (*Node) VerifyRequest

func (*Node) VerifyRequest(val []byte) (bft.RequestInfo, error)

func (*Node) VerifySignature

func (*Node) VerifySignature(signature bft.Signature) error

type Transaction

type Transaction struct {
    ClientID string
    ID       string
}

func TransactionFromBytes

func TransactionFromBytes(rawTxn []byte) *Transaction

func (Transaction) ToBytes

func (txn Transaction) ToBytes() []byte