コード例 #1
0
ファイル: crawler.go プロジェクト: AaronGoldman/ccfs
// This function seeds the queue from a web request
func seedQueue(hkidhex string) (err error) {
	h, hexerr := objects.HcidFromHex(hkidhex)
	if hexerr == nil {
		err = crawlList(objects.HCID(h.Bytes()))
		if err != nil {
			log.Println("seed was not a List")
		}
		err = crawlBlob(objects.HCID(h.Bytes()))
		if err != nil {
			log.Println("seed was not a Blob")
		}
		err = crawlCommit(objects.HKID(h.Bytes()))
		if err != nil {
			log.Println("seed was not a Commit")
		}
		err = crawlhcidCommit(objects.HCID(h.Bytes()))
		if err != nil {
			log.Println("seed was not a Commit's hcid")
		}
		err = crawlhcidTag(objects.HCID(h.Bytes()))
		if err != nil {
			log.Println("seed was not a Tag's hcid")
		}
	} else {
		log.Println(hexerr)
	}
	return hexerr
}
コード例 #2
0
ファイル: get.go プロジェクト: AaronGoldman/ccfs
//GetPublicKeyForHkid uses the lookup services to get a public key for an hkid
func GetPublicKeyForHkid(hkid objects.HKID) objects.PublicKey {
	marshaledKey, err := GetBlob(objects.HCID(hkid))
	if err != nil {
		return objects.PublicKey{}
	}
	curve := elliptic.P521()
	x, y := elliptic.Unmarshal(elliptic.P521(), marshaledKey)
	pubKey := ecdsa.PublicKey{
		Curve: curve, //elliptic.Curve
		X:     x,     //X *big.Int
		Y:     y}     //Y *big.Int
	return objects.PublicKey(pubKey)
}
コード例 #3
0
ファイル: post.go プロジェクト: AaronGoldman/ccfs
func post(h objects.HID, path string, nextPathSegmentType string,
	postBytes objects.Byteser, postType string) (hid objects.HID, err error) {
	//log.Printf(
	//	"\n\th: %v\n\tpath: %v\n\tnext_path_segment_type: %v\n\tpost_bytes: %s\n\tpost_type: %v\n",
	//	h, path, next_path_segment_type, post_bytes, post_type)
	if path == "" {
		//log.Printf("post_type: %s", post_type)
		err := PostBlob(postBytes.(objects.Blob))
		return objects.HCID(postBytes.(objects.Blob).Hash()), err
	}

	nameSegments := strings.SplitN(path, "/", 2)
	nextPathSegment := nameSegments[0]
	restOfPath := ""
	if len(nameSegments) > 1 {
		restOfPath = nameSegments[1]
	}
	switch nextPathSegmentType {
	default:
		return nil, fmt.Errorf(fmt.Sprintf("Invalid type %T", nextPathSegmentType))
	case "blob":
		return nil, fmt.Errorf(fmt.Sprintf("only \"\" path can be blob"))
	case "list":
		postedListHash, err := listHelper(h, nextPathSegment, restOfPath,
			postBytes, postType)
		return postedListHash, err
	case "commit":
		postedCommitHash, err := commitHelper(h.Bytes(), path, postBytes,
			postType)
		return postedCommitHash, err
	case "tag":
		postedTagHash, err := tagHelper(h, nextPathSegment, restOfPath,
			postBytes, postType)
		return postedTagHash, err
	}
}