當前位置: 首頁>>代碼示例>>Golang>>正文


Golang primitives.EncodeJSONString函數代碼示例

本文整理匯總了Golang中github.com/FactomProject/factomd/common/primitives.EncodeJSONString函數的典型用法代碼示例。如果您正苦於以下問題:Golang EncodeJSONString函數的具體用法?Golang EncodeJSONString怎麽用?Golang EncodeJSONString使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了EncodeJSONString函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TopupFAddress

func TopupFAddress() {
	const fBalanceThreshold uint64 = 20000000 //0.2

	fBalance, err := factom.GetFactoidBalance(FaucetAddress)
	if err != nil {
		panic(err)
	}
	if fBalance < int64(fBalanceThreshold) {
		panic(fmt.Sprintf("Balance is too low - %v vs %v", fBalance/100000000.0, fBalanceThreshold/100000000.0))
	}

	tx, err := factom.SendFactoid(FaucetAddress, FAddressStr, fBalanceThreshold)
	if err != nil {
		panic(err)
	}

	fmt.Printf("F Topup tx - %v\n", tx)

	for i := 0; ; i++ {
		i = i % 3
		time.Sleep(5 * time.Second)
		ack, err := factom.FactoidACK(tx, "")
		if err != nil {
			panic(err)
		}

		str, err := primitives.EncodeJSONString(ack)
		if err != nil {
			panic(err)
		}
		fmt.Printf("Topup ack - %v", str)
		for j := 0; j < i+1; j++ {
			fmt.Printf(".")
		}
		fmt.Printf("  \r")

		if ack.Status != "DBlockConfirmed" {
			continue
		}

		fmt.Printf("Topup ack - %v\n", str)

		break
	}

	fBalance, _, err = CheckFactomBalance()
	if err != nil {
		panic(err)
	}
	if uint64(fBalance) < fBalanceThreshold {
		panic("Balance was not increased!")
	}

}
開發者ID:FactomProject,項目名稱:factomd,代碼行數:54,代碼來源:longTests.go

示例2: TopupECAddress

func TopupECAddress() {
	//fmt.Printf("TopupECAddress - %v, %v\n", FAddressStr, ECAddressStr)
	const ecBalanceThreshold uint64 = 10

	tx, err := factom.BuyExactEC(FAddressStr, ECAddressStr, uint64(ecBalanceThreshold))
	//tx, err := factom.BuyExactEC(FaucetAddress, ECAddressStr, uint64(ecBalanceThreshold))
	if err != nil {
		panic(err)
	}

	fmt.Printf("EC Topup tx - %v\n", tx)

	for i := 0; ; i++ {
		i = i % 3
		time.Sleep(5 * time.Second)
		ack, err := factom.FactoidACK(tx, "")
		if err != nil {
			panic(err)
		}

		str, err := primitives.EncodeJSONString(ack)
		if err != nil {
			panic(err)
		}
		fmt.Printf("Topup ack - %v", str)
		for j := 0; j < i+1; j++ {
			fmt.Printf(".")
		}
		fmt.Printf("  \r")

		if ack.Status != "DBlockConfirmed" {
			continue
		}

		fmt.Printf("Topup ack - %v\n", str)

		break
	}

	_, ecBalance, err := CheckFactomBalance()
	if err != nil {
		panic(err)
	}
	if uint64(ecBalance) < ecBalanceThreshold {
		panic("Balance was not increased!")
	}
}
開發者ID:FactomProject,項目名稱:factomd,代碼行數:47,代碼來源:longTests.go

示例3: JSONString

func (e *IncreaseServerCount) JSONString() (string, error) {
	return primitives.EncodeJSONString(e)
}
開發者ID:FactomProject,項目名稱:factomd,代碼行數:3,代碼來源:EntryIncreaseServerCount.go

示例4: JSONString

func (e *ECBlockBody) JSONString() (string, error) {
	return primitives.EncodeJSONString(e)
}
開發者ID:jjdevbiz,項目名稱:factomd,代碼行數:3,代碼來源:ecblockBody.go

示例5: JSONString

func (e *DirectoryBlock) JSONString() (string, error) {
	return primitives.EncodeJSONString(e)
}
開發者ID:FactomProject,項目名稱:factomd,代碼行數:3,代碼來源:directoryBlock.go

示例6: JSONString

func (e *EBlockHeader) JSONString() (string, error) {
	return primitives.EncodeJSONString(e)
}
開發者ID:jjdevbiz,項目名稱:factomd,代碼行數:3,代碼來源:eblockHeader.go

示例7: JSONString

func (e *ServerFault) JSONString() (string, error) {
	return primitives.EncodeJSONString(e)
}
開發者ID:FactomProject,項目名稱:factomd,代碼行數:3,代碼來源:EntryServerFault.go

示例8: JSONString

func (e *MsgAck) JSONString() (string, error) {
	return primitives.EncodeJSONString(e)
}
開發者ID:jjdevbiz,項目名稱:factomd,代碼行數:3,代碼來源:msgack.go

示例9: JSONString

func (e *DataResponse) JSONString() (string, error) {
	return primitives.EncodeJSONString(e)
}
開發者ID:FactomProject,項目名稱:factomd,代碼行數:3,代碼來源:dataResponse.go

示例10: JSONString

func (e *AddServerMsg) JSONString() (string, error) {
	return primitives.EncodeJSONString(e)
}
開發者ID:FactomProject,項目名稱:factomd,代碼行數:3,代碼來源:addServer.go

示例11: JSONString

func (e *RequestBlock) JSONString() (string, error) {
	return primitives.EncodeJSONString(e)
}
開發者ID:FactomProject,項目名稱:factomd,代碼行數:3,代碼來源:requestBlock.go

示例12: JSONString

func (e *DBStateMissing) JSONString() (string, error) {
	return primitives.EncodeJSONString(e)
}
開發者ID:FactomProject,項目名稱:factomd,代碼行數:3,代碼來源:dbstateMissing.go

示例13: JSONString

func (e *MsgGetEntryData) JSONString() (string, error) {
	return primitives.EncodeJSONString(e)
}
開發者ID:jjdevbiz,項目名稱:factomd,代碼行數:3,代碼來源:msggetentrydata.go

示例14: JSONString

func (e ByteStore) JSONString() (string, error) {
	return primitives.EncodeJSONString(e)
}
開發者ID:jjdevbiz,項目名稱:factomd,代碼行數:3,代碼來源:bytestore.go

示例15: JSONString

func (s *FactoidSignature) JSONString() (string, error) {
	return primitives.EncodeJSONString(s)
}
開發者ID:FactomProject,項目名稱:factomd,代碼行數:3,代碼來源:signature.go


注:本文中的github.com/FactomProject/factomd/common/primitives.EncodeJSONString函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。