Skip to content

Commit

Permalink
Correctly receive messages
Browse files Browse the repository at this point in the history
  • Loading branch information
bahner committed Feb 11, 2024
1 parent 982582c commit be5b6d7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ go.work

# Binaries created by go build ., ie the module name.
go-space
.*.log
10 changes: 6 additions & 4 deletions entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,17 @@ func getOrCreateEntity(id string) (*entity.Entity, error) {
return nil, err
}

// We need to publish the identity to the network, before we can create the entity
err = publishIdentityFromKeyset(k)
if err != nil {
return nil, fmt.Errorf("failed to publish identity: %w", err)
}

e, err := entity.NewFromKeyset(k, id)
if err != nil {
return nil, err
}

// This can take some time. It should be done in the background.
// Maybe with a timeout?
go publishIdentityFromKeyset(k)

entities.Set(id, e)

return e, nil
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module go-space
go 1.21.6

require (
github.com/bahner/go-ma v0.4.0
github.com/bahner/go-ma-actor v0.0.7-0.20240206001924-85fba2a776af
github.com/bahner/go-ma v0.4.2
github.com/bahner/go-ma-actor v0.0.9
github.com/ergo-services/ergo v1.999.224
github.com/fxamacker/cbor/v2 v2.5.0
github.com/sirupsen/logrus v1.9.3
Expand Down Expand Up @@ -162,6 +162,7 @@ require (
gonum.org/v1/gonum v0.14.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
lukechampine.com/blake3 v1.2.1 // indirect
)
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ github.com/alibabacloud-go/tea-utils v1.3.5/go.mod h1:EI/o33aBfj3hETm4RLiAxF/ThQ
github.com/aliyun/credentials-go v1.1.0/go.mod h1:ZXrrxv386Mj6z8NpihLKpexQE550m7j3LlyCvYub9aE=
github.com/aliyun/credentials-go v1.1.2/go.mod h1:ozcZaMR5kLM7pwtCMEpVmQ242suV6qTJya2bDq4X1Tw=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
github.com/bahner/go-ma v0.4.0 h1:JKHdjwzFwHakwe521ozJhLelCUgTqcuKtXAMnM2n7C0=
github.com/bahner/go-ma v0.4.0/go.mod h1:WM8wAs1tYjIuQLnM5kGkOo177N0dRQ4bXO4p/t63w+E=
github.com/bahner/go-ma-actor v0.0.7-0.20240206001924-85fba2a776af h1:hfODiDrJKypXSnKGuJBVDepEZenLgnWFJta6hZuR228=
github.com/bahner/go-ma-actor v0.0.7-0.20240206001924-85fba2a776af/go.mod h1:CEE0PwjKktRw7XnyP7Z8UgscsqhD8VE+gLMfO8ABqk8=
github.com/bahner/go-ma v0.4.2 h1:u0ZKy36ldJM/gwUS6IiyhFreoRvR131FzVx1+vQ9qFo=
github.com/bahner/go-ma v0.4.2/go.mod h1:WM8wAs1tYjIuQLnM5kGkOo177N0dRQ4bXO4p/t63w+E=
github.com/bahner/go-ma-actor v0.0.9 h1:7e5EtaoY71NRIZk6du7m3mWmqk0EoNKEPCKYthX8p4c=
github.com/bahner/go-ma-actor v0.0.9/go.mod h1:r/If1ecXk+fD9t8a7qwHWC39977qoLk5w5huZC/7V4M=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/benbjohnson/clock v1.3.5 h1:VvXlSJBzZpA/zum6Sj74hxwYI2DIxRWuNIoXAzHZz5o=
Expand Down
4 changes: 2 additions & 2 deletions node.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ func StartApplication(_p2p *p2p.P2P) {
// Starting node
n, err = ergo.StartNodeWithContext(ctx, nodeName, nodeCookie, options)
if err != nil {
panic(err)
log.Fatalf("Failed to start node: %s", err)
}

// Starting applications
process, err = n.Spawn("space", gen.ProcessOptions{}, new(SPACE))
if err != nil {
panic(err)
log.Fatalf("Failed to spawn space application: %s", err)
}

log.Infof("Started process %q with PID %s.", process.Name(), process.Self())
Expand Down

0 comments on commit be5b6d7

Please sign in to comment.