@@ -16,16 +16,13 @@ import (
16
16
"github.com/nspcc-dev/neo-go/pkg/services/helpers/neofs"
17
17
"github.com/nspcc-dev/neo-go/pkg/util"
18
18
"github.com/nspcc-dev/neo-go/pkg/wallet"
19
- "github.com/nspcc-dev/neofs-sdk-go/checksum"
20
19
"github.com/nspcc-dev/neofs-sdk-go/client"
21
20
"github.com/nspcc-dev/neofs-sdk-go/container"
22
21
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
23
- "github.com/nspcc-dev/neofs-sdk-go/netmap"
24
22
"github.com/nspcc-dev/neofs-sdk-go/object"
25
23
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
26
24
"github.com/nspcc-dev/neofs-sdk-go/pool"
27
25
"github.com/nspcc-dev/neofs-sdk-go/user"
28
- "github.com/nspcc-dev/neofs-sdk-go/version"
29
26
"github.com/urfave/cli/v2"
30
27
)
31
28
@@ -86,17 +83,6 @@ func uploadBin(ctx *cli.Context) error {
86
83
}
87
84
defer p .Close ()
88
85
89
- var net netmap.NetworkInfo
90
- err = retry (func () error {
91
- var errNet error
92
- net , errNet = p .NetworkInfo (ctx .Context , client.PrmNetworkInfo {})
93
- return errNet
94
- }, maxRetries )
95
- if err != nil {
96
- return cli .Exit (fmt .Errorf ("failed to get network info: %w" , err ), 1 )
97
- }
98
- homomorphicHashingDisabled := net .HomomorphicHashingDisabled ()
99
-
100
86
var containerObj container.Container
101
87
err = retry (func () error {
102
88
containerObj , err = p .ContainerGet (ctx .Context , containerID , client.PrmContainerGet {})
@@ -126,7 +112,7 @@ func uploadBin(ctx *cli.Context) error {
126
112
return cli .Exit (fmt .Errorf ("failed to find objects: %w" , err ), 1 )
127
113
}
128
114
129
- err = uploadBlocksAndIndexFiles (ctx , pWrapper , rpc , signer , containerID , acc , attr , indexAttrKey , buf , i , indexFileSize , uint (currentBlockHeight ), homomorphicHashingDisabled , numWorkers , maxRetries , debug )
115
+ err = uploadBlocksAndIndexFiles (ctx , pWrapper , rpc , signer , containerID , acc , attr , indexAttrKey , buf , i , indexFileSize , uint (currentBlockHeight ), numWorkers , maxRetries , debug )
130
116
if err != nil {
131
117
return cli .Exit (fmt .Errorf ("failed to upload objects: %w" , err ), 1 )
132
118
}
@@ -151,7 +137,7 @@ func retry(action func() error, maxRetries uint) error {
151
137
}
152
138
153
139
// uploadBlocksAndIndexFiles uploads the blocks and index files to the container using the pool.
154
- func uploadBlocksAndIndexFiles (ctx * cli.Context , p poolWrapper , rpc * rpcclient.Client , signer user.Signer , containerID cid.ID , acc * wallet.Account , attr , indexAttributeKey string , buf []byte , currentIndexFileID , indexFileSize , currentBlockHeight uint , homomorphicHashingDisabled bool , numWorkers , maxRetries uint , debug bool ) error {
140
+ func uploadBlocksAndIndexFiles (ctx * cli.Context , p poolWrapper , rpc * rpcclient.Client , signer user.Signer , containerID cid.ID , acc * wallet.Account , attr , indexAttributeKey string , buf []byte , currentIndexFileID , indexFileSize , currentBlockHeight uint , numWorkers , maxRetries uint , debug bool ) error {
155
141
if currentIndexFileID * indexFileSize >= currentBlockHeight {
156
142
fmt .Fprintf (ctx .App .Writer , "No new blocks to upload. Need to upload starting from %d, current height %d\n " , currentIndexFileID * indexFileSize , currentBlockHeight )
157
143
return nil
@@ -218,7 +204,7 @@ func uploadBlocksAndIndexFiles(ctx *cli.Context, p poolWrapper, rpc *rpcclient.C
218
204
)
219
205
errRetr := retry (func () error {
220
206
var errUpload error
221
- resOid , errUpload = uploadObj (ctx .Context , p , signer , acc .PrivateKey ().GetScriptHash (), containerID , objBytes , attrs , homomorphicHashingDisabled )
207
+ resOid , errUpload = uploadObj (ctx .Context , p , signer , acc .PrivateKey ().GetScriptHash (), containerID , objBytes , attrs )
222
208
if errUpload != nil {
223
209
return errUpload
224
210
}
@@ -265,7 +251,7 @@ func uploadBlocksAndIndexFiles(ctx *cli.Context, p poolWrapper, rpc *rpcclient.C
265
251
}
266
252
err := retry (func () error {
267
253
var errUpload error
268
- _ , errUpload = uploadObj (ctx .Context , p , signer , acc .PrivateKey ().GetScriptHash (), containerID , buf , attrs , homomorphicHashingDisabled )
254
+ _ , errUpload = uploadObj (ctx .Context , p , signer , acc .PrivateKey ().GetScriptHash (), containerID , buf , attrs )
269
255
return errUpload
270
256
}, maxRetries )
271
257
if err != nil {
@@ -437,41 +423,19 @@ func searchObjects(ctx context.Context, p poolWrapper, containerID cid.ID, accou
437
423
}
438
424
439
425
// uploadObj uploads object to the container using provided settings.
440
- func uploadObj (ctx context.Context , p poolWrapper , signer user.Signer , owner util.Uint160 , containerID cid.ID , objData []byte , attrs []object.Attribute , homomorphicHashingDisabled bool ) (oid.ID , error ) {
426
+ func uploadObj (ctx context.Context , p poolWrapper , signer user.Signer , owner util.Uint160 , containerID cid.ID , objData []byte , attrs []object.Attribute ) (oid.ID , error ) {
441
427
var (
442
428
ownerID user.ID
443
429
hdr object.Object
444
- chSHA256 checksum.Checksum
445
- chHomomorphic checksum.Checksum
446
- v = new (version.Version )
447
430
prmObjectPutInit client.PrmObjectPutInit
448
431
resOID = oid.ID {}
449
432
)
450
433
451
434
ownerID .SetScriptHash (owner )
452
435
hdr .SetPayload (objData )
453
- hdr .SetPayloadSize (uint64 (len (objData )))
454
436
hdr .SetContainerID (containerID )
455
437
hdr .SetOwnerID (& ownerID )
456
438
hdr .SetAttributes (attrs ... )
457
- hdr .SetCreationEpoch (1 )
458
- v .SetMajor (1 )
459
- hdr .SetVersion (v )
460
- if ! homomorphicHashingDisabled {
461
- checksum .Calculate (& chHomomorphic , checksum .TZ , objData )
462
- hdr .SetPayloadHomomorphicHash (chHomomorphic )
463
- }
464
- checksum .Calculate (& chSHA256 , checksum .SHA256 , objData )
465
- hdr .SetPayloadChecksum (chSHA256 )
466
-
467
- err := hdr .SetIDWithSignature (signer )
468
- if err != nil {
469
- return resOID , err
470
- }
471
- err = hdr .CheckHeaderVerificationFields ()
472
- if err != nil {
473
- return resOID , err
474
- }
475
439
476
440
writer , err := p .ObjectPutInit (ctx , hdr , signer , prmObjectPutInit )
477
441
if err != nil {
0 commit comments