dhtnode

package
v0.0.0-...-370c9f9 Latest Latest
Warning

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

Go to latest
Published: May 17, 2021 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlockDataHash

func BlockDataHash(b *cb.BlockData) []byte

func NewBlock

func NewBlock(seqNum uint64, previousHash []byte) *cb.Block

Types

type Config

type Config struct {
	DialOpts []grpc.DialOption
	Timeout  time.Duration // 作为WithTimeout()函数参数
	MaxIdle  time.Duration // 超过maxidle自动关闭连接
}

Client(outbound) dial config

type DhtNode

type DhtNode struct {
	IsMainNode bool

	PendingBatchStartTime time.Time
	ChannelID             string
	*chord.Node

	Transport *GrpcTransport
	// contains filtered or unexported fields
}

func NewDhtNode

func NewDhtNode(cnf *chord.Config, joinNode *cm.Node) (*DhtNode, error)

NewDhtNode 创建DhtNode

func (*DhtNode) Cut

func (dhtn *DhtNode) Cut() []*cb.Envelope

Cut returns the current batch and starts a new one

func (*DhtNode) DhtInsideTransBlock

func (dhtn *DhtNode) DhtInsideTransBlock(block *cb.Block) error

func (*DhtNode) Ordered

func (dhtn *DhtNode) Ordered(msg *cb.Envelope) (messageBatches [][]*cb.Envelope, pending bool)

Ordered should be invoked sequentially as messages are ordered

messageBatches length: 0, pending: false

  • impossible, as we have just received a message

messageBatches length: 0, pending: true

  • no batch is cut and there are messages pending

messageBatches length: 1, pending: false

  • the message count reaches BatchSize.MaxMessageCount

messageBatches length: 1, pending: true

  • the current message will cause the pending batch size in bytes to exceed BatchSize.PreferredMaxBytes.

messageBatches length: 2, pending: false

  • the current message size in bytes exceeds BatchSize.PreferredMaxBytes, therefore isolated in its own batch.

messageBatches length: 2, pending: true

  • impossible

Note that messageBatches can not be greater than 2.

func (*DhtNode) PreCreateNextBlock

func (dhtn *DhtNode) PreCreateNextBlock(messages []*cb.Envelope) *cb.Block

CreateNextBlock creates a new block with the next block number, and the given contents.

func (*DhtNode) PrevBlock

func (dhtn *DhtNode) PrevBlock(sendMsgChan chan *chord.Message)

PrevBlock 将区块进行排序并发送给orderer

func (*DhtNode) TransPrevBlockClient

func (dhtn *DhtNode) TransPrevBlockClient() error

type GrpcTransport

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

func NewGrpcTransport

func NewGrpcTransport() *GrpcTransport

func NewGrpcTransport(config *Config) (cm.ChordClient, error) {

func (*GrpcTransport) Start

func (g *GrpcTransport) Start() error

func (*GrpcTransport) Stop

func (g *GrpcTransport) Stop() error

Close all outbound connection in the pool

type MainNode

type MainNode interface {
	StartDht(id string, address string)
	StartTransMsgServer(address string)
	StartTransBlockServer(address string)
	Stop()
}

MainNode 主节点,负责接受Orderer的Msg,通过node的内部机制转发给其它DhtNode 接受其它DhtNode及自身的出块,排序后发送给Orderer

func NewMainNode

func NewMainNode() (MainNode, error)

NewMainNode 创建mainNode节点 其中会向Orderer询问配置,如果无法通信,则等待1分钟

type OrdererConfigFetcher

type OrdererConfigFetcher interface {
	OrdererConfig() (channelconfig.Orderer, bool)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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