Skip to content

7 Block Creation And Replication

Senthilnathan Natarajan edited this page May 27, 2020 · 2 revisions

Block Creation and Replication

type blockCreator struct {
    nextTxBatchQueue NextTxBatchQueue
}

// Creates new blocks, using data from blockCreator
type BlockCreator interface {
    CreateNextBlock(messages []*pb.Envelope) *pb.Block
}

// BlockPuller is used to pull blocks from other OSN
type BlockPuller interface {
    PullBlock(seq uint64) *common.Block
    HeightsByEndpoints() (map[string]uint64, error)
    Close()
}

type consenter struct {
    queue BlockQueue
}

type blockQueue struct {
     Queue []*pb.Block
     mu    sync.RWMutex
}

type BlockQueue interface {
     Enqueue(tx *pb.Block) error
     Dequeue() (tx *pb.Block, error)
     Peek() (tx *pb.Block, error)
     Size() uint64
}

type Consenter interface {
    identity.Signer
    // AcceptBlock adds a block to the block queue.
    AcceptBlock(block Block) error
    // Send block to network
    SendBlock(block Block) error
    // Incoming block handler
    OnBlock(block Block) error
}