this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

remove unused dbcid code

-64
-64
cmd/rerelay/relay/models/dbcid.go
··· 1 - package models 2 - 3 - import ( 4 - "database/sql/driver" 5 - "encoding/json" 6 - "fmt" 7 - 8 - "github.com/ipfs/go-cid" 9 - ) 10 - 11 - type Uid uint64 12 - 13 - type DbCID struct { 14 - CID cid.Cid 15 - } 16 - 17 - func (dbc *DbCID) Scan(v interface{}) error { 18 - b, ok := v.([]byte) 19 - if !ok { 20 - return fmt.Errorf("dbcids must get bytes!") 21 - } 22 - 23 - if len(b) == 0 { 24 - return nil 25 - } 26 - 27 - c, err := cid.Cast(b) 28 - if err != nil { 29 - return err 30 - } 31 - 32 - dbc.CID = c 33 - return nil 34 - } 35 - 36 - func (dbc DbCID) Value() (driver.Value, error) { 37 - if !dbc.CID.Defined() { 38 - return nil, fmt.Errorf("cannot serialize undefined cid to database") 39 - } 40 - return dbc.CID.Bytes(), nil 41 - } 42 - 43 - func (dbc DbCID) MarshalJSON() ([]byte, error) { 44 - return json.Marshal(dbc.CID.String()) 45 - } 46 - 47 - func (dbc *DbCID) UnmarshalJSON(b []byte) error { 48 - var s string 49 - if err := json.Unmarshal(b, &s); err != nil { 50 - return err 51 - } 52 - 53 - c, err := cid.Decode(s) 54 - if err != nil { 55 - return err 56 - } 57 - 58 - dbc.CID = c 59 - return nil 60 - } 61 - 62 - func (dbc *DbCID) GormDataType() string { 63 - return "bytes" 64 - }