Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

gx update and fix code to use new Cid type #2

Merged
merged 2 commits into from
Sep 12, 2018
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .gx/lastpubver
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.6: QmPcR9Eft4i3XU5DXdnmNY8SWRuFnJms58NKjY1Hso8WiQ
0.1.0: QmVcoYLHSe31tE18fQznFzEPawkCh9JvWR7zckfwZh1nno
2 changes: 1 addition & 1 deletion mfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func setupRoot(ctx context.Context, t *testing.T) (ipld.DAGService, *Root) {
ds := getDagserv(t)

root := emptyDirNode()
rt, err := NewRoot(ctx, ds, root, func(ctx context.Context, c *cid.Cid) error {
rt, err := NewRoot(ctx, ds, root, func(ctx context.Context, c cid.Cid) error {
fmt.Println("PUBLISHED: ", c)
return nil
})
Expand Down
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,40 @@
"gxDependencies": [
{
"author": "why",
"hash": "QmNr4E8z9bGTztvHJktp7uQaMdx9p3r9Asrq6eYk7iCh4a",
"hash": "QmURqt1jB9Yu3X4Tr9WQJf36QGN7vi8mGTzjnX2ij1CJwC",
"name": "go-merkledag",
"version": "1.0.14"
"version": "1.1.0"
},
{
"author": "why",
"hash": "QmWAfTyD6KEBm7bzqNRBPvqKrZCDtn5PGbs9V1DKfnVK59",
"hash": "QmPXzQ9LAFGZjcifFANCQFQiYt5SXgJziGoxUfJULVpHyA",
"name": "go-unixfs",
"version": "1.0.16"
"version": "1.1.0"
},
{
"author": "whyrusleeping",
"hash": "QmZFbDTY9jfSBms2MchvYM9oYRbAF19K7Pby47yDBfpPrb",
"hash": "QmPSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7",
"name": "go-cid",
"version": "0.8.0"
"version": "0.9.0"
},
{
"author": "whyrusleeping",
"hash": "QmX5CsuHyVZeTLxgRSYkgLSDQKb9UjE8xnhQzCEJWWWFsC",
"hash": "QmdDXJs4axxefSPgK6Y1QhpJWKuDPnGJiqgq4uncb4rFHL",
"name": "go-ipld-format",
"version": "0.5.8"
"version": "0.6.0"
},
{
"author": "why",
"hash": "QmNgXoHgXU1HzNb2HEZmRww9fDKE9NfDsvQwWLHiKHpvKM",
"hash": "QmRYx6fJzTWFoeTo3qQn64iDrVC154Gy9waQDhvKRr2ND3",
"name": "go-path",
"version": "1.0.14"
"version": "1.1.0"
}
],
"gxVersion": "0.12.1",
"language": "go",
"license": "MIT",
"name": "go-mfs",
"releaseCmd": "git commit -a -m \"gx publish $VERSION\"",
"version": "0.0.6"
"version": "0.1.0"
}

6 changes: 3 additions & 3 deletions repub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestRepublisher(t *testing.T) {

pub := make(chan struct{})

pf := func(ctx context.Context, c *cid.Cid) error {
pf := func(ctx context.Context, c cid.Cid) error {
pub <- struct{}{}
return nil
}
Expand All @@ -29,7 +29,7 @@ func TestRepublisher(t *testing.T) {
rp := NewRepublisher(ctx, pf, tshort, tlong)
go rp.Run()

rp.Update(nil)
rp.Update(cid.Undef)

// should hit short timeout
select {
Expand All @@ -42,7 +42,7 @@ func TestRepublisher(t *testing.T) {

go func() {
for {
rp.Update(nil)
rp.Update(cid.Undef)
time.Sleep(time.Millisecond * 10)
select {
case <-cctx.Done():
Expand Down
10 changes: 5 additions & 5 deletions system.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ type Root struct {
}

// PubFunc is the function used by the `publish()` method.
type PubFunc func(context.Context, *cid.Cid) error
type PubFunc func(context.Context, cid.Cid) error

// NewRoot creates a new Root and starts up a republisher routine for it.
func NewRoot(parent context.Context, ds ipld.DAGService, node *dag.ProtoNode, pf PubFunc) (*Root, error) {
Expand Down Expand Up @@ -182,8 +182,8 @@ type Republisher struct {
cancel func()

lk sync.Mutex
val *cid.Cid
lastpub *cid.Cid
val cid.Cid
lastpub cid.Cid
}

// NewRepublisher creates a new Republisher object to republish the given root
Expand All @@ -201,7 +201,7 @@ func NewRepublisher(ctx context.Context, pf PubFunc, tshort, tlong time.Duration
}
}

func (p *Republisher) setVal(c *cid.Cid) {
func (p *Republisher) setVal(c cid.Cid) {
p.lk.Lock()
defer p.lk.Unlock()
p.val = c
Expand Down Expand Up @@ -231,7 +231,7 @@ func (p *Republisher) Close() error {
// Touch signals that an update has occurred since the last publish.
// Multiple consecutive touches may extend the time period before
// the next Publish occurs in order to more efficiently batch updates.
func (np *Republisher) Update(c *cid.Cid) {
func (np *Republisher) Update(c cid.Cid) {
np.setVal(c)
select {
case np.Publish <- struct{}{}:
Expand Down