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

Method init

txnpool/proc/txnpool_server.go:154–194  ·  view source on GitHub ↗

init initializes the server with the configured settings

(num uint8, disablePreExec, disableBroadcastNetTx bool)

Source from the content-addressed store, hash-verified

152
153// init initializes the server with the configured settings
154func (s *TXPoolServer) init(num uint8, disablePreExec, disableBroadcastNetTx bool) {
155 // Initial txnPool
156 s.txPool = &tc.TXPool{}
157 s.txPool.Init()
158 s.allPendingTxs = make(map[common.Uint256]*serverPendingTx)
159 s.actors = make(map[tc.ActorType]*actor.PID)
160
161 s.validators = &registerValidators{
162 entries: make(map[types.VerifyType][]*types.RegisterValidator),
163 state: roundRobinState{
164 state: make(map[types.VerifyType]int),
165 },
166 }
167
168 s.pendingBlock = &pendingBlock{
169 processedTxs: make(map[common.Uint256]*tc.VerifyTxResult, 0),
170 unProcessedTxs: make(map[common.Uint256]*tx.Transaction, 0),
171 }
172
173 s.stats = txStats{count: make([]uint64, tc.MaxStats-1)}
174
175 s.slots = make(chan struct{}, tc.MAX_LIMITATION)
176 for i := 0; i < tc.MAX_LIMITATION; i++ {
177 s.slots <- struct{}{}
178 }
179
180 s.gasPrice = getGasPriceConfig()
181 log.Infof("tx pool: the current local gas price is %d", s.gasPrice)
182
183 s.disablePreExec = disablePreExec
184 s.disableBroadcastNetTx = disableBroadcastNetTx
185 // Create the given concurrent workers
186 s.workers = make([]txPoolWorker, num)
187 // Initial and start the workers
188 var i uint8
189 for i = 0; i < num; i++ {
190 s.wg.Add(1)
191 s.workers[i].init(i, s)
192 go s.workers[i].start()
193 }
194}
195
196// checkPendingBlockOk checks whether a block from consensus is verified.
197// If some transaction is invalid, return the result directly at once, no

Callers 1

NewTxPoolServerFunction · 0.95

Calls 5

InfofFunction · 0.92
getGasPriceConfigFunction · 0.85
AddMethod · 0.80
InitMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected