Skip to content

Commit a580b62

Browse files
committed
Revert "New attempt"
This reverts commit d853327.
1 parent d853327 commit a580b62

File tree

4 files changed

+48
-101
lines changed

4 files changed

+48
-101
lines changed

arbitrum/apibackend.go

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,8 @@ func createRegisterAPIBackend(backend *Backend, filterConfig filters.Config, fal
150150
archiveClientsManager: archiveClientsManager,
151151
}
152152
filterSystem := filters.NewFilterSystem(backend.apiBackend, filterConfig)
153-
apis := backend.apiBackend.GetAPIs(filterSystem)
154-
backend.stack.RegisterAPIs(apis.Slice())
155-
156-
service := apis.EthAPIs.TransactionAPI.Service
157-
receiptFetcher, ok := service.(ReceiptFetcher)
158-
if !ok {
159-
return nil, nil, fmt.Errorf("TransactionAPI.Service does not implement ReceiptFetcher")
160-
}
153+
apis, receiptFetcher := backend.apiBackend.GetAPIs(filterSystem)
154+
backend.stack.RegisterAPIs(apis)
161155
return filterSystem, receiptFetcher, nil
162156
}
163157

@@ -169,35 +163,40 @@ func (a *APIBackend) SetSyncBackend(sync SyncProgressBackend) error {
169163
return nil
170164
}
171165

172-
func (a *APIBackend) GetAPIs(filterSystem *filters.FilterSystem) APIs {
173-
return APIs{
174-
EthAPIs: ethapi.GetAPIs(a),
175-
FilterAPI: rpc.API{
176-
Namespace: "eth",
177-
Version: "1.0",
178-
Service: filters.NewFilterAPI(filterSystem),
179-
Public: true,
180-
},
181-
ArbTransactionAPI: rpc.API{
182-
Namespace: "eth",
183-
Version: "1.0",
184-
Service: NewArbTransactionAPI(a),
185-
Public: true,
186-
},
187-
PublicNetAPI: rpc.API{
188-
Namespace: "net",
189-
Version: "1.0",
190-
Service: NewPublicNetAPI(a.ChainConfig().ChainID.Uint64()),
191-
Public: true,
192-
},
193-
PublicTxPoolAPI: rpc.API{
194-
Namespace: "txpool",
195-
Version: "1.0",
196-
Service: NewPublicTxPoolAPI(),
197-
Public: true,
198-
},
199-
TracersAPIs: tracers.APIs(a),
200-
}
166+
func (a *APIBackend) GetAPIs(filterSystem *filters.FilterSystem) ([]rpc.API, ReceiptFetcher) {
167+
apis, transactionAPI := ethapi.GetAPIs(a)
168+
169+
apis = append(apis, rpc.API{
170+
Namespace: "eth",
171+
Version: "1.0",
172+
Service: filters.NewFilterAPI(filterSystem),
173+
Public: true,
174+
})
175+
176+
apis = append(apis, rpc.API{
177+
Namespace: "eth",
178+
Version: "1.0",
179+
Service: NewArbTransactionAPI(a),
180+
Public: true,
181+
})
182+
183+
apis = append(apis, rpc.API{
184+
Namespace: "net",
185+
Version: "1.0",
186+
Service: NewPublicNetAPI(a.ChainConfig().ChainID.Uint64()),
187+
Public: true,
188+
})
189+
190+
apis = append(apis, rpc.API{
191+
Namespace: "txpool",
192+
Version: "1.0",
193+
Service: NewPublicTxPoolAPI(),
194+
Public: true,
195+
})
196+
197+
apis = append(apis, tracers.APIs(a)...)
198+
199+
return apis, transactionAPI
201200
}
202201

203202
func (a *APIBackend) BlockChain() *core.BlockChain {

arbitrum/apis.go

Lines changed: 0 additions & 28 deletions
This file was deleted.

eth/backend.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ func makeExtraData(extra []byte) []byte {
394394
// APIs return the collection of RPC services the ethereum package offers.
395395
// NOTE, some of these services probably need to be moved to somewhere else.
396396
func (s *Ethereum) APIs() []rpc.API {
397-
apis := ethapi.GetAPIs(s.APIBackend).Slice()
397+
apis, _ := ethapi.GetAPIs(s.APIBackend)
398398

399399
// Append all the local APIs and return
400400
return append(apis, []rpc.API{

internal/ethapi/backend.go

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -108,52 +108,28 @@ type Backend interface {
108108
NewMatcherBackend() filtermaps.MatcherBackend
109109
}
110110

111-
func GetAPIs(apiBackend Backend) APIs {
111+
func GetAPIs(apiBackend Backend) ([]rpc.API, *TransactionAPI) {
112112
nonceLock := new(AddrLocker)
113-
return APIs{
114-
EthereumAPI: rpc.API{
113+
transactionAPI := NewTransactionAPI(apiBackend, nonceLock)
114+
return []rpc.API{
115+
{
115116
Namespace: "eth",
116117
Service: NewEthereumAPI(apiBackend),
117-
},
118-
BlockChainAPI: rpc.API{
118+
}, {
119119
Namespace: "eth",
120120
Service: NewBlockChainAPI(apiBackend),
121-
},
122-
TransactionAPI: rpc.API{
121+
}, {
123122
Namespace: "eth",
124-
Service: NewTransactionAPI(apiBackend, nonceLock),
125-
},
126-
TxPoolAPI: rpc.API{
123+
Service: transactionAPI,
124+
}, {
127125
Namespace: "txpool",
128126
Service: NewTxPoolAPI(apiBackend),
129-
},
130-
DebugAPI: rpc.API{
127+
}, {
131128
Namespace: "debug",
132129
Service: NewDebugAPI(apiBackend),
133-
},
134-
EthereumAccountAPI: rpc.API{
130+
}, {
135131
Namespace: "eth",
136132
Service: NewEthereumAccountAPI(apiBackend.AccountManager()),
137133
},
138-
}
139-
}
140-
141-
type APIs struct {
142-
EthereumAPI rpc.API
143-
BlockChainAPI rpc.API
144-
TransactionAPI rpc.API
145-
TxPoolAPI rpc.API
146-
DebugAPI rpc.API
147-
EthereumAccountAPI rpc.API
148-
}
149-
150-
func (a APIs) Slice() []rpc.API {
151-
return []rpc.API{
152-
a.EthereumAPI,
153-
a.BlockChainAPI,
154-
a.TransactionAPI,
155-
a.TxPoolAPI,
156-
a.DebugAPI,
157-
a.EthereumAccountAPI,
158-
}
134+
}, transactionAPI
159135
}

0 commit comments

Comments
 (0)