We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c3ba4ac commit ef4135eCopy full SHA for ef4135e
whisper/util.go
@@ -0,0 +1,27 @@
1
+package whisper
2
+
3
+import "github.com/ethereum/go-ethereum/crypto"
4
5
+func hashTopic(topic []byte) []byte {
6
+ return crypto.Sha3(topic)[:4]
7
+}
8
9
+// NOTE this isn't DRY, but I don't want to iterate twice.
10
11
+// Returns a formatted topics byte slice.
12
+// data: unformatted data (e.g., no hashes needed)
13
+func Topics(data [][]byte) [][]byte {
14
+ d := make([][]byte, len(data))
15
+ for i, byts := range data {
16
+ d[i] = hashTopic(byts)
17
+ }
18
+ return d
19
20
21
+func TopicsFromString(data []string) [][]byte {
22
23
+ for i, str := range data {
24
+ d[i] = hashTopic([]byte(str))
25
26
27
0 commit comments