github.com/status-im/status-go@v1.1.0/eth-node/bridge/geth/subscription.go (about)

     1  package gethbridge
     2  
     3  import (
     4  	"github.com/ethereum/go-ethereum/event"
     5  
     6  	"github.com/status-im/status-go/eth-node/types"
     7  )
     8  
     9  type gethSubscriptionWrapper struct {
    10  	subscription event.Subscription
    11  }
    12  
    13  // NewGethSubscriptionWrapper returns an object that wraps Geth's Subscription in a types interface
    14  func NewGethSubscriptionWrapper(subscription event.Subscription) types.Subscription {
    15  	if subscription == nil {
    16  		panic("subscription cannot be nil")
    17  	}
    18  
    19  	return &gethSubscriptionWrapper{
    20  		subscription: subscription,
    21  	}
    22  }
    23  
    24  func (w *gethSubscriptionWrapper) Err() <-chan error {
    25  	return w.subscription.Err()
    26  }
    27  
    28  func (w *gethSubscriptionWrapper) Unsubscribe() {
    29  	w.subscription.Unsubscribe()
    30  }