Documentation ¶
Index ¶
- Constants
- Variables
- func HomeDirFromEnvironment() string
- func RedirectHandler(next http.Handler) http.Handler
- func TLSConfig(certFile, keyFile, rootCAs string) (*tls.Config, error)
- type BlockRequestMessage
- type BlockResponseMessage
- type BlockchainMessage
- type BlockchainReactor
- func (bcr *BlockchainReactor) AddPeer(peer *p2p.Peer)
- func (bcr *BlockchainReactor) BroadcastStatusResponse()
- func (bcr *BlockchainReactor) BroadcastTransaction(tx *legacy.Tx) error
- func (bcr *BlockchainReactor) BuildHandler()
- 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 GetBlockByHashJSON
- type Response
- type StatusRequestMessage
- type StatusResponseMessage
- type TransactionNotifyMessage
- type TxJSON
Constants ¶
const ( BlockRequestByte = byte(0x10) BlockResponseByte = byte(0x11) StatusRequestByte = byte(0x20) StatusResponseByte = byte(0x21) NewTransactionByte = byte(0x30) )
const ( // SUCCESS indicates the rpc calling is successful. SUCCESS = "success" // FAIL indicated the rpc calling is failed. FAIL = "fail" )
const ( // BlockchainChannel is a channel for blocks and status updates BlockchainChannel = byte(0x40) )
Variables ¶
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 BlockRequestMessage ¶ added in v0.1.4
func (*BlockRequestMessage) GetHash ¶ added in v0.1.4
func (m *BlockRequestMessage) GetHash() *bc.Hash
func (*BlockRequestMessage) String ¶ added in v0.1.4
func (m *BlockRequestMessage) String() string
type BlockResponseMessage ¶ added in v0.1.4
type BlockResponseMessage struct {
RawBlock []byte
}
func NewBlockResponseMessage ¶ added in v0.1.4
func NewBlockResponseMessage(block *legacy.Block) (*BlockResponseMessage, error)
func (*BlockResponseMessage) GetBlock ¶ added in v0.1.4
func (m *BlockResponseMessage) GetBlock() *legacy.Block
func (*BlockResponseMessage) String ¶ added in v0.1.4
func (m *BlockResponseMessage) String() string
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)
type BlockchainReactor ¶
type BlockchainReactor struct { p2p.BaseReactor // contains filtered or unexported fields }
BlockchainReactor handles long-term catchup syncing.
func NewBlockchainReactor ¶
func NewBlockchainReactor(chain *protocol.Chain, txPool *protocol.TxPool, accounts *account.Manager, assets *asset.Registry, sw *p2p.Switch, hsm *pseudohsm.HSM, wallet *wallet.Wallet, txfeeds *txfeed.Tracker, accessTokens *accesstoken.CredentialStore, miningEnable bool) *BlockchainReactor
NewBlockchainReactor returns the reactor of whole blockchain.
func (*BlockchainReactor) AddPeer ¶
func (bcr *BlockchainReactor) AddPeer(peer *p2p.Peer)
AddPeer implements Reactor by sending our state to peer.
func (*BlockchainReactor) BroadcastStatusResponse ¶ added in v0.1.4
func (bcr *BlockchainReactor) BroadcastStatusResponse()
BroadcastStatusRequest broadcasts `BlockStore` height.
func (*BlockchainReactor) BroadcastTransaction ¶
func (bcr *BlockchainReactor) BroadcastTransaction(tx *legacy.Tx) error
BroadcastTransaction broadcats `BlockStore` transaction.
func (*BlockchainReactor) BuildHandler ¶ added in v0.3.0
func (bcr *BlockchainReactor) BuildHandler()
BuildHandler is in charge of all the rpc handling.
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)
serve http
type BuildRequest ¶
type GetBlockByHashJSON ¶ added in v0.2.0
type GetBlockByHashJSON struct { BlockHeader *bc.BlockHeader `json:"block_header"` Transactions []*TxJSON `json:"transactions"` }
GetBlockByHashJSON is actually a block, include block header and transactions.
type Response ¶ added in v0.2.0
type Response struct { Status string `json:"status,omitempty"` Msg string `json:"msg,omitempty"` Data interface{} `json:"data,omitempty"` }
Response describes the response standard.
type StatusRequestMessage ¶ added in v0.1.4
type StatusRequestMessage struct{}
func (*StatusRequestMessage) String ¶ added in v0.1.4
func (m *StatusRequestMessage) String() string
type StatusResponseMessage ¶ added in v0.1.4
func NewStatusResponseMessage ¶ added in v0.1.4
func NewStatusResponseMessage(block *legacy.Block) *StatusResponseMessage
func (*StatusResponseMessage) GetHash ¶ added in v0.1.4
func (m *StatusResponseMessage) GetHash() *bc.Hash
func (*StatusResponseMessage) String ¶ added in v0.1.4
func (m *StatusResponseMessage) String() string
type TransactionNotifyMessage ¶ added in v0.1.4
type TransactionNotifyMessage struct {
RawTx []byte
}
func NewTransactionNotifyMessage ¶ added in v0.1.4
func NewTransactionNotifyMessage(tx *legacy.Tx) (*TransactionNotifyMessage, error)
func (*TransactionNotifyMessage) GetTransaction ¶ added in v0.1.4
func (m *TransactionNotifyMessage) GetTransaction() *legacy.Tx
func (*TransactionNotifyMessage) String ¶ added in v0.1.4
func (m *TransactionNotifyMessage) String() string
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. |
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. |
storage
Package storage is a generated protocol buffer package.
|
Package storage is a generated protocol buffer package. |