forked from TrueCloudLab/frostfs-node
[#265] innerring: Select containers to audit
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
87e1252065
commit
3d3d058b05
8 changed files with 263 additions and 11 deletions
|
@ -74,23 +74,24 @@ func CashOutCheque(cli *client.Client, con util.Uint160, p *ChequeParams) error
|
|||
)
|
||||
}
|
||||
|
||||
// InnerRingIndex returns index of the `key` in the inner ring list from sidechain.
|
||||
// If key is not in the inner ring list, then returns `-1`.
|
||||
func InnerRingIndex(cli *client.Client, con util.Uint160, key *ecdsa.PublicKey) (int32, error) {
|
||||
// InnerRingIndex returns index of the `key` in the inner ring list from sidechain
|
||||
// along with total size of inner ring list. If key is not in the inner ring list,
|
||||
// then returns `-1` as index.
|
||||
func InnerRingIndex(cli *client.Client, con util.Uint160, key *ecdsa.PublicKey) (int32, int32, error) {
|
||||
if cli == nil {
|
||||
return 0, client.ErrNilClient
|
||||
return 0, 0, client.ErrNilClient
|
||||
}
|
||||
|
||||
nodePublicKey := crypto.MarshalPublicKey(key)
|
||||
|
||||
data, err := cli.TestInvoke(con, innerRingListMethod)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
irNodes, err := client.ArrayFromStackItem(data[0])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
var result int32 = -1
|
||||
|
@ -98,12 +99,12 @@ func InnerRingIndex(cli *client.Client, con util.Uint160, key *ecdsa.PublicKey)
|
|||
for i := range irNodes {
|
||||
key, err := client.ArrayFromStackItem(irNodes[i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
keyValue, err := client.BytesFromStackItem(key[0])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
if bytes.Equal(keyValue, nodePublicKey) {
|
||||
|
@ -112,5 +113,5 @@ func InnerRingIndex(cli *client.Client, con util.Uint160, key *ecdsa.PublicKey)
|
|||
}
|
||||
}
|
||||
|
||||
return result, nil
|
||||
return result, int32(len(irNodes)), nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue