Skip to content

Commit 73743d6

Browse files
author
Alex
committed
options: add hash function selection for dagput
1 parent 740521c commit 73743d6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

options/dag.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ type DagPutSettings struct {
55
InputEnc string
66
Kind string
77
Pin string
8+
Hash string
89
}
910

1011
// DagPutOption is a single DagPut option.
@@ -16,6 +17,7 @@ func DagPutOptions(opts ...DagPutOption) (*DagPutSettings, error) {
1617
InputEnc: "json",
1718
Kind: "cbor",
1819
Pin: "false",
20+
Hash: "sha2-256",
1921
}
2022

2123
for _, opt := range opts {
@@ -57,3 +59,11 @@ func (dagOpts) Kind(kind string) DagPutOption {
5759
return nil
5860
}
5961
}
62+
63+
// Hash is an option for Dag.Put which specifies the hash function to use
64+
func (dagOpts) Hash(hash string) DagPutOption {
65+
return func(opts *DagPutSettings) error {
66+
opts.Hash = hash
67+
return nil
68+
}
69+
}

0 commit comments

Comments
 (0)