blockchain

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2017 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BlockchainChannel is a channel for blocks and status updates (`BlockStore` height)
	BlockchainChannel = byte(0x40)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockPool

type BlockPool struct {
	cmn.BaseService
	// contains filtered or unexported fields
}

func NewBlockPool

func NewBlockPool(start int, requestsCh chan<- BlockRequest, timeoutsCh chan<- string) *BlockPool

func (*BlockPool) AddBlock

func (pool *BlockPool) AddBlock(peerID string, block *types.Block, blockSize int)

TODO: ensure that blocks come in order for each peer.

func (*BlockPool) GetStatus

func (pool *BlockPool) GetStatus() (height int, numPending int32, lenRequesters int)

func (*BlockPool) IsCaughtUp

func (pool *BlockPool) IsCaughtUp() bool

TODO: relax conditions, prevent abuse.

func (*BlockPool) OnStart

func (pool *BlockPool) OnStart() error

func (*BlockPool) OnStop

func (pool *BlockPool) OnStop()

func (*BlockPool) PeekTwoBlocks

func (pool *BlockPool) PeekTwoBlocks() (first *types.Block, second *types.Block)

We need to see the second block's Commit to validate the first block. So we peek two blocks at a time. The caller will verify the commit.

func (*BlockPool) PopRequest

func (pool *BlockPool) PopRequest()

Pop the first block at pool.height It must have been validated by 'second'.Commit from PeekTwoBlocks().

func (*BlockPool) RedoRequest

func (pool *BlockPool) RedoRequest(height int)

Invalidates the block at pool.height, Remove the peer and redo request from others.

func (*BlockPool) RemovePeer

func (pool *BlockPool) RemovePeer(peerID string)

func (*BlockPool) SetPeerHeight

func (pool *BlockPool) SetPeerHeight(peerID string, height int)

Sets the peer's alleged blockchain height.

type BlockRequest

type BlockRequest struct {
	Height int
	PeerID string
}

type BlockStore

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

Simple low level store for blocks.

There are three types of information stored:

  • BlockMeta: Meta information about each block
  • Block part: Parts of each block, aggregated w/ PartSet
  • Commit: The commit part of each block, for gossiping precommit votes

Currently the precommit signatures are duplicated in the Block parts as well as the Commit. In the future this may change, perhaps by moving the Commit data outside the Block.

Panics indicate probable corruption in the data

func NewBlockStore

func NewBlockStore(db dbm.DB) *BlockStore

func (*BlockStore) GetReader added in v0.7.0

func (bs *BlockStore) GetReader(key []byte) io.Reader

func (*BlockStore) Height

func (bs *BlockStore) Height() int

Height() returns the last known contiguous block height.

func (*BlockStore) LoadBlock

func (bs *BlockStore) LoadBlock(height int) *types.Block

func (*BlockStore) LoadBlockCommit

func (bs *BlockStore) LoadBlockCommit(height int) *types.Commit

The +2/3 and other Precommit-votes for block at `height`. This Commit comes from block.LastCommit for `height+1`.

func (*BlockStore) LoadBlockMeta

func (bs *BlockStore) LoadBlockMeta(height int) *types.BlockMeta

func (*BlockStore) LoadBlockPart

func (bs *BlockStore) LoadBlockPart(height int, index int) *types.Part

func (*BlockStore) LoadSeenCommit

func (bs *BlockStore) LoadSeenCommit(height int) *types.Commit

NOTE: the Precommit-vote heights are for the block at `height`

func (*BlockStore) SaveBlock

func (bs *BlockStore) SaveBlock(block *types.Block, blockParts *types.PartSet, seenCommit *types.Commit)

blockParts: Must be parts of the block seenCommit: The +2/3 precommits that were seen which committed at height.

If all the nodes restart after committing a block,
we need this to reload the precommits to catch-up nodes to the
most recent height.  Otherwise they'd stall at H-1.

type BlockStoreStateJSON

type BlockStoreStateJSON struct {
	Height int
}

func LoadBlockStoreStateJSON

func LoadBlockStoreStateJSON(db dbm.DB) BlockStoreStateJSON

func (BlockStoreStateJSON) Save

func (bsj BlockStoreStateJSON) Save(db dbm.DB)

type BlockchainMessage

type BlockchainMessage interface{}

BlockchainMessage is a generic message for this reactor.

func DecodeMessage added in v0.7.0

func DecodeMessage(bz []byte, maxSize int) (msgType byte, msg BlockchainMessage, err error)

DecodeMessage decodes BlockchainMessage. TODO: ensure that bz is completely read.

type BlockchainReactor

type BlockchainReactor struct {
	p2p.BaseReactor
	// contains filtered or unexported fields
}

BlockchainReactor handles long-term catchup syncing.

func NewBlockchainReactor

func NewBlockchainReactor(state *sm.State, proxyAppConn proxy.AppConnConsensus, store *BlockStore, fastSync bool) *BlockchainReactor

NewBlockchainReactor returns new reactor instance.

func (*BlockchainReactor) AddPeer

func (bcR *BlockchainReactor) AddPeer(peer p2p.Peer)

AddPeer implements Reactor by sending our state to peer.

func (*BlockchainReactor) BroadcastStatusRequest

func (bcR *BlockchainReactor) BroadcastStatusRequest() error

BroadcastStatusRequest broadcasts `BlockStore` height.

func (*BlockchainReactor) GetChannels

func (bcR *BlockchainReactor) GetChannels() []*p2p.ChannelDescriptor

GetChannels implements Reactor

func (*BlockchainReactor) OnStart

func (bcR *BlockchainReactor) OnStart() error

OnStart implements BaseService

func (*BlockchainReactor) OnStop

func (bcR *BlockchainReactor) OnStop()

OnStop implements BaseService

func (*BlockchainReactor) Receive

func (bcR *BlockchainReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte)

Receive implements Reactor by handling 4 types of messages (look below).

func (*BlockchainReactor) RemovePeer

func (bcR *BlockchainReactor) RemovePeer(peer p2p.Peer, reason interface{})

RemovePeer implements Reactor by removing peer from the pool.

func (*BlockchainReactor) SetEventSwitch added in v0.7.0

func (bcR *BlockchainReactor) SetEventSwitch(evsw types.EventSwitch)

SetEventSwitch implements events.Eventable

Jump to

Keyboard shortcuts

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