@@ -13,7 +13,7 @@ import (
13
13
)
14
14
15
15
type Backend struct {
16
- arbos ArbosWrapper
16
+ publisher TransactionPublisher
17
17
blockChain * core.BlockChain
18
18
stack * node.Node
19
19
chainId * big.Int
@@ -29,9 +29,9 @@ type Backend struct {
29
29
chanNewBlock chan struct {} //create new L2 block unless empty
30
30
}
31
31
32
- func NewBackend (stack * node.Node , config * ethconfig.Config , ethDatabase ethdb.Database , blockChain * core.BlockChain , chainId * big.Int , arbos ArbosWrapper ) (* Backend , error ) {
32
+ func NewBackend (stack * node.Node , config * ethconfig.Config , ethDatabase ethdb.Database , blockChain * core.BlockChain , chainId * big.Int , publisher TransactionPublisher ) (* Backend , error ) {
33
33
backend := & Backend {
34
- arbos : arbos ,
34
+ publisher : publisher ,
35
35
blockChain : blockChain ,
36
36
stack : stack ,
37
37
chainId : chainId ,
@@ -42,7 +42,6 @@ func NewBackend(stack *node.Node, config *ethconfig.Config, ethDatabase ethdb.Da
42
42
chanNewBlock : make (chan struct {}, 1 ),
43
43
}
44
44
stack .RegisterLifecycle (backend )
45
- go backend .segmentQueueRoutine ()
46
45
47
46
createRegisterAPIBackend (backend )
48
47
return backend , nil
@@ -53,12 +52,7 @@ func (b *Backend) APIBackend() *APIBackend {
53
52
}
54
53
55
54
func (b * Backend ) EnqueueL2Message (tx * types.Transaction ) error {
56
- b .chanTxs <- tx
57
- return nil
58
- }
59
-
60
- func (b * Backend ) CloseBlock () {
61
- b .chanNewBlock <- struct {}{}
55
+ return b .publisher .PublishTransaction (tx )
62
56
}
63
57
64
58
func (b * Backend ) SubscribeNewTxsEvent (ch chan <- core.NewTxsEvent ) event.Subscription {
@@ -76,20 +70,6 @@ func (b *Backend) enqueueBlock(block *types.Block, reciepts types.Receipts, stat
76
70
b .blockChain .WriteBlockWithState (block , reciepts , logs , state , true )
77
71
}
78
72
79
- func (b * Backend ) segmentQueueRoutine () {
80
- for {
81
- select {
82
- case tx := <- b .chanTxs :
83
- b .txFeed .Send (core.NewTxsEvent {Txs : []* types.Transaction {tx }})
84
- b .arbos .EnqueueSequencerTx (tx )
85
- case <- b .chanNewBlock :
86
- b .enqueueBlock (b .arbos .BuildBlock (true ))
87
- case <- b .chanClose :
88
- return
89
- }
90
- }
91
- }
92
-
93
73
//TODO: this is used when registering backend as lifecycle in stack
94
74
func (b * Backend ) Start () error {
95
75
return nil
0 commit comments