Skip to content

Commit

Permalink
index
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhangTao1596 committed Nov 3, 2020
1 parent 475ba5d commit f32c744
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/neo/Network/P2P/Payloads/OracleResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public override bool Verify(StoreView snapshot, Transaction tx)
OracleRequest request = NativeContract.Oracle.GetRequest(snapshot, Id);
if (request is null) return false;
if (tx.NetworkFee + tx.SystemFee != request.GasForResponse) return false;
UInt160 oracleAccount = Blockchain.GetConsensusAddress(NativeContract.Designate.GetDesignatedByRole(snapshot, Role.Oracle, snapshot.Height));
UInt160 oracleAccount = Blockchain.GetConsensusAddress(NativeContract.Designate.GetDesignatedByRole(snapshot, Role.Oracle, snapshot.Height + 1));
return tx.Signers.Any(p => p.Account.Equals(oracleAccount));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public ECPoint[] GetDesignatedByRole(StoreView snapshot, Role role, uint index)
{
if (!Enum.IsDefined(typeof(Role), role))
throw new ArgumentOutOfRangeException(nameof(role));
if (snapshot.Height + 2 < index)
if (snapshot.Height + 1 < index)
throw new ArgumentOutOfRangeException(nameof(index));
byte[] key = CreateStorageKey((byte)role).AddBigEndian(index).ToArray();
byte[] boundary = CreateStorageKey((byte)role).ToArray();
Expand Down
2 changes: 1 addition & 1 deletion src/neo/SmartContract/Native/Oracle/OracleContract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected override void PostPersist(ApplicationEngine engine)
if (list.Count == 0) engine.Snapshot.Storages.Delete(key);

//Mint GAS for oracle nodes
nodes ??= NativeContract.Designate.GetDesignatedByRole(engine.Snapshot, Role.Oracle, engine.Snapshot.Height).Select(p => (Contract.CreateSignatureRedeemScript(p).ToScriptHash(), BigInteger.Zero)).ToArray();
nodes ??= NativeContract.Designate.GetDesignatedByRole(engine.Snapshot, Role.Oracle, engine.Snapshot.PersistingBlock.Index).Select(p => (Contract.CreateSignatureRedeemScript(p).ToScriptHash(), BigInteger.Zero)).ToArray();
if (nodes.Length > 0)
{
int index = (int)(response.Id % (ulong)nodes.Length);
Expand Down

0 comments on commit f32c744

Please sign in to comment.