MCPcopy Create free account
hub / github.com/DNAProject/DNA / StartTxnPoolServer

Function StartTxnPoolServer

txnpool/server.go:56–92  ·  view source on GitHub ↗

StartTxnPoolServer starts the txnpool server and registers actors to handle the msgs from the network, http, consensus and validators. Meanwhile subscribes the block complete event.

(disablePreExec, disableBroadcastNetTx bool)

Source from the content-addressed store, hash-verified

54// actors to handle the msgs from the network, http, consensus
55// and validators. Meanwhile subscribes the block complete event.
56func StartTxnPoolServer(disablePreExec, disableBroadcastNetTx bool) (*tp.TXPoolServer, error) {
57 var s *tp.TXPoolServer
58
59 /* Start txnpool server to receive msgs from p2p,
60 * consensus and valdiators
61 */
62 s = tp.NewTxPoolServer(tc.MAX_WORKER_NUM, disablePreExec, disableBroadcastNetTx)
63
64 // Initialize an actor to handle the msgs from valdiators
65 rspActor := tp.NewVerifyRspActor(s)
66 rspPid, err := startActor(rspActor, "txVerifyRsp")
67 if rspPid == nil {
68 return nil, err
69 }
70 s.RegisterActor(tc.VerifyRspActor, rspPid)
71
72 // Initialize an actor to handle the msgs from consensus
73 tpa := tp.NewTxPoolActor(s)
74 txPoolPid, err := startActor(tpa, "txPool")
75 if txPoolPid == nil {
76 return nil, err
77 }
78 s.RegisterActor(tc.TxPoolActor, txPoolPid)
79
80 // Initialize an actor to handle the msgs from p2p and api
81 ta := tp.NewTxActor(s)
82 txPid, err := startActor(ta, "tx")
83 if txPid == nil {
84 return nil, err
85 }
86 s.RegisterActor(tc.TxActor, txPid)
87
88 // Subscribe the block complete event
89 var sub = events.NewActorSubscriber(txPoolPid)
90 sub.Subscribe(message.TOPIC_SAVE_BLOCK_COMPLETE)
91 return s, nil
92}

Callers 1

initTxPoolFunction · 0.92

Calls 4

RegisterActorMethod · 0.95
NewActorSubscriberFunction · 0.92
startActorFunction · 0.70
SubscribeMethod · 0.45

Tested by

no test coverage detected