You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
625 B
36 lines
625 B
2 years ago
|
package registry
|
||
|
|
||
|
import (
|
||
|
"sync"
|
||
|
|
||
|
"github.com/harmony-one/harmony/core"
|
||
|
)
|
||
|
|
||
|
// Registry consolidates services at one place.
|
||
|
type Registry struct {
|
||
|
mu sync.Mutex
|
||
|
blockchain core.BlockChain
|
||
|
}
|
||
|
|
||
|
// New creates a new registry.
|
||
|
func New() *Registry {
|
||
|
return &Registry{}
|
||
|
}
|
||
|
|
||
|
// SetBlockchain sets the blockchain to registry.
|
||
|
func (r *Registry) SetBlockchain(bc core.BlockChain) *Registry {
|
||
|
r.mu.Lock()
|
||
|
defer r.mu.Unlock()
|
||
|
|
||
|
r.blockchain = bc
|
||
|
return r
|
||
|
}
|
||
|
|
||
|
// GetBlockchain gets the blockchain from registry.
|
||
|
func (r *Registry) GetBlockchain() core.BlockChain {
|
||
|
r.mu.Lock()
|
||
|
defer r.mu.Unlock()
|
||
|
|
||
|
return r.blockchain
|
||
|
}
|