Skip to content

Commit

Permalink
Revert "Remove commented out code (#238)"
Browse files Browse the repository at this point in the history
This reverts commit 07a71a4.
  • Loading branch information
jsimnz committed Mar 1, 2022
1 parent 07a71a4 commit 3ed41d8
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions core/crdt/composite.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ func (c CompositeDAG) DeltaDecode(node ipld.Node) (core.Delta, error) {
return nil, errors.New("Failed to cast ipld.Node to ProtoNode")
}
data := pbNode.Data()
// fmt.Println(data)
h := &codec.CborHandle{}
dec := codec.NewDecoderBytes(data, h)
err := dec.Decode(delta)
Expand Down
1 change: 1 addition & 0 deletions core/crdt/lwwreg.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ func (reg LWWRegister) DeltaDecode(node ipld.Node) (core.Delta, error) {
return nil, errors.New("Failed to cast ipld.Node to ProtoNode")
}
data := pbNode.Data()
// fmt.Println(data)
h := &codec.CborHandle{}
dec := codec.NewDecoderBytes(data, h)
err := dec.Decode(delta)
Expand Down
8 changes: 6 additions & 2 deletions core/crdt/lwwreg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ func TestLWWRegisterDeltaMarshal(t *testing.T) {
return
}

// fmt.Println(bytes)

h := &codec.CborHandle{}
dec := codec.NewDecoderBytes(bytes, h)
unmarshaledDelta := &LWWRegDelta{}
Expand Down Expand Up @@ -185,7 +187,8 @@ func makeNode(delta core.Delta, heads []cid.Cid) (ipld.Node, error) {
return nil, err
}
}

// data = []byte("test")
// fmt.Println("PRE", data)
nd := dag.NodeWithData(data)
// The cid builder defaults to v0, we want to be using v1 CIDs
nd.SetCidBuilder(
Expand All @@ -201,7 +204,8 @@ func makeNode(delta core.Delta, heads []cid.Cid) (ipld.Node, error) {
return nil, err
}
}

// data2 := nd.Data()
// fmt.Println("POST", data2)
return nd, nil
}

Expand Down
1 change: 1 addition & 0 deletions core/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func (k Key) PrefixEnd() Key {
// An error is returned if it can't correct convert the
// field to a uint32.
func (k Key) FieldID() (uint32, error) {
// fmt.Println(k.String())
fieldIDStr := k.Type()
fieldID, err := strconv.Atoi(fieldIDStr)
if err != nil {
Expand Down
4 changes: 3 additions & 1 deletion document/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ func NewFromMap(data map[string]interface{}, schema ...base.SchemaDescription) (
if err != nil {
return nil, err
}
// fmt.Println(c)
doc.key = key.NewDocKeyV0(c)
}

Expand Down Expand Up @@ -229,7 +230,8 @@ func (doc *Document) SetWithJSON(patch []byte) error {
}

for k, v := range patchObj {
if v == nil {
fmt.Println(k, v)
if v == nil { // needs deletion
err = doc.Delete(k)
} else {
err = doc.Set(k, v)
Expand Down

0 comments on commit 3ed41d8

Please sign in to comment.