No description
Find a file
2026-10-01 13:12:53 +03:00
.github go.mod: upgrade to 1.26 min, use 1.27 for tests 2026-08-21 15:14:24 +03:00
accounting internal/proto: Export from module 2026-08-26 19:20:49 +03:00
bearer internal/proto: Export from module 2026-08-26 19:20:49 +03:00
checksum checksum: drop support for TZ hash calculations, fix #831 2026-08-04 19:21:56 +03:00
client client: drop obsolete SyncContainerWithNetwork 2026-09-30 18:16:39 +03:00
container client: drop obsolete SyncContainerWithNetwork 2026-09-30 18:16:39 +03:00
crypto crypto/proto: Reuse existing message interface type 2026-08-26 19:20:49 +03:00
docs docs: add minimalistic labels doc 2023-12-20 21:36:44 +03:00
eacl version: Bump current to 2.27 2026-09-09 16:28:48 +03:00
internal client: autoresolve grpcs scheme into port 443 (#865) 2026-09-07 09:15:38 +03:00
netmap Feat/versioned netmap (#867) 2026-09-04 13:25:37 +03:00
object client: drop ObjectSearchInit and associated 2026-09-30 18:15:27 +03:00
pool pool: fix AIO test with node 0.57.0 2026-09-30 18:16:40 +03:00
proto client/proto: move container revision from X-Headers to request fields 2026-09-25 20:18:52 +03:00
reputation internal/proto: Export from module 2026-08-26 19:20:49 +03:00
scripts Store protocol-related code in proto dir 2024-07-15 20:36:38 +04:00
session session: simplify readContext() types 2026-09-15 18:46:21 +03:00
stat client: drop ObjectHash operation 2026-07-31 16:40:38 +03:00
user *: silence staticcheck warnings for ecdsa.PublicKey direct access 2026-08-21 16:04:31 +03:00
version version: Bump current to 2.27 2026-09-09 16:28:48 +03:00
.gitattributes [#3] policy: use ANTLRv4 parser generator 2021-06-15 11:42:14 +03:00
.gitignore workflows: reuse org-wide linter job 2024-09-10 21:26:16 +03:00
CHANGELOG.md client: drop obsolete SyncContainerWithNetwork 2026-09-30 18:16:39 +03:00
go.mod build(deps): bump google.golang.org/grpc from 1.83.1 to 1.83.2 2026-09-09 00:17:20 +00:00
go.sum build(deps): bump google.golang.org/grpc from 1.83.1 to 1.83.2 2026-09-09 00:17:20 +00:00
LICENSE Initial commit 2021-02-25 11:35:04 +03:00
Makefile Makefile: specify .PHONY targets 2026-02-27 17:56:30 +03:00
README.md README: drop deprecated goreportcard 2026-09-29 18:57:09 +03:00

codecov GitHub release (latest SemVer) License

neofs-sdk-go

Go implementation of NeoFS SDK. It contains high-level version-independent wrappers for structures from proto packages as well as helper functions for simplifying node/dApp implementations.

Repository structure

accounting

Contains fixed-point Decimal type for performing balance calculations.

eacl

Contains Extended ACL types for fine-grained access control. There is also a reference implementation of checking algorithm which is used in NeoFS node.

checksum

Contains Checksum type encapsulating checksum as well as it's kind. Currently Sha256 and Tillich-Zemor hashsum are in use.

bearer

Contains Bearer token type with several NeoFS-specific methods.

session

To help lightweight clients interact with NeoFS without sacrificing trust, NeoFS has a concept of session token. It is signed by client and allows any node with which a session is established to perform certain actions on behalf of the user.

client

Contains client for working with NeoFS.

var prmInit client.PrmInit
prmInit.SetDefaultPrivateKey(key) // private key for request signing

c, err := client.New(prmInit)
if err != nil {
    return
}

var prmDial client.PrmDial
prmDial.SetServerURI("grpcs://localhost:40005") // endpoint address

err := c.Dial(prmDial)
if err != nil {
    return
}
    
ctx, cancel := context.WithTimeout(context.Background(), 5 * time.Second)
defer cancel()

var prm client.PrmBalanceGet
prm.SetAccount(acc)

res, err := c.BalanceGet(ctx, prm)
if err != nil {
    return
}

fmt.Printf("Balance for %s: %v\n", acc, res.Amount())

Response status

In NeoFS every operation can fail on multiple levels, so a single error doesn't suffice, e.g. consider a case when object was put on 4 out of 5 replicas. Thus, all request execution details are contained in Status returned from every RPC call. dApp can inspect them if needed and perform any desired action. In the case above we may want to report these details to the user as well as retry an operation, possibly with different parameters. Status wire-format is extendable and each node can report any set of details it wants. The set of reserved status codes can be found in NeoFS API.

netmap

Contains CRUSH-like implementation of container node selection algorithm. Relevant details are described in this paper http://ceur-ws.org/Vol-2344/short10.pdf . Note that it can be outdated in some details.

netmap/json_tests subfolder contains language-agnostic tests for selection algorithm.

import (
    "github.com/nspcc-dev/neofs-sdk-go/netmap"
    "github.com/nspcc-dev/neofs-sdk-go/object"
)

func placementNodes(addr *object.Address, p *netmap.PlacementPolicy, neofsNodes []netmap.NodeInfo) {
    // Convert list of nodes in NeoFS API format to the intermediate representation.
    nodes := netmap.NodesFromInfo(nodes)

    // Create new netmap (errors are skipped for the sake of clarity). 
    nm, _ := NewNetmap(nodes)

    // Calculate nodes of container.
    cn, _ := nm.GetContainerNodes(p, addr.ContainerID().ToV2().GetValue())

    // Return list of nodes for each replica to place object on in the order of priority.
    return nm.GetPlacementVectors(cn, addr.ObjectID().ToV2().GetValue())
}

pool

Simple pool for managing connections to NeoFS nodes.

checksum, version

Contain simple API wrappers.

Development

NeoFS API protocol codegen

Go code for NeoFS protocol messages, client and server is in api directory. To compile source files from https://github.com/nspcc-dev/neofs-api repository, clone it first and then exec:

$ ./scripts/genapi.sh /path/to/neofs-api