Skip to content

Commit

Permalink
Update LedgerContract.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
erikzhang committed Jan 21, 2021
1 parent abf0dc3 commit 41c5d9f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/neo/SmartContract/Native/LedgerContract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,28 +142,28 @@ public Header GetHeader(DataCache snapshot, uint index)
return GetHeader(snapshot, hash);
}

public Transaction GetTransaction(DataCache snapshot, UInt256 hash)
public TransactionState GetTransactionState(DataCache snapshot, UInt256 hash)
{
return GetTransactionState(snapshot, hash)?.Transaction;
return snapshot.TryGet(CreateStorageKey(Prefix_Transaction).Add(hash))?.GetInteroperable<TransactionState>();
}

public TransactionState GetTransactionState(DataCache snapshot, UInt256 hash)
public Transaction GetTransaction(DataCache snapshot, UInt256 hash)
{
return snapshot.TryGet(CreateStorageKey(Prefix_Transaction).Add(hash))?.GetInteroperable<TransactionState>();
return GetTransactionState(snapshot, hash)?.Transaction;
}

[ContractMethod(0_01000000, CallFlags.ReadStates, Name = "getTransaction")]
private Transaction GetTransactionForContract(DataCache snapshot, UInt256 hash)
{
TransactionState state = snapshot.TryGet(CreateStorageKey(Prefix_Transaction).Add(hash))?.GetInteroperable<TransactionState>();
TransactionState state = GetTransactionState(snapshot, hash);
if (state is null || !IsTraceableBlock(snapshot, state.BlockIndex)) return null;
return state.Transaction;
}

[ContractMethod(0_01000000, CallFlags.ReadStates)]
private int GetTransactionHeight(DataCache snapshot, UInt256 hash)
{
TransactionState state = snapshot.TryGet(CreateStorageKey(Prefix_Transaction).Add(hash))?.GetInteroperable<TransactionState>();
TransactionState state = GetTransactionState(snapshot, hash);
if (state is null || !IsTraceableBlock(snapshot, state.BlockIndex)) return -1;
return (int)state.BlockIndex;
}
Expand Down

0 comments on commit 41c5d9f

Please sign in to comment.