Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make it possible to compose with other graceland implementations #783

Merged
merged 3 commits into from
Feb 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,20 @@ const (
defaultDBGCRatio = 0.5
)

var (
defaultHTTPHeaders = []utils.HTTPHeader{
{
Key: "Access-Control-Allow-Origin",
Value: "*",
},
{
Key: "Access-Control-Allow-Methods",
Value: "POST, GET, OPTIONS, PUT, DELETE",
},
{
Key: "Access-Control-Allow-Headers",
Value: "*",
},
}
)
var defaultHTTPHeaders = []utils.HTTPHeader{
{
Key: "Access-Control-Allow-Origin",
Value: "*",
},
{
Key: "Access-Control-Allow-Methods",
Value: "POST, GET, OPTIONS, PUT, DELETE",
},
{
Key: "Access-Control-Allow-Headers",
Value: "*",
},
}

// Config is the configuration for an emulator server.
type Config struct {
Expand Down Expand Up @@ -129,11 +127,11 @@ type Config struct {
SkipTransactionValidation bool
// Host listen on for the emulator servers (REST/GRPC/Admin)
Host string
//Chain to emulation
// Chain to emulation
ChainID flowgo.ChainID
//Redis URL for redis storage backend
// Redis URL for redis storage backend
RedisURL string
//Sqlite URL for sqlite storage backend
// Sqlite URL for sqlite storage backend
SqliteURL string
// CoverageReportingEnabled enables/disables Cadence code coverage reporting.
CoverageReportingEnabled bool
Expand Down Expand Up @@ -257,10 +255,8 @@ func (s *EmulatorServer) Listen() error {
// Start starts the Flow Emulator server.
//
// This is a blocking call that listens and starts the emulator server.
func (s *EmulatorServer) Start() {
s.Stop()

s.group = graceland.NewGroup()
func (s *EmulatorServer) AddToGroup(group *graceland.Group) {
s.group = group
// only start blocks ticker if it exists
if s.blocks != nil {
s.group.Add(s.blocks)
Expand Down Expand Up @@ -291,9 +287,13 @@ func (s *EmulatorServer) Start() {
if s.blocks != nil {
s.group.Add(s.blocks)
}

// routines are shut down in insertion order, so database is added last
s.group.Add(s.storage)
}

func (s *EmulatorServer) Start() {
s.Stop()
s.AddToGroup(graceland.NewGroup())

err := s.group.Start()
if err != nil {
Expand Down
Loading