Documentation
¶
Overview ¶
Package broadcast implements the network broadcast and consensus within a shard.
Index ¶
- Variables
- func Replay(dir string, nodeID uint64, g *blockmania.Graph, start uint64, batch int) error
- type AckBroadcast
- func (*AckBroadcast) Descriptor() ([]byte, []int)
- func (m *AckBroadcast) GetLast() uint64
- func (*AckBroadcast) ProtoMessage()
- func (m *AckBroadcast) Reset()
- func (m *AckBroadcast) String() string
- func (m *AckBroadcast) XXX_DiscardUnknown()
- func (m *AckBroadcast) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *AckBroadcast) XXX_Merge(src proto.Message)
- func (m *AckBroadcast) XXX_Size() int
- func (m *AckBroadcast) XXX_Unmarshal(b []byte) error
- type Block
- func (*Block) Descriptor() ([]byte, []int)
- func (m *Block) GetNode() uint64
- func (m *Block) GetPrevious() *SignedData
- func (m *Block) GetReferences() []*SignedData
- func (m *Block) GetRound() uint64
- func (m *Block) GetTransactions() *Transactions
- func (b *Block) Iter() *TxIterator
- func (*Block) ProtoMessage()
- func (m *Block) Reset()
- func (m *Block) String() string
- func (m *Block) XXX_DiscardUnknown()
- func (m *Block) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *Block) XXX_Merge(src proto.Message)
- func (m *Block) XXX_Size() int
- func (m *Block) XXX_Unmarshal(b []byte) error
- type BlockReference
- func (*BlockReference) Descriptor() ([]byte, []int)
- func (m *BlockReference) GetHash() []byte
- func (m *BlockReference) GetNode() uint64
- func (m *BlockReference) GetRound() uint64
- func (*BlockReference) ProtoMessage()
- func (m *BlockReference) Reset()
- func (b *BlockReference) Size() int
- func (m *BlockReference) String() string
- func (m *BlockReference) XXX_DiscardUnknown()
- func (m *BlockReference) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *BlockReference) XXX_Merge(src proto.Message)
- func (m *BlockReference) XXX_Size() int
- func (m *BlockReference) XXX_Unmarshal(b []byte) error
- type Broadcaster
- type Callback
- type Config
- type GetBlocks
- func (*GetBlocks) Descriptor() ([]byte, []int)
- func (m *GetBlocks) GetBlocks() []*BlockReference
- func (*GetBlocks) ProtoMessage()
- func (m *GetBlocks) Reset()
- func (m *GetBlocks) String() string
- func (m *GetBlocks) XXX_DiscardUnknown()
- func (m *GetBlocks) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *GetBlocks) XXX_Merge(src proto.Message)
- func (m *GetBlocks) XXX_Size() int
- func (m *GetBlocks) XXX_Unmarshal(b []byte) error
- type GetRounds
- func (*GetRounds) Descriptor() ([]byte, []int)
- func (m *GetRounds) GetRounds() []uint64
- func (*GetRounds) ProtoMessage()
- func (m *GetRounds) Reset()
- func (m *GetRounds) String() string
- func (m *GetRounds) XXX_DiscardUnknown()
- func (m *GetRounds) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *GetRounds) XXX_Merge(src proto.Message)
- func (m *GetRounds) XXX_Size() int
- func (m *GetRounds) XXX_Unmarshal(b []byte) error
- type ListBlocks
- func (*ListBlocks) Descriptor() ([]byte, []int)
- func (m *ListBlocks) GetBlocks() []*SignedData
- func (*ListBlocks) ProtoMessage()
- func (m *ListBlocks) Reset()
- func (m *ListBlocks) String() string
- func (m *ListBlocks) XXX_DiscardUnknown()
- func (m *ListBlocks) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *ListBlocks) XXX_Merge(src proto.Message)
- func (m *ListBlocks) XXX_Size() int
- func (m *ListBlocks) XXX_Unmarshal(b []byte) error
- type OP
- type Service
- type SignedData
- func (s *SignedData) Block() (*Block, error)
- func (*SignedData) Descriptor() ([]byte, []int)
- func (s *SignedData) Digest() []byte
- func (m *SignedData) GetData() []byte
- func (m *SignedData) GetSignature() []byte
- func (*SignedData) ProtoMessage()
- func (m *SignedData) Reset()
- func (s *SignedData) Size() int
- func (m *SignedData) String() string
- func (m *SignedData) XXX_DiscardUnknown()
- func (m *SignedData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *SignedData) XXX_Merge(src proto.Message)
- func (m *SignedData) XXX_Size() int
- func (m *SignedData) XXX_Unmarshal(b []byte) error
- type TransactionData
- type TransactionList
- type Transactions
- func (*Transactions) Descriptor() ([]byte, []int)
- func (m *Transactions) GetCount() uint64
- func (m *Transactions) GetData() []byte
- func (*Transactions) ProtoMessage()
- func (m *Transactions) Reset()
- func (m *Transactions) String() string
- func (m *Transactions) XXX_DiscardUnknown()
- func (m *Transactions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *Transactions) XXX_Merge(src proto.Message)
- func (m *Transactions) XXX_Size() int
- func (m *Transactions) XXX_Unmarshal(b []byte) error
- type TxIterator
Constants ¶
This section is empty.
Variables ¶
var OP_name = map[int32]string{
0: "UNKNOWN",
1: "ACK_BROADCAST",
2: "BROADCAST",
3: "GET_BLOCKS",
4: "GET_ROUNDS",
5: "LIST_BLOCKS",
}
var OP_value = map[string]int32{
"UNKNOWN": 0,
"ACK_BROADCAST": 1,
"BROADCAST": 2,
"GET_BLOCKS": 3,
"GET_ROUNDS": 4,
"LIST_BLOCKS": 5,
}
Functions ¶
Types ¶
type AckBroadcast ¶
type AckBroadcast struct { Last uint64 `protobuf:"varint,1,opt,name=last,proto3" json:"last,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*AckBroadcast) Descriptor ¶
func (*AckBroadcast) Descriptor() ([]byte, []int)
func (*AckBroadcast) GetLast ¶
func (m *AckBroadcast) GetLast() uint64
func (*AckBroadcast) ProtoMessage ¶
func (*AckBroadcast) ProtoMessage()
func (*AckBroadcast) Reset ¶
func (m *AckBroadcast) Reset()
func (*AckBroadcast) String ¶
func (m *AckBroadcast) String() string
func (*AckBroadcast) XXX_DiscardUnknown ¶
func (m *AckBroadcast) XXX_DiscardUnknown()
func (*AckBroadcast) XXX_Marshal ¶
func (m *AckBroadcast) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*AckBroadcast) XXX_Merge ¶
func (dst *AckBroadcast) XXX_Merge(src proto.Message)
func (*AckBroadcast) XXX_Size ¶
func (m *AckBroadcast) XXX_Size() int
func (*AckBroadcast) XXX_Unmarshal ¶
func (m *AckBroadcast) XXX_Unmarshal(b []byte) error
type Block ¶
type Block struct { Node uint64 `protobuf:"varint,1,opt,name=node,proto3" json:"node,omitempty"` Previous *SignedData `protobuf:"bytes,2,opt,name=previous" json:"previous,omitempty"` References []*SignedData `protobuf:"bytes,3,rep,name=references" json:"references,omitempty"` Round uint64 `protobuf:"varint,4,opt,name=round,proto3" json:"round,omitempty"` Transactions *Transactions `protobuf:"bytes,5,opt,name=transactions" json:"transactions,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*Block) Descriptor ¶
func (*Block) GetPrevious ¶
func (m *Block) GetPrevious() *SignedData
func (*Block) GetReferences ¶
func (m *Block) GetReferences() []*SignedData
func (*Block) GetTransactions ¶
func (m *Block) GetTransactions() *Transactions
func (*Block) Iter ¶
func (b *Block) Iter() *TxIterator
Iter returns a iterator for the block's transactions.
func (*Block) ProtoMessage ¶
func (*Block) ProtoMessage()
func (*Block) XXX_DiscardUnknown ¶
func (m *Block) XXX_DiscardUnknown()
func (*Block) XXX_Marshal ¶
func (*Block) XXX_Unmarshal ¶
type BlockReference ¶
type BlockReference struct { Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` Node uint64 `protobuf:"varint,2,opt,name=node,proto3" json:"node,omitempty"` Round uint64 `protobuf:"varint,3,opt,name=round,proto3" json:"round,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*BlockReference) Descriptor ¶
func (*BlockReference) Descriptor() ([]byte, []int)
func (*BlockReference) GetHash ¶
func (m *BlockReference) GetHash() []byte
func (*BlockReference) GetNode ¶
func (m *BlockReference) GetNode() uint64
func (*BlockReference) GetRound ¶
func (m *BlockReference) GetRound() uint64
func (*BlockReference) ProtoMessage ¶
func (*BlockReference) ProtoMessage()
func (*BlockReference) Reset ¶
func (m *BlockReference) Reset()
func (*BlockReference) Size ¶
func (b *BlockReference) Size() int
Size returns the rough size of a BlockReference in bytes.
func (*BlockReference) String ¶
func (m *BlockReference) String() string
func (*BlockReference) XXX_DiscardUnknown ¶
func (m *BlockReference) XXX_DiscardUnknown()
func (*BlockReference) XXX_Marshal ¶
func (m *BlockReference) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*BlockReference) XXX_Merge ¶
func (dst *BlockReference) XXX_Merge(src proto.Message)
func (*BlockReference) XXX_Size ¶
func (m *BlockReference) XXX_Size() int
func (*BlockReference) XXX_Unmarshal ¶
func (m *BlockReference) XXX_Unmarshal(b []byte) error
type Broadcaster ¶
type Callback ¶
type Callback func(round uint64, blocks []*SignedData)
Callback defines the delivery callback registered with the broadcast service. The callback should call Acknowledge at some point so as to mark the delivery of the round as successful.
type Config ¶
type Config struct { Broadcast *config.Broadcast Connections *config.Connections Directory string Key signature.KeyPair Keys map[uint64]signature.PublicKey MaxPayload int NetConsensus *config.NetConsensus NodeConsensus *config.NodeConsensus NodeID uint64 Peers []uint64 }
Config for the broadcast service.
type GetBlocks ¶
type GetBlocks struct { Blocks []*BlockReference `protobuf:"bytes,1,rep,name=blocks" json:"blocks,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*GetBlocks) Descriptor ¶
func (*GetBlocks) GetBlocks ¶
func (m *GetBlocks) GetBlocks() []*BlockReference
func (*GetBlocks) ProtoMessage ¶
func (*GetBlocks) ProtoMessage()
func (*GetBlocks) XXX_DiscardUnknown ¶
func (m *GetBlocks) XXX_DiscardUnknown()
func (*GetBlocks) XXX_Marshal ¶
func (*GetBlocks) XXX_Unmarshal ¶
type GetRounds ¶
type GetRounds struct { Rounds []uint64 `protobuf:"varint,1,rep,packed,name=rounds" json:"rounds,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*GetRounds) Descriptor ¶
func (*GetRounds) ProtoMessage ¶
func (*GetRounds) ProtoMessage()
func (*GetRounds) XXX_DiscardUnknown ¶
func (m *GetRounds) XXX_DiscardUnknown()
func (*GetRounds) XXX_Marshal ¶
func (*GetRounds) XXX_Unmarshal ¶
type ListBlocks ¶
type ListBlocks struct { Blocks []*SignedData `protobuf:"bytes,1,rep,name=blocks" json:"blocks,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*ListBlocks) Descriptor ¶
func (*ListBlocks) Descriptor() ([]byte, []int)
func (*ListBlocks) GetBlocks ¶
func (m *ListBlocks) GetBlocks() []*SignedData
func (*ListBlocks) ProtoMessage ¶
func (*ListBlocks) ProtoMessage()
func (*ListBlocks) Reset ¶
func (m *ListBlocks) Reset()
func (*ListBlocks) String ¶
func (m *ListBlocks) String() string
func (*ListBlocks) XXX_DiscardUnknown ¶
func (m *ListBlocks) XXX_DiscardUnknown()
func (*ListBlocks) XXX_Marshal ¶
func (m *ListBlocks) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*ListBlocks) XXX_Merge ¶
func (dst *ListBlocks) XXX_Merge(src proto.Message)
func (*ListBlocks) XXX_Size ¶
func (m *ListBlocks) XXX_Size() int
func (*ListBlocks) XXX_Unmarshal ¶
func (m *ListBlocks) XXX_Unmarshal(b []byte) error
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service implements the broadcast and consensus system.
TODO(tav): pad/re-order to minimise false sharing.
func (*Service) Acknowledge ¶
Acknowledge should be called by BroadcastEnd in the registered Callback to mark a particular round as being fully delivered. If not, all unacknowledged rounds will be replayed when the node restarts.
func (*Service) AddTransaction ¶
AddTransaction adds the given transaction data onto a queue to be added to the current block.
func (*Service) Handle ¶
Handle implements the service Handler interface for handling messages received over a connection.
type SignedData ¶
type SignedData struct { Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` Signature []byte `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
The data of a SignedData may either be an encoded Block or BlockReference.
func (*SignedData) Block ¶
func (s *SignedData) Block() (*Block, error)
Block returns the decoded Block struct assuming the SignedData is of a Block.
func (*SignedData) Descriptor ¶
func (*SignedData) Descriptor() ([]byte, []int)
func (*SignedData) Digest ¶
func (s *SignedData) Digest() []byte
Digest returns the hash of the underlying data.
func (*SignedData) GetData ¶
func (m *SignedData) GetData() []byte
func (*SignedData) GetSignature ¶
func (m *SignedData) GetSignature() []byte
func (*SignedData) ProtoMessage ¶
func (*SignedData) ProtoMessage()
func (*SignedData) Reset ¶
func (m *SignedData) Reset()
func (*SignedData) Size ¶
func (s *SignedData) Size() int
Size returns the rough size of the SignedData in bytes.
func (*SignedData) String ¶
func (m *SignedData) String() string
func (*SignedData) XXX_DiscardUnknown ¶
func (m *SignedData) XXX_DiscardUnknown()
func (*SignedData) XXX_Marshal ¶
func (m *SignedData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*SignedData) XXX_Merge ¶
func (dst *SignedData) XXX_Merge(src proto.Message)
func (*SignedData) XXX_Size ¶
func (m *SignedData) XXX_Size() int
func (*SignedData) XXX_Unmarshal ¶
func (m *SignedData) XXX_Unmarshal(b []byte) error
type TransactionData ¶
TransactionData represents the transaction's combined data and fee.
type TransactionList ¶
type TransactionList []TransactionData
TransactionList wraps a slice of TransactionData for the purposes of sorting.
func (TransactionList) Sort ¶
func (t TransactionList) Sort()
Sort orders the TransactionList in descending order of the transaction fee and then hash if the fees are equal.
type Transactions ¶
type Transactions struct { Count uint64 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"` Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*Transactions) Descriptor ¶
func (*Transactions) Descriptor() ([]byte, []int)
func (*Transactions) GetCount ¶
func (m *Transactions) GetCount() uint64
func (*Transactions) GetData ¶
func (m *Transactions) GetData() []byte
func (*Transactions) ProtoMessage ¶
func (*Transactions) ProtoMessage()
func (*Transactions) Reset ¶
func (m *Transactions) Reset()
func (*Transactions) String ¶
func (m *Transactions) String() string
func (*Transactions) XXX_DiscardUnknown ¶
func (m *Transactions) XXX_DiscardUnknown()
func (*Transactions) XXX_Marshal ¶
func (m *Transactions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*Transactions) XXX_Merge ¶
func (dst *Transactions) XXX_Merge(src proto.Message)
func (*Transactions) XXX_Size ¶
func (m *Transactions) XXX_Size() int
func (*Transactions) XXX_Unmarshal ¶
func (m *Transactions) XXX_Unmarshal(b []byte) error
type TxIterator ¶
TxIterator provides support for iterating over a Block's transactions.
func (*TxIterator) Next ¶
func (t *TxIterator) Next()
Next moves the iterator forward. The TxData and TxFee values of the iterator are only valid until the next call to Next().
func (*TxIterator) Valid ¶
func (t *TxIterator) Valid() bool
Valid returns whether the iterator is still valid and has more elements to iterate over.