BlockObserver
Simple scalable blockchain observer
Features
- Observe Ethereum
- Observe Ripple
Installation
Swift Package Manager
To include BlockObserver using Swift Package Manager add this line to your Package.swift
dependencies: [
.package(url: "https://github.com/impul/BlockObserver.git", from: "0.1.5")
]
CocoaPods
To integrate BlockObserver into your Xcode project using CocoaPods, specify it in your Podfile
:
pod 'BlockObserver'
Carthage
To include BlockObserver using Carthage, simply add this in your Cartfile
:
github "impul/BlockObserver"
Communication
- If you found a bug, open an issue.
- If you have a feature request, open an issue.
- If you want to contribute, submit a pull request.
How to use
There is three ways to init BlockObserver
Default way, use embedded blockchain observers
let blockObserver = BlockObserver(assets: [.ethereum, .ripple])
blockObserver.addObserver(for: "0xB29f7E1AB952CF2770D56712e4667680F55359eb", asset: .ethereum)
Use your own Blockchain Observers
let myEhtereumObserver: BlockchainObserverInterface = RippleBlockchainObserver()
let myRippleObserver: BlockchainObserverInterface = EthereumBlockchainObserver()
let buffer: TransactionsBufferInterfce = TransactionsBuffer(capacity: 100)
let looger: Logger = PrintLoger()
let blockObserver = BlockObserver(blockchainsObservers: [myEhtereumObserver, myRippleObserver],
buffer: buffer,
logger: looger)
myEhtereumObserver.delegate = blockObserver
myRippleObserver.delegate = blockObserver
If you do not create own .init in your blockchain observers, you can use simpler init
let buffer: TransactionsBufferInterfce = TransactionsBuffer(capacity: 100)
let looger: Logger = PrintLoger()
let blockObserver = BlockObserver(blockchainsObservers: [RippleBlockchainObserver.self, RippleBlockchainObserver.self],
buffer: buffer,
logger: looger)
Add observer
blockObserver.addObserver(for: "0xB29f7E1AB952CF2770D56712e4667680F55359eb", asset: .ethereum)
Remove observer
blockObserver.removeObserver(for: "0xB29f7E1AB952CF2770D56712e4667680F55359eb", asset: .ethereum)
That's all, now you can check your transactions when you want:
print(blockObserver.transactions)
License
BlockOberver is released under the MIT License.