(txHash common.Uint256)
| 380 | } |
| 381 | |
| 382 | func (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 |
| 413 | func (this *BlockStore) ContainTransaction(txHash common.Uint256) (bool, error) { |
no test coverage detected