MCPcopy Create free account
hub / github.com/DNAProject/DNA / loadTransaction

Method loadTransaction

core/store/ledgerstore/block_store.go:382–410  ·  view source on GitHub ↗
(txHash common.Uint256)

Source from the content-addressed store, hash-verified

380}
381
382func (this *BlockStore) loadTransaction(txHash common.Uint256) (*types.Transaction, uint32, error) {
383 key := this.getTransactionKey(txHash)
384
385 var tx *types.Transaction
386 var height uint32
387 if this.enableCache {
388 tx, height = this.cache.GetTransaction(txHash)
389 if tx != nil {
390 return tx, height, nil
391 }
392 }
393
394 value, err := this.store.Get(key)
395 if err != nil {
396 return nil, 0, err
397 }
398 source := common.NewZeroCopySource(value)
399 var eof bool
400 height, eof = source.NextUint32()
401 if eof {
402 return nil, 0, io.ErrUnexpectedEOF
403 }
404 tx = new(types.Transaction)
405 err = tx.Deserialization(source)
406 if err != nil {
407 return nil, 0, fmt.Errorf("transaction deserialize error %s", err)
408 }
409 return tx, height, nil
410}
411
412//IsContainTransaction return whether the transaction is in store
413func (this *BlockStore) ContainTransaction(txHash common.Uint256) (bool, error) {

Callers 1

GetTransactionMethod · 0.95

Calls 6

getTransactionKeyMethod · 0.95
NextUint32Method · 0.95
DeserializationMethod · 0.95
ErrorfMethod · 0.80
GetTransactionMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected