func NewFromString(s string) (*ProofOfWork, error) {
	parts := strings.SplitN(s, "$", 3)
	if len(parts) != 3 {
		return nil, errIncorrectFormat
	}

	bits, err := strconv.Atoi(parts[0])
	if err != nil {
		return nil, err
	}

	data, err := base64.StdEncoding.DecodeString(parts[1])
	if err != nil {
		return nil, err
	}

	proof, err := strconv.Atoi(parts[2])
	if err != nil {
		return nil, err
	}

	return &ProofOfWork{
		Bits:  bits,
		Data:  string(data),
		Proof: uint64(proof),
	}, nil
}
// NewFromString generates a proof-of-work based on the given string
NewFromString generates a proof-of-work based on the given string
// NewFromString generates a proof - of - work based on the given string
func NewFromString(s string) (*ProofOfWork, error) {
	parts := strings.SplitN(s, "$", 3)
	if len(parts) != 3 {
		return nil, errIncorrectFormat
	}
	bits, err := strconv.Atoi(parts[0])
	if err != nil {
		return nil, err
	}
	data, err := base64.StdEncoding.DecodeString(parts[1])
	if err != nil {
		return nil, err
	}
	proof, err := strconv.Atoi(parts[2])
	if err != nil {
		return nil, err
	}
	return &ProofOfWork{
		Bits:  bits,
		Data:  string(data),
		Proof: uint64(proof),
	}, nil
}
func NewFromString ( s string ) ( * ProofOfWork , error ) { parts := strings . SplitN ( s , " " , 3 ) if len ( parts ) != 3 { return nil , errIncorrectFormat } bits , err := strconv . Atoi ( parts [ 0 ] ) if err != nil { return nil , err } data , err := base64 . StdEncoding . DecodeString ( parts [ 1 ] ) if err != nil { return nil , err } proof , err := strconv . Atoi ( parts [ 2 ] ) if err != nil { return nil , err } return & ProofOfWork { Bits : bits , Data : string ( data ) , Proof : uint64 ( proof ) , } , nil }
NewFromString generates a proof-of-work based on the given string
NewFromString generates a proof - of - work based on the given string