Documentation ¶
Overview ¶
MemStore is a Store implementation that keeps all blockchain state in memory.
It is used in tests to avoid needing a database.
Index ¶
- Constants
- Variables
- func HomeDirFromEnvironment() string
- func TLSConfig(certFile, keyFile, rootCAs string) (*tls.Config, error)
- type BlockPool
- func (pool *BlockPool) AddBlock(peerID string, block *legacy.Block, blockSize int)
- func (pool *BlockPool) GetStatus() (height uint64, numPending int32, lenRequesters int)
- func (pool *BlockPool) IsCaughtUp() bool
- func (pool *BlockPool) OnStart() error
- func (pool *BlockPool) OnStop()
- func (pool *BlockPool) PeekTwoBlocks() (first *legacy.Block, second *legacy.Block)
- func (pool *BlockPool) PopRequest()
- func (pool *BlockPool) RedoRequest(height uint64)
- func (pool *BlockPool) RemovePeer(peerID string)
- func (pool *BlockPool) SetPeerHeight(peerID string, height uint64)
- type BlockRequest
- type BlockchainMessage
- type BlockchainReactor
- func (bcR *BlockchainReactor) AddPeer(peer *p2p.Peer)
- func (bcR *BlockchainReactor) BroadcastStatusRequest() error
- func (bcR *BlockchainReactor) BroadcastTransaction(tx *legacy.Tx) error
- func (bcr *BlockchainReactor) BuildHander()
- func (bcr *BlockchainReactor) GetAccountUTXOs() []account.AccountUTXOs
- func (bcR *BlockchainReactor) GetChannels() []*p2p.ChannelDescriptor
- func (bcR *BlockchainReactor) OnStart() error
- func (bcR *BlockchainReactor) OnStop()
- func (bcR *BlockchainReactor) Receive(chID byte, src *p2p.Peer, msgBytes []byte)
- func (bcR *BlockchainReactor) RemovePeer(peer *p2p.Peer, reason interface{})
- func (bcr *BlockchainReactor) ServeHTTP(rw http.ResponseWriter, req *http.Request)
- type BuildRequest
- type MemStore
- type SubmitArg
Constants ¶
const ( // BlockchainChannel is a channel for blocks and status updates (`BlockStore` height) BlockchainChannel = byte(0x40) )
Variables ¶
var (
AccountUTXOFmt = `` /* 195-byte string literal not displayed */
)
var ErrNoTLS = errors.New("no TLS configuration available")
Functions ¶
func HomeDirFromEnvironment ¶
func HomeDirFromEnvironment() string
HomeDirFromEnvironment returns the directory to use for reading config and storing variable data. It returns $BYTOM_HOME, or, if that is empty, $HOME/.chaincore.
func TLSConfig ¶
TLSConfig returns a TLS config suitable for use as a bytom client and server. It reads a PEM-encoded X.509 certificate and private key from certFile and keyFile. If rootCAs is given, it should name a file containing a list of trusted root CA certs, otherwise the returned config uses the system cert pool.
For compatibility, it attempts to read the cert and key from the environment if certFile and keyFile both do not exist in the filesystem.
TLSCRT=[PEM-encoded X.509 certificate] TLSKEY=[PEM-encoded X.509 private key]
If certFile and keyFile do not exist or are empty and the environment vars are both unset, TLSConfig returns ErrNoTLS.
Types ¶
type BlockPool ¶
type BlockPool struct { BaseService // contains filtered or unexported fields }
func NewBlockPool ¶
func NewBlockPool(start uint64, requestsCh chan<- BlockRequest, timeoutsCh chan<- string) *BlockPool
func (*BlockPool) IsCaughtUp ¶
TODO: relax conditions, prevent abuse.
func (*BlockPool) PeekTwoBlocks ¶
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 ¶
Invalidates the block at pool.height, Remove the peer and redo request from others.
func (*BlockPool) RemovePeer ¶
func (*BlockPool) SetPeerHeight ¶
Sets the peer's alleged blockchain height.
type BlockRequest ¶
type BlockchainMessage ¶
type BlockchainMessage interface{}
BlockchainMessage is a generic message for this reactor.
func DecodeMessage ¶
func DecodeMessage(bz []byte) (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 (*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) BroadcastTransaction ¶
func (bcR *BlockchainReactor) BroadcastTransaction(tx *legacy.Tx) error
func (*BlockchainReactor) BuildHander ¶
func (bcr *BlockchainReactor) BuildHander()
func (*BlockchainReactor) GetAccountUTXOs ¶ added in v0.1.3
func (bcr *BlockchainReactor) GetAccountUTXOs() []account.AccountUTXOs
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) ServeHTTP ¶
func (bcr *BlockchainReactor) ServeHTTP(rw http.ResponseWriter, req *http.Request)
type BuildRequest ¶
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package accesstoken provides storage and validation of Chain Core credentials.
|
Package accesstoken provides storage and validation of Chain Core credentials. |
Package account stores and tracks accounts within a Chain Core.
|
Package account stores and tracks accounts within a Chain Core. |
Package pseudohsm provides a pseudo HSM for development environments.
|
Package pseudohsm provides a pseudo HSM for development environments. |
Package query implements indexing and querying of annotated blockchain data.
|
Package query implements indexing and querying of annotated blockchain data. |
filter
Package filter parses and evaluates Chain filter expressions.
|
Package filter parses and evaluates Chain filter expressions. |
Package signers associates signers and their corresponding keys.
|
Package signers associates signers and their corresponding keys. |
Package txbuilder builds a Chain Protocol transaction from a list of actions.
|
Package txbuilder builds a Chain Protocol transaction from a list of actions. |
Package txdb provides storage for Chain Protocol blockchain data structures.
|
Package txdb provides storage for Chain Protocol blockchain data structures. |
internal/storage
Package storage is a generated protocol buffer package.
|
Package storage is a generated protocol buffer package. |