This repository has been archived by the owner on Apr 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 559
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: rpc namespace refactor - txpool * refactor: rpc namespace refactor - net * refactor: rpc namespace refactor - web3 * refactor: rpc namespace refactor - eth * refactor: rpc namespace refactor - personal * fix: api to uppercase * fix: fix import cycle * fix: fix import cycle
- Loading branch information
1 parent
1f96204
commit 1c06553
Showing
14 changed files
with
292 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package rpc | ||
package backend | ||
|
||
import ( | ||
"context" | ||
|
91 changes: 46 additions & 45 deletions
91
ethereum/rpc/eth_api.go → ethereum/rpc/namespaces/eth/api.go
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package filters | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
ethtypes "github.com/ethereum/go-ethereum/core/types" | ||
"github.com/ethereum/go-ethereum/eth/filters" | ||
"github.com/ethereum/go-ethereum/rpc" | ||
coretypes "github.com/tendermint/tendermint/rpc/core/types" | ||
) | ||
|
||
// Subscription defines a wrapper for the private subscription | ||
type Subscription struct { | ||
id rpc.ID | ||
typ filters.Type | ||
event string | ||
created time.Time | ||
logsCrit filters.FilterCriteria | ||
logs chan []*ethtypes.Log | ||
hashes chan []common.Hash | ||
headers chan *ethtypes.Header | ||
installed chan struct{} // closed when the filter is installed | ||
eventCh <-chan coretypes.ResultEvent | ||
err chan error | ||
} | ||
|
||
// ID returns the underlying subscription RPC identifier. | ||
func (s Subscription) ID() rpc.ID { | ||
return s.id | ||
} | ||
|
||
// Unsubscribe from the current subscription to Tendermint Websocket. It sends an error to the | ||
// subscription error channel if unsubscription fails. | ||
func (s *Subscription) Unsubscribe(es *EventSystem) { | ||
go func() { | ||
uninstallLoop: | ||
for { | ||
// write uninstall request and consume logs/hashes. This prevents | ||
// the eventLoop broadcast method to deadlock when writing to the | ||
// filter event channel while the subscription loop is waiting for | ||
// this method to return (and thus not reading these events). | ||
select { | ||
case es.uninstall <- s: | ||
break uninstallLoop | ||
case <-s.logs: | ||
case <-s.hashes: | ||
case <-s.headers: | ||
} | ||
} | ||
}() | ||
} | ||
|
||
// Err returns the error channel | ||
func (s *Subscription) Err() <-chan error { | ||
return s.err | ||
} | ||
|
||
// Event returns the tendermint result event channel | ||
func (s *Subscription) Event() <-chan coretypes.ResultEvent { | ||
return s.eventCh | ||
} |
Oops, something went wrong.