Integrate go-nitro node for payments #256

Merged
ashwin merged 12 commits from deep-stack/ipld-eth-server:pm-integrate-go-nitro into payments 2023-10-13 09:03:11 +00:00
3 changed files with 64 additions and 1 deletions
Showing only changes of commit 2708d02558 - Show all commits

View File

@ -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()
}

4
go.mod
View File

@ -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

48
pkg/nitro/node.go Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
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
}