diff --git a/cmd/serve.go b/cmd/serve.go index a1fb8621..8a4f110a 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -26,6 +26,7 @@ import ( "time" "github.com/cerc-io/ipld-eth-server/v5/pkg/log" + "github.com/cerc-io/ipld-eth-server/v5/pkg/nitro" "github.com/ethereum/go-ethereum/rpc" "github.com/mailgun/groupcache/v2" "github.com/spf13/cobra" @@ -95,6 +96,14 @@ func serve() { logWithCommand.Debug("state validator disabled") } + // TODO: Create required config for Nitro node + + // TODO: Create a new Nitro node using the config + nitro, _ := nitro.NewNitroNode() + + // TODO: Start the Nitro node, pass wg + nitro.Start(wg) + shutdown := make(chan os.Signal, 1) signal.Notify(shutdown, os.Interrupt) <-shutdown @@ -102,6 +111,10 @@ func serve() { graphQL.Stop() } server.Stop() + + // TODO: Stop nitro node + nitro.Stop() + wg.Wait() } diff --git a/go.mod b/go.mod index a61f89fc..feb9346a 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/cerc-io/ipfs-ethdb/v5 v5.0.0-alpha github.com/cerc-io/ipld-eth-statedb v0.0.5-alpha github.com/cerc-io/plugeth-statediff v0.1.1 - github.com/ethereum/go-ethereum v1.11.6 + github.com/ethereum/go-ethereum v1.12.0 // TODO: Investigate github.com/google/uuid v1.3.0 github.com/graph-gophers/graphql-go v1.3.0 github.com/ipfs/go-cid v0.4.1 @@ -291,3 +291,5 @@ replace ( // https://git.vdb.to/cerc-io/ipfs-ethdb/src/branch/v5-go-upgrade github.com/cerc-io/ipfs-ethdb/v5 => github.com/cerc-io/ipfs-ethdb/v5 v5.0.1-alpha.0.20231013070931-0b1a36562a28 ) + +replace github.com/statechannels/go-nitro v0.1.1 => github.com/cerc-io/go-nitro v0.1.1-ts-port-0.1.5 diff --git a/pkg/nitro/node.go b/pkg/nitro/node.go new file mode 100644 index 00000000..8ca98430 --- /dev/null +++ b/pkg/nitro/node.go @@ -0,0 +1,48 @@ +// VulcanizeDB +// Copyright © 2023 Vulcanize + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. + +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package nitro + +import ( + "sync" +) + +// TODO: Implement +// Struct representing the in-process Nitro node +type NitroNode struct { + // Used to signal shutdown of the node + QuitChan chan bool +} + +func NewNitroNode() (NitroNode, error) { + // TODO: Implement + return NitroNode{}, nil +} + +func (n *NitroNode) Start(wg *sync.WaitGroup) { + // TODO: Implement + go func() { + wg.Add(1) + defer wg.Done() + <-n.QuitChan + }() +} + +func (n *NitroNode) Stop() error { + // TODO: Implement + close(n.QuitChan) + return nil +}