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


Golang Receipt.SetLogs方法代碼示例

本文整理匯總了Golang中github.com/ethereum/go-ethereum/core/types.Receipt.SetLogs方法的典型用法代碼示例。如果您正苦於以下問題:Golang Receipt.SetLogs方法的具體用法?Golang Receipt.SetLogs怎麽用?Golang Receipt.SetLogs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/ethereum/go-ethereum/core/types.Receipt的用法示例。


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

示例1: TestPutReceipt

func TestPutReceipt(t *testing.T) {
	db, _ := ethdb.NewMemDatabase()

	var addr common.Address
	addr[0] = 1
	var hash common.Hash
	hash[0] = 2

	receipt := new(types.Receipt)
	receipt.SetLogs(state.Logs{&state.Log{
		Address:   addr,
		Topics:    []common.Hash{hash},
		Data:      []byte("hi"),
		Number:    42,
		TxHash:    hash,
		TxIndex:   0,
		BlockHash: hash,
		Index:     0,
	}})

	putReceipts(db, hash, types.Receipts{receipt})
	receipts, err := getBlockReceipts(db, hash)
	if err != nil {
		t.Error("got err:", err)
	}
	if len(receipts) != 1 {
		t.Error("expected to get 1 receipt, got", len(receipts))
	}
}
開發者ID:haegyung,項目名稱:go-ethereum,代碼行數:29,代碼來源:block_processor_test.go

示例2: TestPutReceipt

func TestPutReceipt(t *testing.T) {
	db, _ := ethdb.NewMemDatabase()

	var addr common.Address
	addr[0] = 1
	var hash common.Hash
	hash[0] = 2

	receipt := new(types.Receipt)
	receipt.SetLogs(state.Logs{&state.Log{
		Address:   addr,
		Topics:    []common.Hash{hash},
		Data:      []byte("hi"),
		Number:    42,
		TxHash:    hash,
		TxIndex:   0,
		BlockHash: hash,
		Index:     0,
	}})

	PutReceipts(db, types.Receipts{receipt})
	receipt = GetReceipt(db, common.Hash{})
	if receipt == nil {
		t.Error("expected to get 1 receipt, got none.")
	}
}
開發者ID:ruflin,項目名稱:go-ethereum,代碼行數:26,代碼來源:block_processor_test.go


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