blockchain

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2018 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BlockRequestByte means block request message
	BlockRequestByte = byte(0x10)
	// BlockResponseByte means block response message
	BlockResponseByte = byte(0x11)
	// StatusRequestByte means status request message
	StatusRequestByte = byte(0x20)
	// StatusResponseByte means status response message
	StatusResponseByte = byte(0x21)
	// NewTransactionByte means transaction notify message
	NewTransactionByte = byte(0x30)
)
View Source
const (
	// BlockchainChannel is a channel for blocks and status updates
	BlockchainChannel = byte(0x40)
)

Variables

This section is empty.

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.

Types

type BlockRequestMessage added in v0.1.4

type BlockRequestMessage struct {
	Height  uint64
	RawHash [32]byte
}

BlockRequestMessage is block request message struct

func (*BlockRequestMessage) GetHash added in v0.1.4

func (m *BlockRequestMessage) GetHash() *bc.Hash

GetHash return block 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
}

BlockResponseMessage is block response message struct

func NewBlockResponseMessage added in v0.1.4

func NewBlockResponseMessage(block *types.Block) (*BlockResponseMessage, error)

NewBlockResponseMessage produce new BlockResponseMessage instance

func (*BlockResponseMessage) GetBlock added in v0.1.4

func (m *BlockResponseMessage) GetBlock() *types.Block

GetBlock return block struct

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)

DecodeMessage decode receive messages

type BlockchainReactor

type BlockchainReactor struct {
	p2p.BaseReactor

	TxFeedTracker *txfeed.Tracker // TODO: move it out from BlockchainReactor
	// contains filtered or unexported fields
}

BlockchainReactor handles long-term catchup syncing.

func NewBlockchainReactor

func NewBlockchainReactor(chain *protocol.Chain, txPool *protocol.TxPool, sw *p2p.Switch, accountMgr *account.Manager, txfeeds *txfeed.Tracker, 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()

BroadcastStatusResponse broadcasts `BlockStore` height.

func (*BlockchainReactor) BroadcastTransaction

func (bcr *BlockchainReactor) BroadcastTransaction(tx *protocolTypes.Tx) error

BroadcastTransaction broadcats `BlockStore` transaction.

func (*BlockchainReactor) GetChannels

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

GetChannels implements Reactor

func (*BlockchainReactor) GetNodeInfo added in v0.4.1

func (bcr *BlockchainReactor) GetNodeInfo() *NetInfo

func (*BlockchainReactor) GetTxFeedByAlias added in v0.4.1

func (bcr *BlockchainReactor) GetTxFeedByAlias(ctx context.Context, filter string) ([]byte, error)

func (*BlockchainReactor) GetWork added in v0.4.1

func (bcr *BlockchainReactor) GetWork() (*GetWorkResp, error)

func (*BlockchainReactor) Info added in v0.4.1

func (bcr *BlockchainReactor) Info(ctx context.Context) (map[string]interface{}, error)

Info return the server information

func (*BlockchainReactor) IsMining added in v0.4.1

func (bcr *BlockchainReactor) IsMining() bool

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) SubmitWork added in v0.4.1

func (bcr *BlockchainReactor) SubmitWork(bh *types.BlockHeader) error

type GetWorkResp added in v0.4.1

type GetWorkResp struct {
	BlockHeader *types.BlockHeader `json:"block_header"`
	Seed        *bc.Hash           `json:"seed"`
}

GetWorkResp is resp struct for API

type NetInfo added in v0.4.1

type NetInfo struct {
	Listening    bool   `json:"listening"`
	Syncing      bool   `json:"syncing"`
	Mining       bool   `json:"mining"`
	PeerCount    int    `json:"peer_count"`
	CurrentBlock uint64 `json:"current_block"`
	HighestBlock uint64 `json:"highest_block"`
}

type StatusRequestMessage added in v0.1.4

type StatusRequestMessage struct{}

StatusRequestMessage is status request message struct

func (*StatusRequestMessage) String added in v0.1.4

func (m *StatusRequestMessage) String() string

type StatusResponseMessage added in v0.1.4

type StatusResponseMessage struct {
	Height  uint64
	RawHash [32]byte
}

StatusResponseMessage is status response message struct

func NewStatusResponseMessage added in v0.1.4

func NewStatusResponseMessage(block *types.Block) *StatusResponseMessage

NewStatusResponseMessage produce new StatusResponseMessage instance

func (*StatusResponseMessage) GetHash added in v0.1.4

func (m *StatusResponseMessage) GetHash() *bc.Hash

GetHash return hash pointer

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
}

TransactionNotifyMessage is transaction notify message struct

func NewTransactionNotifyMessage added in v0.1.4

func NewTransactionNotifyMessage(tx *types.Tx) (*TransactionNotifyMessage, error)

NewTransactionNotifyMessage produce new TransactionNotifyMessage instance

func (*TransactionNotifyMessage) GetTransaction added in v0.1.4

func (m *TransactionNotifyMessage) GetTransaction() *types.Tx

GetTransaction return Tx struct

func (*TransactionNotifyMessage) String added in v0.1.4

func (m *TransactionNotifyMessage) String() string

Directories

Path Synopsis
Package pseudohsm provides a pseudo HSM for development environments.
Package pseudohsm provides a pseudo HSM for development environments.
rpc
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.

Jump to

Keyboard shortcuts

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