Skip to content

Commit

Permalink
Upgraded go-ma to v0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
bahner committed Jan 22, 2024
1 parent 8b61360 commit aa401cf
Show file tree
Hide file tree
Showing 13 changed files with 98 additions and 223 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"program": "${fileDirname}",
"args": [
"-loglevel", "debug",
"-keyset", "z92ekm6BMHDc1wJNkbmzqFpRxX7JwQUDEFcawGdkvWZcLNC7FbWKfFtM8rm7n2fh68U2NmDke4kjMv5HJtmaByMSbvLbtzqSR6yRt29PWvytLdsNXc4iaNQrGH2KmMixCMu4wgsDoHZsQSDRykyBpcypggLNfJuTU1EhVhLPjbp2CaZDCWcAF4mXPnFKUuBb2fwGiZ6JtmAXoQeZDHRW1adsC3g9nDULMnonm6Ex7HwSDh3ojywZFzhiJpKD22Wrn43XHDnU6DXdi7aCyFEhQcR1itn6jPppnArzFT24puVFUqMgXfEhysWzG42svTaArziFL1jbqZox7jJBce1ZecBaY14A58AHqXS2azeijf1iiwkRZSCfzAR6mJmE6EJiMWnoXySghw14xAEoxZhrmg9QWBHu36xvzVnfqmk9apJgKuEqS4kk17JVHQJbqwXYs6cqm2soSXF5zzgRKUTyH3oRUoozTN9EYR9gnn5aS2qZv6AvC3umeYYZqvKkFyqnQjL4abL124zCXPsYE2uRoGZxtFXAGtdReJSLAaoNPjo2RFE2Nk5nctZweXu2mrdVpjNifqGS8cyBS4onXe98kPUvsFEioNabf4YrtLcHN8ceWmiRJ8bj47FgAS75avJCgu129ZW7p6hgvEPvGjigcNUxKMo3UckDHBWtxQTKU8rxsHMt3hSnh9rJgVCMFEztVHKpW6T5XgZ79N6BgueCXYd68rbmRhacsar3mRXyaxgcks428JADDCGJbZRwbp8UeHhoRGuWQKyQyRPxzhs5y5bbHk8U9qBg1yMJRazmsiFeC7P3gM6we4Vjk84qMJJpwCQsQXJysPfDpV1YLunq3Qq6BMnzX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RF5SixppgiAa5guBP7CNbvjPnTAPzeoCqgHR7dxXPWP7L8GYoouH3oiHBcrtaeBYDpzZAkTcMGTHsm7sD2iD8hSf6vDmyS1QPnPuBEKEbR1c27e5MvNx83iNUa1pWWnbtFCRmuHVrG6kHYo8bFKZ7R1J94CVzTtkoiuWPiTXbFyeUzDPVrU1eSpHEHGFU5nHt1XcQqXUC2zEQZYU6r9PR5RjdtnkRL5xtjbpAfpMtnTj3AbByfGQNuV9pVZ2DYzEqcSNVVY3Gr7QSTHryrMdWfhmxUkvuwvQTane5443Tb7WFQ9XzCGGoECTH7Jj5VTP8hoeDnJk9HUZ6ZsEGYCiKuFXnYe5DMxtJZjYir",
"-entity", "did:ma:k51qzi5uqu5dmd4sku82zehgj2fklfj05huo0ra3l9ntel7rd4blewdk74vyx4#home"
],
"console": "integratedTerminal"
Expand Down
8 changes: 4 additions & 4 deletions actor/actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type Actor struct {
// Creates a new actor from an entity.
// Takes an entity and a forcePublish flag.
// The forcePublish is to override existing keys in IPFS.
func New(e *entity.Entity, forcePublish bool) (*Actor, error) {
func New(e *entity.Entity) (*Actor, error) {

var err error

Expand All @@ -60,7 +60,7 @@ func New(e *entity.Entity, forcePublish bool) (*Actor, error) {
a.Messages = make(chan *msg.Message, MESSAGES_BUFFERSIZE)

// Publish the entity
_, err = a.Entity.Doc.Publish()
_, err = a.Entity.Doc.Publish(nil)
if err != nil {
return nil, fmt.Errorf("actor.New: Failed to publish Entity: %w", err)
}
Expand All @@ -73,7 +73,7 @@ func New(e *entity.Entity, forcePublish bool) (*Actor, error) {
// Creates a new actor from a keyset.
// Takes a context, a keyset and a forcePublish flag.
// If ctx is nil a background context is used.
func NewFromKeyset(k *set.Keyset, forcePublish bool) (*Actor, error) {
func NewFromKeyset(k *set.Keyset, publish bool) (*Actor, error) {

log.Debugf("Setting Actor Entity: %v", k)
e, err := entity.NewFromKeyset(k)
Expand All @@ -85,7 +85,7 @@ func NewFromKeyset(k *set.Keyset, forcePublish bool) (*Actor, error) {
return nil, fmt.Errorf("actor.NewFromKeyset: Failed to create Entity: %w", err)
}

a, err := New(e, forcePublish)
a, err := New(e)
if err != nil {
return nil, fmt.Errorf("actor.NewFromKeyset: Failed to create Actor: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion actor/envelopes.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (a *Actor) receiveEnvelopes() (*msg.Message, error) {
return nil, fmt.Errorf("failed to receive message from inbox: %w", err)
}

message, err := msg.OpenEnvelope(e, a.Entity.Keyset.EncryptionKey.PrivKey[:])
message, err := e.Open(a.Entity.Keyset.EncryptionKey.PrivKey[:])
if err != nil {
return nil, fmt.Errorf("failed to open envelope: %w", err)
}
Expand Down
13 changes: 8 additions & 5 deletions config/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@ import (
const (

// Environment variable names
GO_MA_ACTOR_ENTITY_VAR = "GO_MA_ACTOR_ENTITY" // Target to connect to

GO_MA_ACTOR_IDENTITY_VAR = "GO_MA_ACTOR_IDENTITY" // Identity of the actor
GO_MA_ACTOR_NODE_IDENTITY_VAR = "GO_MA_ACTOR_NODE_IDENTITY" // Identity of the node

GO_MA_ACTOR_CONNMGR_GRACE_VAR = "GO_MA_ACTOR_CONNMGR_GRACE"
GO_MA_ACTOR_DESIRED_PEERS_VAR = "GO_MA_ACTOR_DESIRED_PEERS"
GO_MA_ACTOR_DISCOVERY_RETRY_INTERVAL_VAR = "GO_MA_ACTOR_DISCOVERY_RETRY"
GO_MA_ACTOR_DISCOVERY_TIMEOUT_VAR = "GO_MA_ACTOR_DISCOVERY_TIMEOUT"
GO_MA_ACTOR_ENTITY_VAR = "GO_MA_ACTOR_ENTITY"
GO_MA_ACTOR_HIGH_WATERMARK_VAR = "GO_MA_ACTOR_HIGH_WATERMARK"
GO_MA_ACTOR_IDENTITY_VAR = "GO_MA_ACTOR_IDENTITY"
GO_MA_ACTOR_LOGFILE_VAR = "GOLOG_FILE"
GO_MA_ACTOR_LOGLEVEL_VAR = "GOLOG_LOG_LEVEL"
GO_MA_ACTOR_LOW_WATERMARK_VAR = "GO_MA_ACTOR_LOW_WATERMARK"
GO_MA_ACTOR_NODE_IDENTITY_VAR = "GO_MA_ACTOR_NODE_IDENTITY"

GO_MA_ACTOR_LOGFILE_VAR = "GOLOG_FILE" // Use same variables as go-log
GO_MA_ACTOR_LOGLEVEL_VAR = "GOLOG_LOG_LEVEL" // Use same variables as go-log
)

var genenv = flag.Bool("genenv", false, "Generates and prints environment to stdout")
Expand Down
4 changes: 1 addition & 3 deletions config/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ var (

func InitIdentity() {

keyset = GetKeyset()

var err error

// Generate a new keysets if requested
Expand Down Expand Up @@ -99,7 +97,7 @@ func publishIdentity(k *set.Keyset) {
}
d.Sign(k.SigningKey, assertionMethod)

_, err = d.Publish()
_, err = d.Publish(nil)
if err != nil {
log.Errorf("config.publishIdentity: failed to publish DOC: %v", err)
os.Exit(75) // EX_TEMPFAIL
Expand Down
2 changes: 1 addition & 1 deletion entity/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func New(id string, alias string) (*Entity, error) {
Alias: alias,
}

e.Doc, err = doc.FetchFromDID(e.DID)
e.Doc, err = doc.GetOrFetch(id)
if err != nil {
return nil, fmt.Errorf("entity/newfromdid: failed to fetch document: %w", err)
}
Expand Down
37 changes: 18 additions & 19 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/bahner/go-ma-actor
go 1.21

require (
github.com/bahner/go-ma v0.0.7
github.com/bahner/go-ma v0.2.1
github.com/c-bata/go-prompt v0.2.6
github.com/gdamore/tcell/v2 v2.7.0
github.com/libp2p/go-libp2p v0.32.2
Expand Down Expand Up @@ -33,23 +33,22 @@ require (
github.com/francoispqt/gojay v1.2.13 // indirect
github.com/fxamacker/cbor/v2 v2.5.0 // indirect
github.com/gdamore/encoding v1.0.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gopacket v1.1.19 // indirect
github.com/google/pprof v0.0.0-20231023181126-ff6d637d2a7b // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/huin/goupnp v1.3.0 // indirect
github.com/ipfs/bbloom v0.0.4 // indirect
github.com/ipfs/boxo v0.15.1-0.20231129112844-08959f281f86 // indirect
github.com/ipfs/boxo v0.16.0 // indirect
github.com/ipfs/go-block-format v0.2.0 // indirect
github.com/ipfs/go-cid v0.4.1 // indirect
github.com/ipfs/go-datastore v0.6.0 // indirect
Expand All @@ -63,15 +62,15 @@ require (
github.com/ipfs/go-log v1.0.5 // indirect
github.com/ipfs/go-log/v2 v2.5.1 // indirect
github.com/ipfs/go-metrics-interface v0.0.1 // indirect
github.com/ipfs/kubo v0.24.1-0.20231129114216-2864f63d9db2 // indirect
github.com/ipfs/kubo v0.25.0 // indirect
github.com/ipld/go-codec-dagpb v1.6.0 // indirect
github.com/ipld/go-ipld-prime v0.21.0 // indirect
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect
github.com/jbenet/goprocess v0.1.4 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.2 // indirect
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
github.com/koron/go-ssdp v0.0.4 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/libp2p/go-cidranger v1.1.0 // indirect
Expand All @@ -93,8 +92,8 @@ require (
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mattn/go-tty v0.0.3 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/miekg/dns v1.1.56 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/miekg/dns v1.1.57 // indirect
github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b // indirect
github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc // indirect
github.com/minio/sha256-simd v1.0.1 // indirect
Expand All @@ -120,7 +119,7 @@ require (
github.com/polydawn/refmt v0.89.0 // indirect
github.com/prometheus/client_golang v1.17.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/quic-go/qpack v0.4.0 // indirect
github.com/quic-go/qtls-go1-20 v0.3.4 // indirect
Expand All @@ -129,7 +128,7 @@ require (
github.com/raulk/go-watchdog v1.3.0 // indirect
github.com/rivo/uniseg v0.4.3 // indirect
github.com/rs/cors v1.7.0 // indirect
github.com/samber/lo v1.36.0 // indirect
github.com/samber/lo v1.39.0 // indirect
github.com/shopspring/decimal v1.2.0 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/whyrusleeping/base32 v0.0.0-20170828182744-c30ac30633cc // indirect
Expand All @@ -146,17 +145,17 @@ require (
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
go4.org v0.0.0-20230225012048-214862532bf5 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
golang.org/x/mod v0.13.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sync v0.4.0 // indirect
golang.org/x/crypto v0.16.0 // indirect
golang.org/x/exp v0.0.0-20231127185646-65229373498e // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.14.0 // indirect
golang.org/x/tools v0.16.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
gonum.org/v1/gonum v0.13.0 // indirect
gonum.org/v1/gonum v0.14.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
lukechampine.com/blake3 v1.2.1 // indirect
)
Loading

0 comments on commit aa401cf

Please sign in to comment.