status-im/status-go

View on GitHub
eth-node/bridge/geth/subscription.go

Summary

Maintainability
A
0 mins
Test Coverage
D
66%
package gethbridge

import (
    "github.com/ethereum/go-ethereum/event"

    "github.com/status-im/status-go/eth-node/types"
)

type gethSubscriptionWrapper struct {
    subscription event.Subscription
}

// NewGethSubscriptionWrapper returns an object that wraps Geth's Subscription in a types interface
func NewGethSubscriptionWrapper(subscription event.Subscription) types.Subscription {
    if subscription == nil {
        panic("subscription cannot be nil")
    }

    return &gethSubscriptionWrapper{
        subscription: subscription,
    }
}

func (w *gethSubscriptionWrapper) Err() <-chan error {
    return w.subscription.Err()
}

func (w *gethSubscriptionWrapper) Unsubscribe() {
    w.subscription.Unsubscribe()
}