support 128 bit NeedleId

This commit is contained in:
Chris Lu
2018-07-31 23:25:26 -07:00
parent 44d8e35988
commit 495a776671
4 changed files with 53 additions and 6 deletions

View File

@@ -166,19 +166,19 @@ func (n *Needle) ParsePath(fid string) (err error) {
func ParseNeedleIdCookie(key_hash_string string) (NeedleId, Cookie, error) {
if len(key_hash_string) <= CookieSize*2 {
return 0, 0, fmt.Errorf("KeyHash is too short.")
return NeedleIdEmpty, 0, fmt.Errorf("KeyHash is too short.")
}
if len(key_hash_string) > (NeedleIdSize+CookieSize)*2 {
return 0, 0, fmt.Errorf("KeyHash is too long.")
return NeedleIdEmpty, 0, fmt.Errorf("KeyHash is too long.")
}
split := len(key_hash_string) - CookieSize*2
needleId, err := ParseNeedleId(key_hash_string[:split])
if err != nil {
return 0, 0, fmt.Errorf("Parse needleId error: %v", err)
return NeedleIdEmpty, 0, fmt.Errorf("Parse needleId error: %v", err)
}
cookie, err := ParseCookie(key_hash_string[split:])
if err != nil {
return 0, 0, fmt.Errorf("Parse cookie error: %v", err)
return NeedleIdEmpty, 0, fmt.Errorf("Parse cookie error: %v", err)
}
return needleId, cookie, nil
}