当前位置: 首页>>代码示例>>Golang>>正文


Golang Stream.Decode方法代码示例

本文整理汇总了Golang中github.com/ethereum/go-ethereum/rlp.Stream.Decode方法的典型用法代码示例。如果您正苦于以下问题:Golang Stream.Decode方法的具体用法?Golang Stream.Decode怎么用?Golang Stream.Decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/ethereum/go-ethereum/rlp.Stream的用法示例。


在下文中一共展示了Stream.Decode方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: DecodeRLP

func (self *Block) DecodeRLP(s *rlp.Stream) error {
	var eb extblock
	if err := s.Decode(&eb); err != nil {
		return err
	}
	self.header, self.uncles, self.transactions = eb.Header, eb.Uncles, eb.Txs
	return nil
}
开发者ID:CedarLogic,项目名称:go-ethereum,代码行数:8,代码来源:block.go

示例2: DecodeRLP

func (tx *Transaction) DecodeRLP(s *rlp.Stream) error {
	_, size, _ := s.Kind()
	err := s.Decode(&tx.data)
	if err == nil {
		tx.size.Store(common.StorageSize(rlp.ListSize(size)))
	}
	return err
}
开发者ID:nellyk,项目名称:go-ethereum,代码行数:8,代码来源:transaction.go

示例3: DecodeRLP

func (self *Value) DecodeRLP(s *rlp.Stream) error {
	var v interface{}
	if err := s.Decode(&v); err != nil {
		return err
	}
	self.Val = v
	return nil
}
开发者ID:j4ustin,项目名称:go-ethereum,代码行数:8,代码来源:value.go

示例4: DecodeRLP

func (b *Block) DecodeRLP(s *rlp.Stream) error {
	var eb extblock
	_, size, _ := s.Kind()
	if err := s.Decode(&eb); err != nil {
		return err
	}
	b.header, b.uncles, b.transactions = eb.Header, eb.Uncles, eb.Txs
	b.size.Store(common.StorageSize(rlp.ListSize(size)))
	return nil
}
开发者ID:NikonMcFly,项目名称:go-ethereum,代码行数:10,代码来源:block.go

示例5: DecodeRLP

func (l *Log) DecodeRLP(s *rlp.Stream) error {
	var log struct {
		Address common.Address
		Topics  []common.Hash
		Data    []byte
	}
	if err := s.Decode(&log); err != nil {
		return err
	}
	l.Address, l.Topics, l.Data = log.Address, log.Topics, log.Data
	return nil
}
开发者ID:j4ustin,项目名称:go-ethereum,代码行数:12,代码来源:log.go

示例6: DecodeRLP

// DecodeRLP implements rlp.Decoder, and loads the consensus fields of a receipt
// from an RLP stream.
func (r *Receipt) DecodeRLP(s *rlp.Stream) error {
	var receipt struct {
		PostState         []byte
		CumulativeGasUsed *big.Int
		Bloom             Bloom
		Logs              vm.Logs
	}
	if err := s.Decode(&receipt); err != nil {
		return err
	}
	r.PostState, r.CumulativeGasUsed, r.Bloom, r.Logs = receipt.PostState, receipt.CumulativeGasUsed, receipt.Bloom, receipt.Logs
	return nil
}
开发者ID:j4ustin,项目名称:go-ethereum,代码行数:15,代码来源:receipt.go

示例7: DecodeRLP

func (self *Receipt) DecodeRLP(s *rlp.Stream) error {
	var r struct {
		PostState         []byte
		CumulativeGasUsed *big.Int
		Bloom             Bloom
		Logs              state.Logs
	}
	if err := s.Decode(&r); err != nil {
		return err
	}
	self.PostState, self.CumulativeGasUsed, self.Bloom, self.logs = r.PostState, r.CumulativeGasUsed, r.Bloom, r.Logs

	return nil
}
开发者ID:ssonneborn22,项目名称:go-ethereum,代码行数:14,代码来源:receipt.go

示例8: DecodeRLP

func (self *Receipt) DecodeRLP(s *rlp.Stream) error {
	var r struct {
		PostState         []byte
		CumulativeGasUsed *big.Int
		Bloom             Bloom
		TxHash            common.Hash
		ContractAddress   common.Address
		Logs              state.Logs
		GasUsed           *big.Int
	}
	if err := s.Decode(&r); err != nil {
		return err
	}
	self.PostState, self.CumulativeGasUsed, self.Bloom, self.TxHash, self.ContractAddress, self.logs, self.GasUsed = r.PostState, r.CumulativeGasUsed, r.Bloom, r.TxHash, r.ContractAddress, r.Logs, r.GasUsed

	return nil
}
开发者ID:nellyk,项目名称:go-ethereum,代码行数:17,代码来源:receipt.go

示例9: checkDecodeFromJSON

// checkDecodeFromJSON decodes from s guided by exp. exp drives the
// Stream by invoking decoding operations (Uint, Big, List, ...) based
// on the type of each value. The value decoded from the RLP stream
// must match the JSON value.
func checkDecodeFromJSON(s *rlp.Stream, exp interface{}) error {
	switch exp := exp.(type) {
	case uint64:
		i, err := s.Uint()
		if err != nil {
			return addStack("Uint", exp, err)
		}
		if i != exp {
			return addStack("Uint", exp, fmt.Errorf("result mismatch: got %d", i))
		}
	case *big.Int:
		big := new(big.Int)
		if err := s.Decode(&big); err != nil {
			return addStack("Big", exp, err)
		}
		if big.Cmp(exp) != 0 {
			return addStack("Big", exp, fmt.Errorf("result mismatch: got %d", big))
		}
	case []byte:
		b, err := s.Bytes()
		if err != nil {
			return addStack("Bytes", exp, err)
		}
		if !bytes.Equal(b, exp) {
			return addStack("Bytes", exp, fmt.Errorf("result mismatch: got %x", b))
		}
	case []interface{}:
		if _, err := s.List(); err != nil {
			return addStack("List", exp, err)
		}
		for i, v := range exp {
			if err := checkDecodeFromJSON(s, v); err != nil {
				return addStack(fmt.Sprintf("[%d]", i), exp, err)
			}
		}
		if err := s.ListEnd(); err != nil {
			return addStack("ListEnd", exp, err)
		}
	default:
		panic(fmt.Errorf("unhandled type: %T", exp))
	}
	return nil
}
开发者ID:Codzart,项目名称:go-ethereum,代码行数:47,代码来源:rlp_test_util.go


注:本文中的github.com/ethereum/go-ethereum/rlp.Stream.Decode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。