-
Notifications
You must be signed in to change notification settings - Fork 72
/
chain.go
28 lines (25 loc) · 1.08 KB
/
chain.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package chain
import (
"github.com/keep-network/keep-core/pkg/beacon"
"github.com/keep-network/keep-core/pkg/beacon/relay"
)
// BlockCounter is an interface that provides the ability to wait for a certain
// number of abstract blocks. It provides for two ways to wait, one blocking and
// one chan-based. Block height is expected to increase monotonically, though
// the time between blocks will depend on the underlying implementation. See
// LocalBlockCounter() for a local implementation.
type BlockCounter interface {
// WaitForBlocks blocks at the caller until numBlocks new blocks have been
// seen.
WaitForBlocks(numBlocks int)
// BlockWaiter returns a channel that will emit the current block height
// after the given number of blocks has elapsed and then immediately close.
BlockWaiter(numBlocks int) <-chan int
}
// Handle represents a handle to a blockchain that provides access to the core
// functionality needed for Keep network interactions.
type Handle interface {
BlockCounter() BlockCounter
RandomBeacon() beacon.ChainInterface
ThresholdRelay() relay.ChainInterface
}