multiaddr.gno
0.87 Kb ยท 41 lines
1package social_feed
2
3import (
4 ma "gno.land/p/zenao/multiaddr"
5)
6
7var (
8 Protocols = ma.NewProtocolRegistry()
9 generalTranscoder = ma.NewTranscoderFromFunctions(generalStB, generalBtS, nil)
10)
11
12var SocialFeedProtocols []*ma.Protocol = []*ma.Protocol{
13 {
14 Name: "gno",
15 Code: 0x300,
16 VCode: ma.CodeToVarint(0x300),
17 Path: true, // XXX: use URL encoding to avoid to have to put it at the end
18 Size: ma.LengthPrefixedVarSize,
19 Transcoder: generalTranscoder,
20 }, {
21 Name: "poll",
22 Code: 0x301,
23 VCode: ma.CodeToVarint(0x301),
24 Size: ma.LengthPrefixedVarSize,
25 Transcoder: generalTranscoder,
26 },
27}
28
29func init() {
30 for _, p := range SocialFeedProtocols {
31 Protocols.AddProtocol(*p)
32 }
33}
34
35func generalStB(s string) ([]byte, error) {
36 return []byte(s), nil
37}
38
39func generalBtS(b []byte) (string, error) {
40 return string(b), nil
41}