Documentation ¶
Index ¶
- Constants
- Variables
- func CreateNodeID() string
- func StartServer(nodeID string, isMining bool, minerAddr string, listenAddr, seedAddr string, ...) error
- type MessageHandler
- func (handler *MessageHandler) OnAddr(msg *protocol.MsgAddr)
- func (handler *MessageHandler) OnBlock(msg *protocol.MsgBlock)
- func (handler *MessageHandler) OnGetAddr(msg *protocol.MsgGetAddr)
- func (handler *MessageHandler) OnGetBlocks(msg *protocol.MsgGetBlocks)
- func (handler *MessageHandler) OnGetData(msg *protocol.MsgGetData)
- func (handler *MessageHandler) OnInv(msg *protocol.MsgInv)
- func (handler *MessageHandler) OnTx(msg *protocol.MsgTx)
- func (handler *MessageHandler) OnVersion(msg *protocol.MsgVersion)
- type RpcHandler
- func (h *RpcHandler) CreateWallet(name string, result *packet.JsonResult) error
- func (h *RpcHandler) GetVersion(name string, result *packet.JsonResult) error
- func (h *RpcHandler) ListAddress(tag string, result *packet.JsonResult) error
- func (h *RpcHandler) ListBlocks(name string, result *packet.JsonResult) error
- func (h *RpcHandler) ListMemPool(name string, result *packet.JsonResult) error
- func (h *RpcHandler) SendTX(txPacket packet.TXPacket, result *packet.JsonResult) error
- type Server
- type ServerConfig
Constants ¶
View Source
const ( MinimumTxInNewBlock = 1 ZeroTxInNewBlock = 0 )
View Source
const MaxPeerNum = 1000
Variables ¶
View Source
var ErrorAllTXInvalid = errors.New("All transactions are invalid!")
View Source
var (
ErrorPacketDeserialize = errors.New("packet data deserialize err")
)
Functions ¶
Types ¶
type MessageHandler ¶
type MessageHandler struct {
// contains filtered or unexported fields
}
func NewMessageHandler ¶
func NewMessageHandler(s *Server) *MessageHandler
func (*MessageHandler) OnAddr ¶
func (handler *MessageHandler) OnAddr(msg *protocol.MsgAddr)
OnAddr is invoked when a peer receives an addr message.
func (*MessageHandler) OnBlock ¶
func (handler *MessageHandler) OnBlock(msg *protocol.MsgBlock)
OnBlock is invoked when a peer receives an block message
func (*MessageHandler) OnGetAddr ¶
func (handler *MessageHandler) OnGetAddr(msg *protocol.MsgGetAddr)
OnGetAddr is invoked when a peer receives a getaddr message
func (*MessageHandler) OnGetBlocks ¶
func (handler *MessageHandler) OnGetBlocks(msg *protocol.MsgGetBlocks)
OnGetBlocks is invoked when a peer receives an getblocks message
func (*MessageHandler) OnGetData ¶
func (handler *MessageHandler) OnGetData(msg *protocol.MsgGetData)
OnGetData is invoked when a peer receives an getdata message
func (*MessageHandler) OnInv ¶
func (handler *MessageHandler) OnInv(msg *protocol.MsgInv)
OnInv is invoked when a peer receives an inv message.
func (*MessageHandler) OnTx ¶
func (handler *MessageHandler) OnTx(msg *protocol.MsgTx)
OnTx is invoked when a peer receives an tx message
func (*MessageHandler) OnVersion ¶
func (handler *MessageHandler) OnVersion(msg *protocol.MsgVersion)
OnVersion is invoked when a peer receives an ver message
type RpcHandler ¶
type RpcHandler struct {
// contains filtered or unexported fields
}
func (*RpcHandler) CreateWallet ¶
func (h *RpcHandler) CreateWallet(name string, result *packet.JsonResult) error
CreateWallet 创建账户
func (*RpcHandler) GetVersion ¶
func (h *RpcHandler) GetVersion(name string, result *packet.JsonResult) error
ListMemPool list tx in mempool
func (*RpcHandler) ListAddress ¶
func (h *RpcHandler) ListAddress(tag string, result *packet.JsonResult) error
func (*RpcHandler) ListBlocks ¶
func (h *RpcHandler) ListBlocks(name string, result *packet.JsonResult) error
ListBlocks list blocks
func (*RpcHandler) ListMemPool ¶
func (h *RpcHandler) ListMemPool(name string, result *packet.JsonResult) error
ListMemPool list tx in mempool
func (*RpcHandler) SendTX ¶
func (h *RpcHandler) SendTX(txPacket packet.TXPacket, result *packet.JsonResult) error
SendTX send TX on rpc server
type Server ¶
type Server struct { NodeID string ListenAddress string SeedAddress string TXMemPool *mempool.TxPool Wallets *wallet.WalletSet BlockChain *chain.Blockchain AddrManager *addr.AddrManager SyncManager *sync.SyncManager Peer *peer.Peer IsGenesisNode bool Config *ServerConfig // contains filtered or unexported fields }
func (*Server) LoopMining ¶
func (s *Server) LoopMining()
type ServerConfig ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.