Documentation ¶
Index ¶
- Constants
- Variables
- type Block
- func (b *Block) BlockNumber() uint64
- func (b *Block) GetScore() uint32
- func (b *Block) Hash() string
- func (b *Block) Marshal() ([]byte, spec.Links, error)
- func (b *Block) Name() string
- func (b *Block) Namespace() string
- func (b *Block) ParentHash() string
- func (b *Block) PeerID() string
- func (b *Block) ResourceType() string
- func (b *Block) Timestamp() int64
- func (b *Block) Transactions() []spec.Transaction
- func (b *Block) Unmarshal(data []byte, links spec.Links) error
- func (b *Block) Valid() bool
- func (b *Block) Version() string
- type BlockGenerator
- func (g *BlockGenerator) BlockPrototype() spec.Block
- func (g *BlockGenerator) CommitBlock(block spec.Block)
- func (g *BlockGenerator) GenerateBlock(branch []spec.Block) (newBlock spec.Block)
- func (g *BlockGenerator) GenerateGenesisBlock() spec.Block
- func (g *BlockGenerator) ReceiveTransaction(netMsg *spec.NetworkMessage) (spec.Transaction, error)
- func (g *BlockGenerator) TryCommitBlock(newBlock spec.Block, branch []spec.Block) bool
- func (g *BlockGenerator) Type() string
- type BlockMessage
- func (*BlockMessage) Descriptor() ([]byte, []int)
- func (m *BlockMessage) GetBlockNumber() uint64
- func (m *BlockMessage) GetLinks() map[string]string
- func (m *BlockMessage) GetName() string
- func (m *BlockMessage) GetNamespace() string
- func (m *BlockMessage) GetPeerID() string
- func (m *BlockMessage) GetScore() uint32
- func (m *BlockMessage) GetTimestamp() int64
- func (m *BlockMessage) GetVersion() string
- func (*BlockMessage) ProtoMessage()
- func (m *BlockMessage) Reset()
- func (m *BlockMessage) String() string
- func (m *BlockMessage) XXX_DiscardUnknown()
- func (m *BlockMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *BlockMessage) XXX_Merge(src proto.Message)
- func (m *BlockMessage) XXX_Size() int
- func (m *BlockMessage) XXX_Unmarshal(b []byte) error
- type TransactionHandler
Constants ¶
View Source
const (
MaxScore = uint64(^uint32(0))
)
Variables ¶
View Source
var BlockComparator spec.BlockComparator = func(blocks []spec.Block) spec.Block { if len(blocks) == 0 { return nil } if len(blocks) == 1 { return blocks[0] } result := make([]spec.Block, len(blocks)) copy(result, blocks) round := 0 for len(result) > 1 { i := 0 j := i + 1 for i < len(result)-1 { switch comparator(result[i], result[j], round) { case 0: result = append(result[:j], result[j+1:]...) case 1: result = append(result[:i], result[i+1:]...) j = i + 1 case 2: j++ } if j >= len(result)-1 { i++ j = i + 1 } } round++ } return result[0] }
Functions ¶
This section is empty.
Types ¶
type Block ¶
type Block struct {
// contains filtered or unexported fields
}
func (*Block) BlockNumber ¶
func (*Block) ParentHash ¶
func (*Block) ResourceType ¶
func (*Block) Transactions ¶
func (b *Block) Transactions() []spec.Transaction
type BlockGenerator ¶
func NewBlockGenerator ¶
func NewBlockGenerator(txnHandlers ...spec.TransactionHandler) *BlockGenerator
func (*BlockGenerator) BlockPrototype ¶
func (g *BlockGenerator) BlockPrototype() spec.Block
func (*BlockGenerator) CommitBlock ¶
func (g *BlockGenerator) CommitBlock(block spec.Block)
func (*BlockGenerator) GenerateBlock ¶
func (g *BlockGenerator) GenerateBlock(branch []spec.Block) (newBlock spec.Block)
func (*BlockGenerator) GenerateGenesisBlock ¶
func (g *BlockGenerator) GenerateGenesisBlock() spec.Block
func (*BlockGenerator) ReceiveTransaction ¶
func (g *BlockGenerator) ReceiveTransaction(netMsg *spec.NetworkMessage) (spec.Transaction, error)
func (*BlockGenerator) TryCommitBlock ¶
func (*BlockGenerator) Type ¶
func (g *BlockGenerator) Type() string
type BlockMessage ¶
type BlockMessage struct { Namespace string `protobuf:"bytes,5,opt,name=namespace,proto3" json:"namespace,omitempty"` Name string `protobuf:"bytes,10,opt,name=name,proto3" json:"name,omitempty"` Version string `protobuf:"bytes,15,opt,name=version,proto3" json:"version,omitempty"` BlockNumber uint64 `protobuf:"varint,25,opt,name=blockNumber,proto3" json:"blockNumber,omitempty"` Timestamp int64 `protobuf:"varint,30,opt,name=timestamp,proto3" json:"timestamp,omitempty"` Score uint32 `protobuf:"varint,35,opt,name=score,proto3" json:"score,omitempty"` PeerID string `protobuf:"bytes,40,opt,name=peerID,proto3" json:"peerID,omitempty"` // Links: // "parent": parent block hash // "txn-1"..."txn-n": transactions belonging to this block Links map[string]string `` /* 152-byte string literal not displayed */ XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*BlockMessage) Descriptor ¶
func (*BlockMessage) Descriptor() ([]byte, []int)
func (*BlockMessage) GetBlockNumber ¶
func (m *BlockMessage) GetBlockNumber() uint64
func (*BlockMessage) GetLinks ¶
func (m *BlockMessage) GetLinks() map[string]string
func (*BlockMessage) GetName ¶
func (m *BlockMessage) GetName() string
func (*BlockMessage) GetNamespace ¶
func (m *BlockMessage) GetNamespace() string
func (*BlockMessage) GetPeerID ¶
func (m *BlockMessage) GetPeerID() string
func (*BlockMessage) GetScore ¶
func (m *BlockMessage) GetScore() uint32
func (*BlockMessage) GetTimestamp ¶
func (m *BlockMessage) GetTimestamp() int64
func (*BlockMessage) GetVersion ¶
func (m *BlockMessage) GetVersion() string
func (*BlockMessage) ProtoMessage ¶
func (*BlockMessage) ProtoMessage()
func (*BlockMessage) Reset ¶
func (m *BlockMessage) Reset()
func (*BlockMessage) String ¶
func (m *BlockMessage) String() string
func (*BlockMessage) XXX_DiscardUnknown ¶
func (m *BlockMessage) XXX_DiscardUnknown()
func (*BlockMessage) XXX_Marshal ¶
func (m *BlockMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*BlockMessage) XXX_Merge ¶
func (dst *BlockMessage) XXX_Merge(src proto.Message)
func (*BlockMessage) XXX_Size ¶
func (m *BlockMessage) XXX_Size() int
func (*BlockMessage) XXX_Unmarshal ¶
func (m *BlockMessage) XXX_Unmarshal(b []byte) error
type TransactionHandler ¶
type TransactionHandler struct {
Protocol string
}
func (*TransactionHandler) Execute ¶
func (h *TransactionHandler) Execute(txn *spec.Transaction) (ok bool)
func (*TransactionHandler) Type ¶
func (h *TransactionHandler) Type() string
func (*TransactionHandler) Unmarshal ¶
func (h *TransactionHandler) Unmarshal(message proto.Message) spec.Transaction
Click to show internal directories.
Click to hide internal directories.