Skip to content

Commit 022390c

Browse files
committed
eth,les: Remove concept of public/private API definitions (ethereum#25053)
1 parent c8b98d2 commit 022390c

File tree

4 files changed

+26
-26
lines changed

4 files changed

+26
-26
lines changed

eth/backend.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ func (s *Ethereum) APIs() []rpc.API {
406406
}, {
407407
Namespace: "eth",
408408
Version: "1.0",
409-
Service: filters.NewPublicFilterAPI(s.ApiBackend, false, 5*time.Minute),
409+
Service: filters.NewFilterAPI(s.ApiBackend, false, 5*time.Minute),
410410
Public: true,
411411
}, {
412412
Namespace: "admin",

eth/filters/api.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ type filter struct {
5151
s *Subscription // associated subscription in event system
5252
}
5353

54-
// PublicFilterAPI offers support to create and manage filters. This will allow external clients to retrieve various
54+
// FilterAPI offers support to create and manage filters. This will allow external clients to retrieve various
5555
// information related to the Ethereum protocol such als blocks, transactions and logs.
56-
type PublicFilterAPI struct {
56+
type FilterAPI struct {
5757
backend Backend
5858
chainDb ethdb.Database
5959
events *EventSystem
@@ -62,9 +62,9 @@ type PublicFilterAPI struct {
6262
timeout time.Duration
6363
}
6464

65-
// NewPublicFilterAPI returns a new PublicFilterAPI instance.
66-
func NewPublicFilterAPI(backend Backend, lightMode bool, timeout time.Duration) *PublicFilterAPI {
67-
api := &PublicFilterAPI{
65+
// NewFilterAPI returns a new FilterAPI instance.
66+
func NewFilterAPI(backend Backend, lightMode bool, timeout time.Duration) *FilterAPI {
67+
api := &FilterAPI{
6868
backend: backend,
6969
chainDb: backend.ChainDb(),
7070
events: NewEventSystem(backend, lightMode),
@@ -78,7 +78,7 @@ func NewPublicFilterAPI(backend Backend, lightMode bool, timeout time.Duration)
7878

7979
// timeoutLoop runs every 5 minutes and deletes filters that have not been recently used.
8080
// Tt is started when the api is created.
81-
func (api *PublicFilterAPI) timeoutLoop(timeout time.Duration) {
81+
func (api *FilterAPI) timeoutLoop(timeout time.Duration) {
8282
var toUninstall []*Subscription
8383
ticker := time.NewTicker(timeout)
8484
for {
@@ -112,7 +112,7 @@ func (api *PublicFilterAPI) timeoutLoop(timeout time.Duration) {
112112
// `eth_getFilterChanges` polling method that is also used for log filters.
113113
//
114114
// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newpendingtransactionfilter
115-
func (api *PublicFilterAPI) NewPendingTransactionFilter() rpc.ID {
115+
func (api *FilterAPI) NewPendingTransactionFilter() rpc.ID {
116116
var (
117117
pendingTxs = make(chan []common.Hash)
118118
pendingTxSub = api.events.SubscribePendingTxs(pendingTxs)
@@ -145,7 +145,7 @@ func (api *PublicFilterAPI) NewPendingTransactionFilter() rpc.ID {
145145

146146
// NewPendingTransactions creates a subscription that is triggered each time a transaction
147147
// enters the transaction pool and was signed from one of the transactions this nodes manages.
148-
func (api *PublicFilterAPI) NewPendingTransactions(ctx context.Context) (*rpc.Subscription, error) {
148+
func (api *FilterAPI) NewPendingTransactions(ctx context.Context) (*rpc.Subscription, error) {
149149
notifier, supported := rpc.NotifierFromContext(ctx)
150150
if !supported {
151151
return &rpc.Subscription{}, rpc.ErrNotificationsUnsupported
@@ -182,7 +182,7 @@ func (api *PublicFilterAPI) NewPendingTransactions(ctx context.Context) (*rpc.Su
182182
// It is part of the filter package since polling goes with eth_getFilterChanges.
183183
//
184184
// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newblockfilter
185-
func (api *PublicFilterAPI) NewBlockFilter() rpc.ID {
185+
func (api *FilterAPI) NewBlockFilter() rpc.ID {
186186
var (
187187
headers = make(chan *types.Header)
188188
headerSub = api.events.SubscribeNewHeads(headers)
@@ -214,7 +214,7 @@ func (api *PublicFilterAPI) NewBlockFilter() rpc.ID {
214214
}
215215

216216
// NewHeads send a notification each time a new (header) block is appended to the chain.
217-
func (api *PublicFilterAPI) NewHeads(ctx context.Context) (*rpc.Subscription, error) {
217+
func (api *FilterAPI) NewHeads(ctx context.Context) (*rpc.Subscription, error) {
218218
notifier, supported := rpc.NotifierFromContext(ctx)
219219
if !supported {
220220
return &rpc.Subscription{}, rpc.ErrNotificationsUnsupported
@@ -244,7 +244,7 @@ func (api *PublicFilterAPI) NewHeads(ctx context.Context) (*rpc.Subscription, er
244244
}
245245

246246
// Logs creates a subscription that fires for all new log that match the given filter criteria.
247-
func (api *PublicFilterAPI) Logs(ctx context.Context, crit FilterCriteria) (*rpc.Subscription, error) {
247+
func (api *FilterAPI) Logs(ctx context.Context, crit FilterCriteria) (*rpc.Subscription, error) {
248248
notifier, supported := rpc.NotifierFromContext(ctx)
249249
if !supported {
250250
return &rpc.Subscription{}, rpc.ErrNotificationsUnsupported
@@ -298,7 +298,7 @@ type FilterCriteria ethereum.FilterQuery
298298
// In case "fromBlock" > "toBlock" an error is returned.
299299
//
300300
// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newfilter
301-
func (api *PublicFilterAPI) NewFilter(crit FilterCriteria) (rpc.ID, error) {
301+
func (api *FilterAPI) NewFilter(crit FilterCriteria) (rpc.ID, error) {
302302
logs := make(chan []*types.Log)
303303
logsSub, err := api.events.SubscribeLogs(ethereum.FilterQuery(crit), logs)
304304
if err != nil {
@@ -333,7 +333,7 @@ func (api *PublicFilterAPI) NewFilter(crit FilterCriteria) (rpc.ID, error) {
333333
// GetLogs returns logs matching the given argument that are stored within the state.
334334
//
335335
// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getlogs
336-
func (api *PublicFilterAPI) GetLogs(ctx context.Context, crit FilterCriteria) ([]*types.Log, error) {
336+
func (api *FilterAPI) GetLogs(ctx context.Context, crit FilterCriteria) ([]*types.Log, error) {
337337
if len(crit.Topics) > maxTopics {
338338
return nil, errExceedMaxTopics
339339
}
@@ -366,7 +366,7 @@ func (api *PublicFilterAPI) GetLogs(ctx context.Context, crit FilterCriteria) ([
366366
// UninstallFilter removes the filter with the given filter id.
367367
//
368368
// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_uninstallfilter
369-
func (api *PublicFilterAPI) UninstallFilter(id rpc.ID) bool {
369+
func (api *FilterAPI) UninstallFilter(id rpc.ID) bool {
370370
api.filtersMu.Lock()
371371
f, found := api.filters[id]
372372
if found {
@@ -384,7 +384,7 @@ func (api *PublicFilterAPI) UninstallFilter(id rpc.ID) bool {
384384
// If the filter could not be found an empty array of logs is returned.
385385
//
386386
// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getfilterlogs
387-
func (api *PublicFilterAPI) GetFilterLogs(ctx context.Context, id rpc.ID) ([]*types.Log, error) {
387+
func (api *FilterAPI) GetFilterLogs(ctx context.Context, id rpc.ID) ([]*types.Log, error) {
388388
api.filtersMu.Lock()
389389
f, found := api.filters[id]
390390
api.filtersMu.Unlock()
@@ -425,7 +425,7 @@ func (api *PublicFilterAPI) GetFilterLogs(ctx context.Context, id rpc.ID) ([]*ty
425425
// (pending)Log filters return []Log.
426426
//
427427
// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getfilterchanges
428-
func (api *PublicFilterAPI) GetFilterChanges(id rpc.ID) (interface{}, error) {
428+
func (api *FilterAPI) GetFilterChanges(id rpc.ID) (interface{}, error) {
429429
api.filtersMu.Lock()
430430
defer api.filtersMu.Unlock()
431431

eth/filters/filter_system_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ func TestBlockSubscription(t *testing.T) {
158158
var (
159159
db = rawdb.NewMemoryDatabase()
160160
backend = &testBackend{db: db}
161-
api = NewPublicFilterAPI(backend, false, deadline)
161+
api = NewFilterAPI(backend, false, deadline)
162162
genesis = new(core.Genesis).MustCommit(db)
163163
chain, _ = core.GenerateChain(params.TestChainConfig, genesis, ethash.NewFaker(), db, 10, func(i int, gen *core.BlockGen) {})
164164
chainEvents = []core.ChainEvent{}
@@ -210,7 +210,7 @@ func TestPendingTxFilter(t *testing.T) {
210210
var (
211211
db = rawdb.NewMemoryDatabase()
212212
backend = &testBackend{db: db}
213-
api = NewPublicFilterAPI(backend, false, deadline)
213+
api = NewFilterAPI(backend, false, deadline)
214214

215215
transactions = []*types.Transaction{
216216
types.NewTransaction(0, common.HexToAddress("0xb794f5ea0ba39494ce83a213fffba74279579268"), new(big.Int), 0, new(big.Int), nil),
@@ -265,7 +265,7 @@ func TestLogFilterCreation(t *testing.T) {
265265
var (
266266
db = rawdb.NewMemoryDatabase()
267267
backend = &testBackend{db: db}
268-
api = NewPublicFilterAPI(backend, false, deadline)
268+
api = NewFilterAPI(backend, false, deadline)
269269

270270
testCases = []struct {
271271
crit FilterCriteria
@@ -309,7 +309,7 @@ func TestInvalidLogFilterCreation(t *testing.T) {
309309
var (
310310
db = rawdb.NewMemoryDatabase()
311311
backend = &testBackend{db: db}
312-
api = NewPublicFilterAPI(backend, false, deadline)
312+
api = NewFilterAPI(backend, false, deadline)
313313
)
314314

315315
// different situations where log filter creation should fail.
@@ -331,7 +331,7 @@ func TestInvalidGetLogsRequest(t *testing.T) {
331331
var (
332332
db = rawdb.NewMemoryDatabase()
333333
backend = &testBackend{db: db}
334-
api = NewPublicFilterAPI(backend, false, deadline)
334+
api = NewFilterAPI(backend, false, deadline)
335335
blockHash = common.HexToHash("0x1111111111111111111111111111111111111111111111111111111111111111")
336336
)
337337

@@ -356,7 +356,7 @@ func TestLogFilter(t *testing.T) {
356356
var (
357357
db = rawdb.NewMemoryDatabase()
358358
backend = &testBackend{db: db}
359-
api = NewPublicFilterAPI(backend, false, deadline)
359+
api = NewFilterAPI(backend, false, deadline)
360360

361361
firstAddr = common.HexToAddress("0x1111111111111111111111111111111111111111")
362362
secondAddr = common.HexToAddress("0x2222222222222222222222222222222222222222")
@@ -470,7 +470,7 @@ func TestPendingLogsSubscription(t *testing.T) {
470470
var (
471471
db = rawdb.NewMemoryDatabase()
472472
backend = &testBackend{db: db}
473-
api = NewPublicFilterAPI(backend, false, deadline)
473+
api = NewFilterAPI(backend, false, deadline)
474474

475475
firstAddr = common.HexToAddress("0x1111111111111111111111111111111111111111")
476476
secondAddr = common.HexToAddress("0x2222222222222222222222222222222222222222")
@@ -606,7 +606,7 @@ func TestPendingTxFilterDeadlock(t *testing.T) {
606606
var (
607607
db = rawdb.NewMemoryDatabase()
608608
backend = &testBackend{db: db}
609-
api = NewPublicFilterAPI(backend, false, timeout)
609+
api = NewFilterAPI(backend, false, timeout)
610610
done = make(chan struct{})
611611
)
612612

les/backend.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ func (s *LightEthereum) APIs() []rpc.API {
190190
}, {
191191
Namespace: "eth",
192192
Version: "1.0",
193-
Service: filters.NewPublicFilterAPI(s.ApiBackend, true, 5*time.Minute),
193+
Service: filters.NewFilterAPI(s.ApiBackend, true, 5*time.Minute),
194194
Public: true,
195195
}, {
196196
Namespace: "net",

0 commit comments

Comments
 (0)