change proto generator to std gogo
This commit is contained in:
parent
2d00719a05
commit
d157c561b7
70
go.mod
70
go.mod
@ -3,32 +3,20 @@ module github.com/anytypeio/go-anytype-infrastructure-experiments
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/akrylysov/pogreb v0.10.1
|
||||
github.com/anytypeio/go-chash v0.0.0-20220629194632-4ad1154fe232
|
||||
github.com/awalterschulze/gographviz v0.0.0-20190522210029-fa59802746ab
|
||||
github.com/cespare/xxhash v1.1.0
|
||||
github.com/goccy/go-graphviz v0.0.9
|
||||
github.com/gogo/protobuf v1.3.2
|
||||
github.com/huandu/skiplist v1.2.0
|
||||
github.com/ipfs/go-block-format v0.0.3
|
||||
github.com/ipfs/go-blockservice v0.4.0
|
||||
github.com/ipfs/go-cid v0.3.0
|
||||
github.com/ipfs/go-datastore v0.6.0
|
||||
github.com/ipfs/go-ipfs-blockstore v1.2.0
|
||||
github.com/ipfs/go-ipfs-chunker v0.0.5
|
||||
github.com/ipfs/go-ipfs-exchange-interface v0.2.0
|
||||
github.com/ipfs/go-ipld-cbor v0.0.6
|
||||
github.com/ipfs/go-ipld-format v0.4.0
|
||||
github.com/ipfs/go-merkledag v0.7.0
|
||||
github.com/ipfs/go-unixfs v0.4.0
|
||||
github.com/ipfs/go-cid v0.1.0
|
||||
github.com/libp2p/go-libp2p v0.20.3
|
||||
github.com/libp2p/go-libp2p-core v0.16.1
|
||||
github.com/mr-tron/base58 v1.2.0
|
||||
github.com/multiformats/go-multibase v0.1.1
|
||||
github.com/multiformats/go-multihash v0.2.1
|
||||
github.com/multiformats/go-multibase v0.0.3
|
||||
github.com/multiformats/go-multihash v0.1.0
|
||||
github.com/stretchr/testify v1.8.0
|
||||
github.com/zeebo/blake3 v0.2.3
|
||||
go.uber.org/zap v1.23.0
|
||||
go.uber.org/zap v1.21.0
|
||||
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
storj.io/drpc v0.0.32
|
||||
@ -36,61 +24,37 @@ require (
|
||||
|
||||
require (
|
||||
github.com/OneOfOne/xxhash v1.2.8 // indirect
|
||||
github.com/alecthomas/units v0.0.0-20210927113745-59d0afb8317a // indirect
|
||||
github.com/anytypeio/go-chash v0.0.0-20220629194632-4ad1154fe232 // indirect
|
||||
github.com/btcsuite/btcd v0.22.1 // indirect
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.1.3 // indirect
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
|
||||
github.com/fogleman/gg v1.3.0 // indirect
|
||||
github.com/go-logr/logr v1.2.3 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
|
||||
github.com/google/uuid v1.3.0 // indirect
|
||||
github.com/hashicorp/golang-lru v0.5.4 // indirect
|
||||
github.com/ipfs/bbloom v0.0.4 // indirect
|
||||
github.com/ipfs/go-bitfield v1.0.0 // indirect
|
||||
github.com/ipfs/go-ipfs-ds-help v1.1.0 // indirect
|
||||
github.com/ipfs/go-ipfs-files v0.0.3 // indirect
|
||||
github.com/ipfs/go-ipfs-posinfo v0.0.1 // indirect
|
||||
github.com/ipfs/go-ipfs-util v0.0.2 // indirect
|
||||
github.com/ipfs/go-ipld-legacy v0.1.1 // indirect
|
||||
github.com/ipfs/go-log v1.0.5 // indirect
|
||||
github.com/ipfs/go-log/v2 v2.5.1 // indirect
|
||||
github.com/ipfs/go-metrics-interface v0.0.1 // indirect
|
||||
github.com/ipfs/go-verifcid v0.0.2 // indirect
|
||||
github.com/ipld/go-codec-dagpb v1.5.0 // indirect
|
||||
github.com/ipld/go-ipld-prime v0.18.0 // indirect
|
||||
github.com/jbenet/goprocess v0.1.4 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.1.1 // indirect
|
||||
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.0.12 // indirect
|
||||
github.com/libp2p/go-buffer-pool v0.0.2 // indirect
|
||||
github.com/libp2p/go-openssl v0.0.7 // indirect
|
||||
github.com/mattn/go-isatty v0.0.16 // indirect
|
||||
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 // indirect
|
||||
github.com/minio/sha256-simd v1.0.0 // indirect
|
||||
github.com/multiformats/go-base32 v0.1.0 // indirect
|
||||
github.com/multiformats/go-base32 v0.0.3 // indirect
|
||||
github.com/multiformats/go-base36 v0.1.0 // indirect
|
||||
github.com/multiformats/go-multiaddr v0.5.0 // indirect
|
||||
github.com/multiformats/go-multicodec v0.5.0 // indirect
|
||||
github.com/multiformats/go-multicodec v0.4.1 // indirect
|
||||
github.com/multiformats/go-varint v0.0.6 // indirect
|
||||
github.com/opentracing/opentracing-go v1.2.0 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/polydawn/refmt v0.0.0-20201211092308-30ac6d18308e // indirect
|
||||
github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 // indirect
|
||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||
github.com/whyrusleeping/cbor-gen v0.0.0-20220514204315-f29c37e9c44c // indirect
|
||||
github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f // indirect
|
||||
github.com/zeebo/errs v1.2.2 // indirect
|
||||
go.opentelemetry.io/otel v1.9.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.9.0 // indirect
|
||||
go.uber.org/atomic v1.10.0 // indirect
|
||||
go.uber.org/atomic v1.9.0 // indirect
|
||||
go.uber.org/multierr v1.8.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect
|
||||
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
|
||||
golang.org/x/image v0.0.0-20200119044424-58c23975cae1 // indirect
|
||||
golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b // indirect
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
|
||||
golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirect
|
||||
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 // indirect
|
||||
google.golang.org/protobuf v1.28.1 // indirect
|
||||
lukechampine.com/blake3 v1.1.7 // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
lukechampine.com/blake3 v1.1.6 // indirect
|
||||
)
|
||||
|
||||
250
go.sum
250
go.sum
@ -1,11 +1,6 @@
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||
github.com/OneOfOne/xxhash v1.2.8 h1:31czK/TI9sNkxIKfaUfGlU47BAxQ0ztGgd9vPyqimf8=
|
||||
github.com/OneOfOne/xxhash v1.2.8/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q=
|
||||
github.com/akrylysov/pogreb v0.10.1 h1:FqlR8VR7uCbJdfUob916tPM+idpKgeESDXOA1K0DK4w=
|
||||
github.com/akrylysov/pogreb v0.10.1/go.mod h1:pNs6QmpQ1UlTJKDezuRWmaqkgUE2TuU0YTWyqJZ7+lI=
|
||||
github.com/alecthomas/units v0.0.0-20210927113745-59d0afb8317a h1:E/8AP5dFtMhl5KPJz66Kt9G0n+7Sn41Fy1wv9/jHOrc=
|
||||
github.com/alecthomas/units v0.0.0-20210927113745-59d0afb8317a/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE=
|
||||
github.com/anytypeio/go-chash v0.0.0-20220629194632-4ad1154fe232 h1:kMPPZYmJgbs4AJfodbg2OCXg5cp+9LPAJcLZJqmcghk=
|
||||
github.com/anytypeio/go-chash v0.0.0-20220629194632-4ad1154fe232/go.mod h1:+PeHBAWp7gUh/yw6uAauKc5ku0w4cFNg6DUddGxoGq0=
|
||||
github.com/awalterschulze/gographviz v0.0.0-20190522210029-fa59802746ab h1:+cdNqtOJWjvepyhxy23G7z7vmpYCoC65AP0nqi1f53s=
|
||||
@ -22,7 +17,6 @@ github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
github.com/corona10/goimagehash v1.0.2 h1:pUfB0LnsJASMPGEZLj7tGY251vF+qLGqOgEP4rUs6kA=
|
||||
github.com/corona10/goimagehash v1.0.2/go.mod h1:/l9umBhvcHQXVtQO1V6Gp1yD20STawkhRnnX0D1bvVI=
|
||||
github.com/cskr/pubsub v1.0.2 h1:vlOzMhl6PFn60gRlTQQsIfVwaPB/B/8MziK8FhEPt/0=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
@ -32,222 +26,77 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
|
||||
github.com/fogleman/gg v1.3.0 h1:/7zJX8F6AaYQc57WQCyN9cAIz+4bCJGO9B+dyW29am8=
|
||||
github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
|
||||
github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k=
|
||||
github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE=
|
||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0=
|
||||
github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/goccy/go-graphviz v0.0.9 h1:s/FMMJ1Joj6La3S5ApO3Jk2cwM4LpXECC2muFx3IPQQ=
|
||||
github.com/goccy/go-graphviz v0.0.9/go.mod h1:wXVsXxmyMQU6TN3zGRttjNn3h+iCAS7xQFC6TlNvLhk=
|
||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
||||
github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF8=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/gxed/hashland/keccakpg v0.0.1/go.mod h1:kRzw3HkwxFU1mpmPP8v1WyQzwdGfmKFJ6tItnhQ67kU=
|
||||
github.com/gxed/hashland/murmur3 v0.0.1/go.mod h1:KjXop02n4/ckmZSnY2+HKcLud/tcmvhST0bie/0lS48=
|
||||
github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
|
||||
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
|
||||
github.com/huandu/go-assert v1.1.5 h1:fjemmA7sSfYHJD7CUqs9qTwwfdNAx7/j2/ZlHXzNB3c=
|
||||
github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0JrPVhn/06U=
|
||||
github.com/huandu/skiplist v1.2.0 h1:gox56QD77HzSC0w+Ws3MH3iie755GBJU1OER3h5VsYw=
|
||||
github.com/huandu/skiplist v1.2.0/go.mod h1:7v3iFjLcSAzO4fN5B8dvebvo/qsfumiLiDXMrPiHF9w=
|
||||
github.com/huin/goupnp v1.0.0 h1:wg75sLpL6DZqwHQN6E1Cfk6mtfzS45z8OV+ic+DtHRo=
|
||||
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
|
||||
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
|
||||
github.com/ipfs/go-bitfield v1.0.0 h1:y/XHm2GEmD9wKngheWNNCNL0pzrWXZwCdQGv1ikXknQ=
|
||||
github.com/ipfs/go-bitfield v1.0.0/go.mod h1:N/UiujQy+K+ceU1EF5EkVd1TNqevLrCQMIcAEPrdtus=
|
||||
github.com/ipfs/go-bitswap v0.8.0 h1:UEV7kogQu2iGggkE9GhLykDrRCUpsNnpu2NODww/srw=
|
||||
github.com/ipfs/go-block-format v0.0.2/go.mod h1:AWR46JfpcObNfg3ok2JHDUfdiHRgWhJgCQF+KIgOPJY=
|
||||
github.com/ipfs/go-block-format v0.0.3 h1:r8t66QstRp/pd/or4dpnbVfXT5Gt7lOqRvC+/dDTpMc=
|
||||
github.com/ipfs/go-block-format v0.0.3/go.mod h1:4LmD4ZUw0mhO+JSKdpWwrzATiEfM7WWgQ8H5l6P8MVk=
|
||||
github.com/ipfs/go-blockservice v0.4.0 h1:7MUijAW5SqdsqEW/EhnNFRJXVF8mGU5aGhZ3CQaCWbY=
|
||||
github.com/ipfs/go-blockservice v0.4.0/go.mod h1:kRjO3wlGW9mS1aKuiCeGhx9K1DagQ10ACpVO59qgAx4=
|
||||
github.com/ipfs/go-cid v0.0.1/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM=
|
||||
github.com/ipfs/go-cid v0.0.2/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM=
|
||||
github.com/ipfs/go-cid v0.0.3/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM=
|
||||
github.com/ipfs/go-cid v0.0.4/go.mod h1:4LLaPOQwmk5z9LBgQnpkivrx8BJjUyGwTXCd5Xfj6+M=
|
||||
github.com/ipfs/go-cid v0.0.5/go.mod h1:plgt+Y5MnOey4vO4UlUazGqdbEXuFYitED67FexhXog=
|
||||
github.com/ipfs/go-cid v0.0.6/go.mod h1:6Ux9z5e+HpkQdckYoX1PG/6xqKspzlEIR5SDmgqgC/I=
|
||||
github.com/ipfs/go-cid v0.0.7/go.mod h1:6Ux9z5e+HpkQdckYoX1PG/6xqKspzlEIR5SDmgqgC/I=
|
||||
github.com/ipfs/go-cid v0.3.0 h1:gT6Cbs6YePaBNc7l6v5EXt0xTMup1jGV5EU1N+QLVpY=
|
||||
github.com/ipfs/go-cid v0.3.0/go.mod h1:P+HXFDF4CVhaVayiEb4wkAy7zBHxBwsJyt0Y5U6MLro=
|
||||
github.com/ipfs/go-datastore v0.5.0/go.mod h1:9zhEApYMTl17C8YDp7JmU7sQZi2/wqiYh73hakZ90Bk=
|
||||
github.com/ipfs/go-datastore v0.6.0 h1:JKyz+Gvz1QEZw0LsX1IBn+JFCJQH4SJVFtM4uWU0Myk=
|
||||
github.com/ipfs/go-datastore v0.6.0/go.mod h1:rt5M3nNbSO/8q1t4LNkLyUwRs8HupMeN/8O4Vn9YAT8=
|
||||
github.com/ipfs/go-detect-race v0.0.1 h1:qX/xay2W3E4Q1U7d9lNs1sU9nvguX0a7319XbyQ6cOk=
|
||||
github.com/ipfs/go-detect-race v0.0.1/go.mod h1:8BNT7shDZPo99Q74BpGMK+4D8Mn4j46UU0LZ723meps=
|
||||
github.com/ipfs/go-ipfs-blockstore v1.2.0 h1:n3WTeJ4LdICWs/0VSfjHrlqpPpl6MZ+ySd3j8qz0ykw=
|
||||
github.com/ipfs/go-ipfs-blockstore v1.2.0/go.mod h1:eh8eTFLiINYNSNawfZOC7HOxNTxpB1PFuA5E1m/7exE=
|
||||
github.com/ipfs/go-ipfs-blocksutil v0.0.1 h1:Eh/H4pc1hsvhzsQoMEP3Bke/aW5P5rVM1IWFJMcGIPQ=
|
||||
github.com/ipfs/go-ipfs-chunker v0.0.5 h1:ojCf7HV/m+uS2vhUGWcogIIxiO5ubl5O57Q7NapWLY8=
|
||||
github.com/ipfs/go-ipfs-chunker v0.0.5/go.mod h1:jhgdF8vxRHycr00k13FM8Y0E+6BoalYeobXmUyTreP8=
|
||||
github.com/ipfs/go-ipfs-delay v0.0.0-20181109222059-70721b86a9a8/go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw=
|
||||
github.com/ipfs/go-ipfs-delay v0.0.1 h1:r/UXYyRcddO6thwOnhiznIAiSvxMECGgtv35Xs1IeRQ=
|
||||
github.com/ipfs/go-ipfs-ds-help v1.1.0 h1:yLE2w9RAsl31LtfMt91tRZcrx+e61O5mDxFRR994w4Q=
|
||||
github.com/ipfs/go-ipfs-ds-help v1.1.0/go.mod h1:YR5+6EaebOhfcqVCyqemItCLthrpVNot+rsOU/5IatU=
|
||||
github.com/ipfs/go-ipfs-exchange-interface v0.2.0 h1:8lMSJmKogZYNo2jjhUs0izT+dck05pqUw4mWNW9Pw6Y=
|
||||
github.com/ipfs/go-ipfs-exchange-interface v0.2.0/go.mod h1:z6+RhJuDQbqKguVyslSOuVDhqF9JtTrO3eptSAiW2/Y=
|
||||
github.com/ipfs/go-ipfs-exchange-offline v0.3.0 h1:c/Dg8GDPzixGd0MC8Jh6mjOwU57uYokgWRFidfvEkuA=
|
||||
github.com/ipfs/go-ipfs-files v0.0.3 h1:ME+QnC3uOyla1ciRPezDW0ynQYK2ikOh9OCKAEg4uUA=
|
||||
github.com/ipfs/go-ipfs-files v0.0.3/go.mod h1:INEFm0LL2LWXBhNJ2PMIIb2w45hpXgPjNoE7yA8Y1d4=
|
||||
github.com/ipfs/go-ipfs-posinfo v0.0.1 h1:Esoxj+1JgSjX0+ylc0hUmJCOv6V2vFoZiETLR6OtpRs=
|
||||
github.com/ipfs/go-ipfs-posinfo v0.0.1/go.mod h1:SwyeVP+jCwiDu0C313l/8jg6ZxM0qqtlt2a0vILTc1A=
|
||||
github.com/ipfs/go-ipfs-pq v0.0.2 h1:e1vOOW6MuOwG2lqxcLA+wEn93i/9laCY8sXAw76jFOY=
|
||||
github.com/ipfs/go-ipfs-routing v0.2.1 h1:E+whHWhJkdN9YeoHZNj5itzc+OR292AJ2uE9FFiW0BY=
|
||||
github.com/ipfs/go-ipfs-util v0.0.1/go.mod h1:spsl5z8KUnrve+73pOhSVZND1SIxPW5RyBCNzQxlJBc=
|
||||
github.com/ipfs/go-ipfs-util v0.0.2 h1:59Sswnk1MFaiq+VcaknX7aYEyGyGDAA73ilhEK2POp8=
|
||||
github.com/ipfs/go-ipfs-util v0.0.2/go.mod h1:CbPtkWJzjLdEcezDns2XYaehFVNXG9zrdrtMecczcsQ=
|
||||
github.com/ipfs/go-ipld-cbor v0.0.6 h1:pYuWHyvSpIsOOLw4Jy7NbBkCyzLDcl64Bf/LZW7eBQ0=
|
||||
github.com/ipfs/go-ipld-cbor v0.0.6/go.mod h1:ssdxxaLJPXH7OjF5V4NSjBbcfh+evoR4ukuru0oPXMA=
|
||||
github.com/ipfs/go-ipld-format v0.0.1/go.mod h1:kyJtbkDALmFHv3QR6et67i35QzO3S0dCDnkOJhcZkms=
|
||||
github.com/ipfs/go-ipld-format v0.2.0/go.mod h1:3l3C1uKoadTPbeNfrDi+xMInYKlx2Cvg1BuydPSdzQs=
|
||||
github.com/ipfs/go-ipld-format v0.3.0/go.mod h1:co/SdBE8h99968X0hViiw1MNlh6fvxxnHpvVLnH7jSM=
|
||||
github.com/ipfs/go-ipld-format v0.4.0 h1:yqJSaJftjmjc9jEOFYlpkwOLVKv68OD27jFLlSghBlQ=
|
||||
github.com/ipfs/go-ipld-format v0.4.0/go.mod h1:co/SdBE8h99968X0hViiw1MNlh6fvxxnHpvVLnH7jSM=
|
||||
github.com/ipfs/go-ipld-legacy v0.1.1 h1:BvD8PEuqwBHLTKqlGFTHSwrwFOMkVESEvwIYwR2cdcc=
|
||||
github.com/ipfs/go-ipld-legacy v0.1.1/go.mod h1:8AyKFCjgRPsQFf15ZQgDB8Din4DML/fOmKZkkFkrIEg=
|
||||
github.com/ipfs/go-log v0.0.1/go.mod h1:kL1d2/hzSpI0thNYjiKfjanbVNU+IIGA/WnNESY9leM=
|
||||
github.com/ipfs/go-log v1.0.5 h1:2dOuUCB1Z7uoczMWgAyDck5JLb72zHzrMnGnCNNbvY8=
|
||||
github.com/ipfs/go-log v1.0.5/go.mod h1:j0b8ZoR+7+R99LD9jZ6+AJsrzkPbSXbZfGakb5JPtIo=
|
||||
github.com/ipfs/go-log/v2 v2.1.3/go.mod h1:/8d0SH3Su5Ooc31QlL1WysJhvyOTDCjcCZ9Axpmri6g=
|
||||
github.com/ipfs/go-log/v2 v2.5.1 h1:1XdUzF7048prq4aBjDQQ4SL5RxftpRGdXhNRwKSAlcY=
|
||||
github.com/ipfs/go-log/v2 v2.5.1/go.mod h1:prSpmC1Gpllc9UYWxDiZDreBYw7zp4Iqp1kOLU9U5UI=
|
||||
github.com/ipfs/go-merkledag v0.7.0 h1:PHdWOGwx+J2uRAuP9Mu+bz89ulmf3W2QmbSS/N6O29U=
|
||||
github.com/ipfs/go-merkledag v0.7.0/go.mod h1:/1cuN4VbcDn/xbVMAqjPUwejJYr8W9SvizmyYLU/B7k=
|
||||
github.com/ipfs/go-metrics-interface v0.0.1 h1:j+cpbjYvu4R8zbleSs36gvB7jR+wsL2fGD6n0jO4kdg=
|
||||
github.com/ipfs/go-metrics-interface v0.0.1/go.mod h1:6s6euYU4zowdslK0GKHmqaIZ3j/b/tL7HTWtJ4VPgWY=
|
||||
github.com/ipfs/go-peertaskqueue v0.7.0 h1:VyO6G4sbzX80K58N60cCaHsSsypbUNs1GjO5seGNsQ0=
|
||||
github.com/ipfs/go-unixfs v0.4.0 h1:qSyyxfB/OiDdWHYiSbyaqKC7zfSE/TFL0QdwkRjBm20=
|
||||
github.com/ipfs/go-unixfs v0.4.0/go.mod h1:I7Nqtm06HgOOd+setAoCU6rf/HgVFHE+peeNuOv/5+g=
|
||||
github.com/ipfs/go-verifcid v0.0.2 h1:XPnUv0XmdH+ZIhLGKg6U2vaPaRDXb9urMyNVCE7uvTs=
|
||||
github.com/ipfs/go-verifcid v0.0.2/go.mod h1:40cD9x1y4OWnFXbLNJYRe7MpNvWlMn3LZAG5Wb4xnPU=
|
||||
github.com/ipld/go-codec-dagpb v1.5.0 h1:RspDRdsJpLfgCI0ONhTAnbHdySGD4t+LHSPK4X1+R0k=
|
||||
github.com/ipld/go-codec-dagpb v1.5.0/go.mod h1:0yRIutEFD8o1DGVqw4RSHh+BUTlJA9XWldxaaWR/o4g=
|
||||
github.com/ipld/go-ipld-prime v0.9.1-0.20210324083106-dc342a9917db/go.mod h1:KvBLMr4PX1gWptgkzRjVZCrLmSGcZCb/jioOQwCqZN8=
|
||||
github.com/ipld/go-ipld-prime v0.18.0 h1:xUk7NUBSWHEXdjiOu2sLXouFJOMs0yoYzeI5RAqhYQo=
|
||||
github.com/ipld/go-ipld-prime v0.18.0/go.mod h1:735yXW548CKrLwVCYXzqx90p5deRJMVVxM9eJ4Qe+qE=
|
||||
github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus=
|
||||
github.com/jbenet/go-cienv v0.1.0/go.mod h1:TqNnHUmJgXau0nCzC7kXWeotg3J9W34CUv5Djy1+FlA=
|
||||
github.com/jbenet/goprocess v0.1.4 h1:DRGOFReOMqqDNXwW70QkacFW0YN9QnwLV0Vqk+3oU0o=
|
||||
github.com/jbenet/goprocess v0.1.4/go.mod h1:5yspPrukOVuOLORacaBi858NqyClJPQxYZlqdZVfqY4=
|
||||
github.com/ipfs/go-cid v0.1.0 h1:YN33LQulcRHjfom/i25yoOZR4Telp1Hr/2RU3d0PnC0=
|
||||
github.com/ipfs/go-cid v0.1.0/go.mod h1:rH5/Xv83Rfy8Rw6xG+id3DYAMUVmem1MowoKwdXmN2o=
|
||||
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||
github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
|
||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.0.12 h1:p9dKCg8i4gmOxtv35DvrYoWqYzQrvEVdjQ762Y0OqZE=
|
||||
github.com/klauspost/cpuid/v2 v2.0.12/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c=
|
||||
github.com/klauspost/cpuid/v2 v2.1.1 h1:t0wUqjowdm8ezddV5k0tLWVklVuvLJpoHeb4WBdydm0=
|
||||
github.com/klauspost/cpuid/v2 v2.1.1/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY=
|
||||
github.com/koron/go-ssdp v0.0.0-20191105050749-2e1c40ed0b5d h1:68u9r4wEvL3gYg2jvAOgROwZ3H+Y3hIDk4tbbmIjcYQ=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/libp2p/go-buffer-pool v0.0.2 h1:QNK2iAFa8gjAe1SPz6mHSMuCcjs+X1wlHzeOSqcmlfs=
|
||||
github.com/libp2p/go-buffer-pool v0.0.2/go.mod h1:MvaB6xw5vOrDl8rYZGLFdKAuk/hRoRZd1Vi32+RXyFM=
|
||||
github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8=
|
||||
github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg=
|
||||
github.com/libp2p/go-cidranger v1.1.0 h1:ewPN8EZ0dd1LSnrtuwd4709PXVcITVeuwbag38yPW7c=
|
||||
github.com/libp2p/go-eventbus v0.2.1 h1:VanAdErQnpTioN2TowqNcOijf6YwhuODe4pPKSDpxGc=
|
||||
github.com/libp2p/go-libp2p v0.20.3 h1:tjjDNfp7FqdI/7v1rXtB/BtELaPlAThL2uzlj18kcrw=
|
||||
github.com/libp2p/go-libp2p v0.20.3/go.mod h1:I+vndVanE/p/SjFbnA+BEmmfAUEpWxrdXZeyQ1Dus5c=
|
||||
github.com/libp2p/go-libp2p-asn-util v0.2.0 h1:rg3+Os8jbnO5DxkC7K/Utdi+DkY3q/d1/1q+8WeNAsw=
|
||||
github.com/libp2p/go-libp2p-core v0.16.1 h1:bWoiEBqVkpJ13hbv/f69tHODp86t6mvc4fBN4DkK73M=
|
||||
github.com/libp2p/go-libp2p-core v0.16.1/go.mod h1:O3i/7y+LqUb0N+qhzXjBjjpchgptWAVMG1Voegk7b4c=
|
||||
github.com/libp2p/go-libp2p-loggables v0.1.0 h1:h3w8QFfCt2UJl/0/NW4K829HX/0S4KD31PQ7m8UXXO8=
|
||||
github.com/libp2p/go-libp2p-netutil v0.1.0 h1:zscYDNVEcGxyUpMd0JReUZTrpMfia8PmLKcKF72EAMQ=
|
||||
github.com/libp2p/go-libp2p-peerstore v0.6.0 h1:HJminhQSGISBIRb93N6WK3t6Fa8OOTnHd/VBjL4mY5A=
|
||||
github.com/libp2p/go-libp2p-record v0.1.0 h1:wHwBGbFzymoIl69BpgwIu0O6ta3TXGcMPvHUAcodzRc=
|
||||
github.com/libp2p/go-libp2p-testing v0.9.2 h1:dCpODRtRaDZKF8HXT9qqqgON+OMEB423Knrgeod8j84=
|
||||
github.com/libp2p/go-msgio v0.2.0 h1:W6shmB+FeynDrUVl2dgFQvzfBZcXiyqY4VmpQLu9FqU=
|
||||
github.com/libp2p/go-nat v0.1.0 h1:MfVsH6DLcpa04Xr+p8hmVRG4juse0s3J8HyNWYHffXg=
|
||||
github.com/libp2p/go-netroute v0.2.0 h1:0FpsbsvuSnAhXFnCY0VLFbJOzaK0VnP0r1QT/o4nWRE=
|
||||
github.com/libp2p/go-openssl v0.0.7 h1:eCAzdLejcNVBzP/iZM9vqHnQm+XyCEbSSIheIPRGNsw=
|
||||
github.com/libp2p/go-openssl v0.0.7/go.mod h1:unDrJpgy3oFr+rqXsarWifmJuNnJR4chtO1HmaZjggc=
|
||||
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
|
||||
github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/miekg/dns v1.1.43 h1:JKfpVSCB84vrAmHzyrsxB5NAr5kLoMXZArPSw7Qlgyg=
|
||||
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 h1:lYpkrQH5ajf0OXOcUbGjvZxxijuBwbbmlSxLiuofa+g=
|
||||
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1/go.mod h1:pD8RvIylQ358TN4wwqatJ8rNavkEINozVn9DtGI3dfQ=
|
||||
github.com/minio/sha256-simd v0.0.0-20190131020904-2d45a736cd16/go.mod h1:2FMWW+8GMoPweT6+pI63m9YE3Lmw4J71hV56Chs1E/U=
|
||||
github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM=
|
||||
github.com/minio/sha256-simd v1.0.0 h1:v1ta+49hkWZyvaKwrQB8elexRqm6Y0aMLjCNsrYxo6g=
|
||||
github.com/minio/sha256-simd v1.0.0/go.mod h1:OuYzVNI5vcoYIAmbIvHPl3N3jUzVedXbKy5RFepssQM=
|
||||
github.com/mr-tron/base58 v1.1.0/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8=
|
||||
github.com/mr-tron/base58 v1.1.2/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
|
||||
github.com/mr-tron/base58 v1.1.3/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
|
||||
github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o=
|
||||
github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
|
||||
github.com/multiformats/go-base32 v0.0.3 h1:tw5+NhuwaOjJCC5Pp82QuXbrmLzWg7uxlMFp8Nq/kkI=
|
||||
github.com/multiformats/go-base32 v0.0.3/go.mod h1:pLiuGC8y0QR3Ue4Zug5UzK9LjgbkL8NSQj0zQ5Nz/AA=
|
||||
github.com/multiformats/go-base32 v0.1.0 h1:pVx9xoSPqEIQG8o+UbAe7DNi51oej1NtK+aGkbLYxPE=
|
||||
github.com/multiformats/go-base32 v0.1.0/go.mod h1:Kj3tFY6zNr+ABYMqeUNeGvkIC/UYgtWibDcT0rExnbI=
|
||||
github.com/multiformats/go-base36 v0.1.0 h1:JR6TyF7JjGd3m6FbLU2cOxhC0Li8z8dLNGQ89tUg4F4=
|
||||
github.com/multiformats/go-base36 v0.1.0/go.mod h1:kFGE83c6s80PklsHO9sRn2NCoffoRdUUOENyW/Vv6sM=
|
||||
github.com/multiformats/go-multiaddr v0.5.0 h1:i/JuOoVg4szYQ4YEzDGtb2h0o8M7CG/Yq6cGlcjWZpM=
|
||||
github.com/multiformats/go-multiaddr v0.5.0/go.mod h1:3KAxNkUqLTJ20AAwN4XVX4kZar+bR+gh4zgbfr3SNug=
|
||||
github.com/multiformats/go-multiaddr-dns v0.3.1 h1:QgQgR+LQVt3NPTjbrLLpsaT2ufAA2y0Mkk+QRVJbW3A=
|
||||
github.com/multiformats/go-multiaddr-fmt v0.1.0 h1:WLEFClPycPkp4fnIzoFoV9FVd49/eQsuaL3/CWe167E=
|
||||
github.com/multiformats/go-multibase v0.0.1/go.mod h1:bja2MqRZ3ggyXtZSEDKpl0uO/gviWFaSteVbWT51qgs=
|
||||
github.com/multiformats/go-multibase v0.0.3 h1:l/B6bJDQjvQ5G52jw4QGSYeOTZoAwIO77RblWplfIqk=
|
||||
github.com/multiformats/go-multibase v0.0.3/go.mod h1:5+1R4eQrT3PkYZ24C3W2Ue2tPwIdYQD509ZjSb5y9Oc=
|
||||
github.com/multiformats/go-multibase v0.1.1 h1:3ASCDsuLX8+j4kx58qnJ4YFq/JWTJpCyDW27ztsVTOI=
|
||||
github.com/multiformats/go-multibase v0.1.1/go.mod h1:ZEjHE+IsUrgp5mhlEAYjMtZwK1k4haNkcaPg9aoe1a8=
|
||||
github.com/multiformats/go-multicodec v0.5.0 h1:EgU6cBe/D7WRwQb1KmnBvU7lrcFGMggZVTPtOW9dDHs=
|
||||
github.com/multiformats/go-multicodec v0.5.0/go.mod h1:DiY2HFaEp5EhEXb/iYzVAunmyX/aSFMxq2KMKfWEues=
|
||||
github.com/multiformats/go-multihash v0.0.1/go.mod h1:w/5tugSrLEbWqlcgJabL3oHFKTwfvkofsjW2Qa1ct4U=
|
||||
github.com/multiformats/go-multihash v0.0.10/go.mod h1:YSLudS+Pi8NHE7o6tb3D8vrpKa63epEDmG8nTduyAew=
|
||||
github.com/multiformats/go-multicodec v0.4.1 h1:BSJbf+zpghcZMZrwTYBGwy0CPcVZGWiC72Cp8bBd4R4=
|
||||
github.com/multiformats/go-multicodec v0.4.1/go.mod h1:1Hj/eHRaVWSXiSNNfcEPcwZleTmdNP81xlxDLnWU9GQ=
|
||||
github.com/multiformats/go-multihash v0.0.13/go.mod h1:VdAWLKTwram9oKAatUcLxBNUjdtcVwxObEQBtRfuyjc=
|
||||
github.com/multiformats/go-multihash v0.0.14/go.mod h1:VdAWLKTwram9oKAatUcLxBNUjdtcVwxObEQBtRfuyjc=
|
||||
github.com/multiformats/go-multihash v0.0.15/go.mod h1:D6aZrWNLFTV/ynMpKsNtB40mJzmCl4jb1alC0OvHiHg=
|
||||
github.com/multiformats/go-multihash v0.2.1 h1:aem8ZT0VA2nCHHk7bPJ1BjUbHNciqZC/d16Vve9l108=
|
||||
github.com/multiformats/go-multihash v0.2.1/go.mod h1:WxoMcYG85AZVQUyRyo9s4wULvW5qrI9vb2Lt6evduFc=
|
||||
github.com/multiformats/go-multistream v0.3.3 h1:d5PZpjwRgVlbwfdTDjife7XszfZd8KYWfROYFlGcR8o=
|
||||
github.com/multiformats/go-multihash v0.1.0 h1:CgAgwqk3//SVEw3T+6DqI4mWMyRuDwZtOWcJT0q9+EA=
|
||||
github.com/multiformats/go-multihash v0.1.0/go.mod h1:RJlXsxt6vHGaia+S8We0ErjhojtKzPP2AH4+kYM7k84=
|
||||
github.com/multiformats/go-varint v0.0.5/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE=
|
||||
github.com/multiformats/go-varint v0.0.6 h1:gk85QWKxh3TazbLxED/NlDVv8+q+ReFJk7Y2W/KhfNY=
|
||||
github.com/multiformats/go-varint v0.0.6/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE=
|
||||
github.com/nfnt/resize v0.0.0-20160724205520-891127d8d1b5 h1:BvoENQQU+fZ9uukda/RzCAL/191HHwJA5b13R6diVlY=
|
||||
github.com/nfnt/resize v0.0.0-20160724205520-891127d8d1b5/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
|
||||
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
|
||||
github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs=
|
||||
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/polydawn/refmt v0.0.0-20190221155625-df39d6c2d992/go.mod h1:uIp+gprXxxrWSjjklXD+mN4wed/tMfjMMmN/9+JsA9o=
|
||||
github.com/polydawn/refmt v0.0.0-20190807091052-3d65705ee9f1/go.mod h1:uIp+gprXxxrWSjjklXD+mN4wed/tMfjMMmN/9+JsA9o=
|
||||
github.com/polydawn/refmt v0.0.0-20201211092308-30ac6d18308e h1:ZOcivgkkFRnjfoTcGsDq3UQYiBmekwLA+qg0OjyB/ls=
|
||||
github.com/polydawn/refmt v0.0.0-20201211092308-30ac6d18308e/go.mod h1:uIp+gprXxxrWSjjklXD+mN4wed/tMfjMMmN/9+JsA9o=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
github.com/smartystreets/goconvey v0.0.0-20190222223459-a17d461953aa/go.mod h1:2RVY1rIf+2J2o/IM9+vPq9RzmHDSseB7FoXiSNIUsoU=
|
||||
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
|
||||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 h1:RC6RW7j+1+HkWaX/Yh71Ee5ZHaHYt7ZP4sQgUrm6cDU=
|
||||
github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572/go.mod h1:w0SWMsp6j9O/dk4/ZpIhL+3CkG8ofA2vuv7k+ltqUMc=
|
||||
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||
@ -261,16 +110,6 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/warpfork/go-testmark v0.10.0 h1:E86YlUMYfwIacEsQGlnTvjk1IgYkyTGjPhF0RnwTCmw=
|
||||
github.com/warpfork/go-wish v0.0.0-20180510122957-5ad1f5abf436/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw=
|
||||
github.com/warpfork/go-wish v0.0.0-20200122115046-b9ea61034e4a h1:G++j5e0OC488te356JvdhaM8YS6nMsjLAYF7JxCv07w=
|
||||
github.com/warpfork/go-wish v0.0.0-20200122115046-b9ea61034e4a/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw=
|
||||
github.com/whyrusleeping/cbor-gen v0.0.0-20200123233031-1cdf64d27158/go.mod h1:Xj/M2wWU+QdTdRbu/L/1dIZY8/Wb2K9pAhtroQuxJJI=
|
||||
github.com/whyrusleeping/cbor-gen v0.0.0-20220514204315-f29c37e9c44c h1:6VPKXBDRt7mDUyiHx9X8ROnPYFDf3L7OfEuKCI5dZDI=
|
||||
github.com/whyrusleeping/cbor-gen v0.0.0-20220514204315-f29c37e9c44c/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ=
|
||||
github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f h1:jQa4QT2UP9WYv2nzyawpKMOCl+Z/jW7djv2/J50lj9E=
|
||||
github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f/go.mod h1:p9UJB6dDgdPgMJZs7UjUOdulKyRr9fqkS+6JKAInPy8=
|
||||
github.com/whyrusleeping/go-logging v0.0.0-20170515211332-0457bb6b88fc/go.mod h1:bopw91TMyo8J3tvftk8xmU2kPmlrt4nScJQZU2hE5EM=
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
@ -282,60 +121,43 @@ github.com/zeebo/errs v1.2.2 h1:5NFypMTuSdoySVTqlNs1dEoU21QVamMQJxW/Fii5O7g=
|
||||
github.com/zeebo/errs v1.2.2/go.mod h1:sgbWHsvVuTPHcqJJGQ1WhI5KbWlHYz+2+2C/LSEtCw4=
|
||||
github.com/zeebo/pcg v1.0.1 h1:lyqfGeWiv4ahac6ttHs+I5hwtH/+1mrhlCtVNQM2kHo=
|
||||
github.com/zeebo/pcg v1.0.1/go.mod h1:09F0S9iiKrwn9rlI5yjLkmrug154/YRW6KnnXVDM/l4=
|
||||
go.opentelemetry.io/otel v1.9.0 h1:8WZNQFIB2a71LnANS9JeyidJKKGOOremcUtb/OtHISw=
|
||||
go.opentelemetry.io/otel v1.9.0/go.mod h1:np4EoPGzoPs3O67xUVNoPPcmSvsfOxNlNA4F4AC+0Eo=
|
||||
go.opentelemetry.io/otel/trace v1.9.0 h1:oZaCNJUjWcg60VXWee8lJKlqhPbXAPB51URuR47pQYc=
|
||||
go.opentelemetry.io/otel/trace v1.9.0/go.mod h1:2737Q0MuG8q1uILYm2YYVkAyLtOofiTNGg6VODnOiPo=
|
||||
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
||||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||
go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ=
|
||||
go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
|
||||
go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
|
||||
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
|
||||
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
|
||||
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
|
||||
go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
|
||||
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
|
||||
go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8=
|
||||
go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
|
||||
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
|
||||
go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ=
|
||||
go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI=
|
||||
go.uber.org/zap v1.23.0 h1:OjGQ5KQDEUawVHxNwQgPpiypGHOxo2mNZsOqTak4fFY=
|
||||
go.uber.org/zap v1.23.0/go.mod h1:D+nX8jyLsMHMYrln8A0rJjFt/T/9/bGgIhAqxv5URuY=
|
||||
golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8=
|
||||
go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200204104054-c9f3fb736b72/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM=
|
||||
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.0.0-20210506145944-38f3c27a63bf/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
|
||||
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 h1:kUhD7nTDoI3fVd9G4ORWrbV5NY0liEs/Jg2pv5f+bBA=
|
||||
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/image v0.0.0-20200119044424-58c23975cae1 h1:5h3ngYt7+vXCDZCup/HkCQgW5XwmSvR/nA2JmJ0RErg=
|
||||
golang.org/x/image v0.0.0-20200119044424-58c23975cae1/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20190227160552-c95aed5357e7/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||
golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b h1:ZmngSVLe/wycRns9MKikG9OWIEjGcGAkacif7oYQaUY=
|
||||
golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190219092855-153ac476189d/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190302025703-b6889370fb10/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@ -344,23 +166,14 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 h1:v6hYoSR9T5oet+pMXwUWkbiVqx/63mlHjefrHmxwfeY=
|
||||
golang.org/x/sys v0.0.0-20220829200755-d48e67d00261/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 h1:xHms4gcpe1YE7A3yIllJXP16CMAGuqwO2lX1mTyyRRc=
|
||||
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
||||
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
@ -369,28 +182,25 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f h1:uF6paiQQebLeSXkrTqHqz0MXhXXS1KgF41eUdBNvxK0=
|
||||
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8=
|
||||
google.golang.org/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
|
||||
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 h1:VpOs+IwYnYBaFnrNAeB8UUWtL3vEUnzSCL1nVjPhqrw=
|
||||
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
lukechampine.com/blake3 v1.1.7 h1:GgRMhmdsuK8+ii6UZFDL8Nb+VyMwadAgcJyfYHxG6n0=
|
||||
lukechampine.com/blake3 v1.1.7/go.mod h1:tkKEOtDkNtklkXtLNEOGNq5tcV90tJiA1vAA12R78LA=
|
||||
lukechampine.com/blake3 v1.1.6 h1:H3cROdztr7RCfoaTpGZFQsrqvweFLrqS73j7L7cmR5c=
|
||||
lukechampine.com/blake3 v1.1.6/go.mod h1:tkKEOtDkNtklkXtLNEOGNq5tcV90tJiA1vAA12R78LA=
|
||||
storj.io/drpc v0.0.32 h1:5p5ZwsK/VOgapaCu+oxaPVwO6UwIs+iwdMiD50+R4PI=
|
||||
storj.io/drpc v0.0.32/go.mod h1:6rcOyR/QQkSTX/9L5ZGtlZaE2PtXTTZl8d+ulSeeYEg=
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
186
pkg/acl/acltree/aclstatebuilder.go
Normal file
186
pkg/acl/acltree/aclstatebuilder.go
Normal file
@ -0,0 +1,186 @@
|
||||
package acltree
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/account"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/encryptionkey"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey"
|
||||
)
|
||||
|
||||
type aclStateBuilder struct {
|
||||
tree *Tree
|
||||
identity string
|
||||
key encryptionkey.PrivKey
|
||||
decoder signingkey.PubKeyDecoder
|
||||
}
|
||||
|
||||
type decreasedPermissionsParameters struct {
|
||||
users []*aclpb.ACLChange_UserPermissionChange
|
||||
startChange string
|
||||
}
|
||||
|
||||
func newACLStateBuilder(decoder signingkey.PubKeyDecoder, accountData *account.AccountData) *aclStateBuilder {
|
||||
return &aclStateBuilder{
|
||||
decoder: decoder,
|
||||
identity: accountData.Identity,
|
||||
key: accountData.EncKey,
|
||||
}
|
||||
}
|
||||
|
||||
func (sb *aclStateBuilder) Init(tree *Tree) error {
|
||||
sb.tree = tree
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sb *aclStateBuilder) Build() (*ACLState, error) {
|
||||
state, _, err := sb.BuildBefore("")
|
||||
return state, err
|
||||
}
|
||||
|
||||
// TODO: we can probably have only one state builder, because we can Build both at the same time
|
||||
func (sb *aclStateBuilder) BuildBefore(beforeId string) (*ACLState, bool, error) {
|
||||
var (
|
||||
err error
|
||||
startChange = sb.tree.root
|
||||
foundId bool
|
||||
idSeenMap = make(map[string][]*Change)
|
||||
decreasedPermissions *decreasedPermissionsParameters
|
||||
)
|
||||
root := sb.tree.Root()
|
||||
if !root.IsSnapshot {
|
||||
return nil, false, fmt.Errorf("root should always be a snapshot")
|
||||
}
|
||||
|
||||
state, err := newACLStateFromSnapshotChange(
|
||||
root.Content,
|
||||
sb.identity,
|
||||
sb.key,
|
||||
sb.decoder)
|
||||
if err != nil {
|
||||
return nil, false, fmt.Errorf("could not build ACLState from snapshot: %w", err)
|
||||
}
|
||||
|
||||
idSeenMap[startChange.Content.Identity] = append(idSeenMap[startChange.Content.Identity], startChange)
|
||||
|
||||
if startChange.Content.GetChangesData() != nil {
|
||||
key, exists := state.userReadKeys[startChange.Content.CurrentReadKeyHash]
|
||||
if !exists {
|
||||
return nil, false, fmt.Errorf("no first snapshot")
|
||||
}
|
||||
|
||||
err = startChange.DecryptContents(key)
|
||||
if err != nil {
|
||||
return nil, false, fmt.Errorf("failed to decrypt contents of first snapshot")
|
||||
}
|
||||
}
|
||||
|
||||
if beforeId == startChange.Id {
|
||||
return state, true, nil
|
||||
}
|
||||
|
||||
for {
|
||||
// TODO: we should optimize this method to just remember last state of iterator and not iterate from the start and skip if nothing was removed from the Tree
|
||||
sb.tree.IterateSkip(sb.tree.root.Id, startChange.Id, func(c *Change) (isContinue bool) {
|
||||
defer func() {
|
||||
if err == nil {
|
||||
startChange = c
|
||||
} else if err != ErrDocumentForbidden {
|
||||
//log.Errorf("marking change %s as invalid: %v", c.Id, err)
|
||||
sb.tree.RemoveInvalidChange(c.Id)
|
||||
}
|
||||
}()
|
||||
|
||||
// not applying root change
|
||||
if c.Id == startChange.Id {
|
||||
return true
|
||||
}
|
||||
|
||||
idSeenMap[c.Content.Identity] = append(idSeenMap[c.Content.Identity], c)
|
||||
if c.Content.GetAclData() != nil {
|
||||
err = state.applyChange(c.Content)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
// if we have some users who have less permissions now
|
||||
users := state.getPermissionDecreasedUsers(c.Content)
|
||||
if len(users) > 0 {
|
||||
decreasedPermissions = &decreasedPermissionsParameters{
|
||||
users: users,
|
||||
startChange: c.Id,
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// the user can't make changes
|
||||
if !state.hasPermission(c.Content.Identity, aclpb.ACLChange_Writer) && !state.hasPermission(c.Content.Identity, aclpb.ACLChange_Admin) {
|
||||
err = fmt.Errorf("user %s cannot make changes", c.Content.Identity)
|
||||
return false
|
||||
}
|
||||
|
||||
// decrypting contents on the fly
|
||||
if c.Content.GetChangesData() != nil {
|
||||
key, exists := state.userReadKeys[c.Content.CurrentReadKeyHash]
|
||||
if !exists {
|
||||
err = fmt.Errorf("failed to find key with hash: %d", c.Content.CurrentReadKeyHash)
|
||||
return false
|
||||
}
|
||||
|
||||
err = c.DecryptContents(key)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("failed to decrypt contents for hash: %d", c.Content.CurrentReadKeyHash)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if c.Id == beforeId {
|
||||
foundId = true
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
})
|
||||
|
||||
// if we have users with decreased permissions
|
||||
if decreasedPermissions != nil {
|
||||
var removed bool
|
||||
validChanges := sb.tree.dfs(decreasedPermissions.startChange)
|
||||
|
||||
for _, permChange := range decreasedPermissions.users {
|
||||
seenChanges := idSeenMap[permChange.Identity]
|
||||
|
||||
for _, seen := range seenChanges {
|
||||
// if we find some invalid changes
|
||||
if _, exists := validChanges[seen.Id]; !exists {
|
||||
// if the user didn't have enough permission to make changes
|
||||
if seen.IsACLChange() || permChange.Permissions > aclpb.ACLChange_Writer {
|
||||
removed = true
|
||||
sb.tree.RemoveInvalidChange(seen.Id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
decreasedPermissions = nil
|
||||
if removed {
|
||||
// starting from the beginning but with updated Tree
|
||||
return sb.BuildBefore(beforeId)
|
||||
}
|
||||
} else if err == nil {
|
||||
// we can finish the acl state building process
|
||||
break
|
||||
}
|
||||
|
||||
// the user is forbidden to access the document
|
||||
if err == ErrDocumentForbidden {
|
||||
return nil, foundId, err
|
||||
}
|
||||
|
||||
// otherwise we have to continue from the change which we had
|
||||
err = nil
|
||||
}
|
||||
|
||||
return state, foundId, err
|
||||
}
|
||||
97
pkg/acl/acltree/change.go
Normal file
97
pkg/acl/acltree/change.go
Normal file
@ -0,0 +1,97 @@
|
||||
package acltree
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/symmetric"
|
||||
)
|
||||
|
||||
type ChangeContent struct {
|
||||
ChangesData proto.Marshaler
|
||||
ACLData *aclpb.ACLChange_ACLData
|
||||
Id string // TODO: this is just for testing, because id should be created automatically from content
|
||||
}
|
||||
|
||||
// Change is an abstract type for all types of changes
|
||||
type Change struct {
|
||||
Next []*Change
|
||||
Unattached []*Change
|
||||
PreviousIds []string
|
||||
Id string
|
||||
SnapshotId string
|
||||
IsSnapshot bool
|
||||
DecryptedDocumentChange []byte
|
||||
|
||||
Content *aclpb.ACLChange
|
||||
Sign []byte
|
||||
}
|
||||
|
||||
func (ch *Change) DecryptContents(key *symmetric.Key) error {
|
||||
if ch.Content.ChangesData == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
decrypted, err := key.Decrypt(ch.Content.ChangesData)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to decrypt changes data: %w", err)
|
||||
}
|
||||
|
||||
ch.DecryptedDocumentChange = decrypted
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ch *Change) IsACLChange() bool {
|
||||
return ch.Content.GetAclData() != nil
|
||||
}
|
||||
|
||||
func NewFromRawChange(rawChange *aclpb.RawChange) (*Change, error) {
|
||||
unmarshalled := &aclpb.ACLChange{}
|
||||
err := proto.Unmarshal(rawChange.Payload, unmarshalled)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ch := NewChange(rawChange.Id, unmarshalled)
|
||||
ch.Sign = rawChange.Signature
|
||||
return ch, nil
|
||||
}
|
||||
|
||||
func NewChange(id string, ch *aclpb.ACLChange) *Change {
|
||||
return &Change{
|
||||
Next: nil,
|
||||
PreviousIds: ch.TreeHeadIds,
|
||||
Id: id,
|
||||
Content: ch,
|
||||
SnapshotId: ch.SnapshotBaseId,
|
||||
IsSnapshot: ch.GetAclData().GetAclSnapshot() != nil,
|
||||
}
|
||||
}
|
||||
|
||||
func NewACLChange(id string, ch *aclpb.ACLChange) *Change {
|
||||
return &Change{
|
||||
Next: nil,
|
||||
PreviousIds: ch.AclHeadIds,
|
||||
Id: id,
|
||||
Content: ch,
|
||||
SnapshotId: ch.SnapshotBaseId,
|
||||
IsSnapshot: ch.GetAclData().GetAclSnapshot() != nil,
|
||||
}
|
||||
}
|
||||
|
||||
func (ch *Change) ProtoChange() *aclpb.ACLChange {
|
||||
return ch.Content
|
||||
}
|
||||
|
||||
func (ch *Change) DecryptedChangeContent() []byte {
|
||||
return ch.DecryptedDocumentChange
|
||||
}
|
||||
|
||||
func (ch *Change) Signature() []byte {
|
||||
return ch.Sign
|
||||
}
|
||||
|
||||
func (ch *Change) CID() string {
|
||||
return ch.Id
|
||||
}
|
||||
169
pkg/acl/example/plaintextdocument/document.go
Normal file
169
pkg/acl/example/plaintextdocument/document.go
Normal file
@ -0,0 +1,169 @@
|
||||
package plaintextdocument
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/account"
|
||||
aclpb "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/acltree"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/testutils/testchanges/testchangepb"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treestorage"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
)
|
||||
|
||||
type PlainTextDocument interface {
|
||||
Text() string
|
||||
AddText(ctx context.Context, text string) error
|
||||
}
|
||||
|
||||
// TODO: this struct is not thread-safe, so use it wisely :-)
|
||||
type plainTextDocument struct {
|
||||
heads []string
|
||||
aclTree acltree.ACLTree
|
||||
state *DocumentState
|
||||
}
|
||||
|
||||
func (p *plainTextDocument) Text() string {
|
||||
if p.state != nil {
|
||||
return p.state.Text
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (p *plainTextDocument) AddText(ctx context.Context, text string) error {
|
||||
_, err := p.aclTree.AddContent(ctx, func(builder acltree.ChangeBuilder) error {
|
||||
builder.AddChangeContent(
|
||||
&testchangepb.PlainTextChange_Data{
|
||||
Content: []*testchangepb.PlainTextChange_Content{
|
||||
createAppendTextChangeContent(text),
|
||||
},
|
||||
})
|
||||
return nil
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *plainTextDocument) Update(tree acltree.ACLTree) {
|
||||
p.aclTree = tree
|
||||
var err error
|
||||
defer func() {
|
||||
if err != nil {
|
||||
fmt.Println("rebuild has returned error:", err)
|
||||
}
|
||||
}()
|
||||
|
||||
prevHeads := p.heads
|
||||
p.heads = tree.Heads()
|
||||
startId := prevHeads[0]
|
||||
tree.IterateFrom(startId, func(change *acltree.Change) (isContinue bool) {
|
||||
if change.Id == startId {
|
||||
return true
|
||||
}
|
||||
if change.DecryptedDocumentChange != nil {
|
||||
p.state, err = p.state.ApplyChange(change.DecryptedDocumentChange, change.Id)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
func (p *plainTextDocument) Rebuild(tree acltree.ACLTree) {
|
||||
p.aclTree = tree
|
||||
p.heads = tree.Heads()
|
||||
var startId string
|
||||
var err error
|
||||
defer func() {
|
||||
if err != nil {
|
||||
fmt.Println("rebuild has returned error:", err)
|
||||
}
|
||||
}()
|
||||
|
||||
rootChange := tree.Root()
|
||||
|
||||
if rootChange.DecryptedDocumentChange == nil {
|
||||
err = fmt.Errorf("root doesn't have decrypted change")
|
||||
return
|
||||
}
|
||||
|
||||
state, err := BuildDocumentStateFromChange(rootChange.DecryptedDocumentChange, rootChange.Id)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
startId = rootChange.Id
|
||||
tree.Iterate(func(change *acltree.Change) (isContinue bool) {
|
||||
if startId == change.Id {
|
||||
return true
|
||||
}
|
||||
if change.DecryptedDocumentChange != nil {
|
||||
state, err = state.ApplyChange(change.DecryptedDocumentChange, change.Id)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
p.state = state
|
||||
}
|
||||
|
||||
func NewInMemoryPlainTextDocument(acc *account.AccountData, text string) (PlainTextDocument, error) {
|
||||
return NewPlainTextDocument(acc, treestorage.NewInMemoryTreeStorage, text)
|
||||
}
|
||||
|
||||
func NewPlainTextDocument(
|
||||
acc *account.AccountData,
|
||||
create treestorage.CreatorFunc,
|
||||
text string) (PlainTextDocument, error) {
|
||||
changeBuilder := func(builder acltree.ChangeBuilder) error {
|
||||
err := builder.UserAdd(acc.Identity, acc.EncKey.GetPublic(), aclpb.ACLChange_Admin)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
builder.AddChangeContent(createInitialChangeContent(text))
|
||||
return nil
|
||||
}
|
||||
t, err := acltree.CreateNewTreeStorageWithACL(
|
||||
acc,
|
||||
changeBuilder,
|
||||
create)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
doc := &plainTextDocument{
|
||||
heads: nil,
|
||||
aclTree: nil,
|
||||
state: nil,
|
||||
}
|
||||
tree, err := acltree.BuildACLTree(t, acc, doc)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
doc.aclTree = tree
|
||||
return doc, nil
|
||||
}
|
||||
|
||||
func createInitialChangeContent(text string) proto.Marshaler {
|
||||
return &testchangepb.PlainTextChange_Data{
|
||||
Content: []*testchangepb.PlainTextChange_Content{
|
||||
createAppendTextChangeContent(text),
|
||||
},
|
||||
Snapshot: &testchangepb.PlainTextChange_Snapshot{Text: text},
|
||||
}
|
||||
}
|
||||
|
||||
func createAppendTextChangeContent(text string) *testchangepb.PlainTextChange_Content {
|
||||
return &testchangepb.PlainTextChange_Content{
|
||||
Value: &testchangepb.PlainTextChange_Content_TextAppend{
|
||||
TextAppend: &testchangepb.PlainTextChange_TextAppend{
|
||||
Text: text,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
59
pkg/acl/example/plaintextdocument/plaintextdocstate.go
Normal file
59
pkg/acl/example/plaintextdocument/plaintextdocstate.go
Normal file
@ -0,0 +1,59 @@
|
||||
package plaintextdocument
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/testutils/testchanges/testchangepb"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
)
|
||||
|
||||
type DocumentState struct {
|
||||
LastChangeId string
|
||||
Text string
|
||||
}
|
||||
|
||||
func NewDocumentState(text string, id string) *DocumentState {
|
||||
return &DocumentState{
|
||||
LastChangeId: id,
|
||||
Text: text,
|
||||
}
|
||||
}
|
||||
|
||||
func BuildDocumentStateFromChange(change []byte, id string) (*DocumentState, error) {
|
||||
var changesData testchangepb.PlainTextChange_Data
|
||||
err := proto.Unmarshal(change, &changesData)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if changesData.GetSnapshot() == nil {
|
||||
return nil, fmt.Errorf("could not create state from empty snapshot")
|
||||
}
|
||||
return NewDocumentState(changesData.GetSnapshot().GetText(), id), nil
|
||||
}
|
||||
|
||||
func (p *DocumentState) ApplyChange(change []byte, id string) (*DocumentState, error) {
|
||||
var changesData testchangepb.PlainTextChange_Data
|
||||
err := proto.Unmarshal(change, &changesData)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, content := range changesData.GetContent() {
|
||||
err = p.applyChange(content)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
p.LastChangeId = id
|
||||
return p, nil
|
||||
}
|
||||
|
||||
func (p *DocumentState) applyChange(ch *testchangepb.PlainTextChange_Content) error {
|
||||
switch {
|
||||
case ch.GetTextAppend() != nil:
|
||||
text := ch.GetTextAppend().GetText()
|
||||
p.Text += "|" + text
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -1,189 +1,135 @@
|
||||
package list
|
||||
package acltree
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/common"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/encryptionkey"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/symmetric"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"go.uber.org/zap"
|
||||
"hash/fnv"
|
||||
)
|
||||
|
||||
var log = logger.NewNamed("acllist").Sugar()
|
||||
|
||||
var ErrNoSuchUser = errors.New("no such user")
|
||||
var ErrFailedToDecrypt = errors.New("failed to decrypt key")
|
||||
var ErrUserRemoved = errors.New("user was removed from the document")
|
||||
var ErrDocumentForbidden = errors.New("your user was forbidden access to the document")
|
||||
var ErrUserAlreadyExists = errors.New("user already exists")
|
||||
var ErrNoSuchRecord = errors.New("no such record")
|
||||
var ErrInsufficientPermissions = errors.New("insufficient permissions")
|
||||
var ErrNoReadKey = errors.New("acl state doesn't have a read key")
|
||||
var ErrInvalidSignature = errors.New("signature is invalid")
|
||||
|
||||
type UserPermissionPair struct {
|
||||
Identity string
|
||||
Permission aclpb.ACLChangeUserPermissions
|
||||
}
|
||||
|
||||
type ACLState struct {
|
||||
currentReadKeyHash uint64
|
||||
userReadKeys map[uint64]*symmetric.Key
|
||||
userStates map[string]*aclpb.ACLChangeUserState
|
||||
userInvites map[string]*aclpb.ACLChangeUserInvite
|
||||
|
||||
signingPubKeyDecoder keys.Decoder
|
||||
userStates map[string]*aclpb.ACLChange_UserState
|
||||
userInvites map[string]*aclpb.ACLChange_UserInvite
|
||||
signingPubKeyDecoder signingkey.PubKeyDecoder
|
||||
encryptionKey encryptionkey.PrivKey
|
||||
|
||||
identity string
|
||||
permissionsAtRecord map[string][]UserPermissionPair
|
||||
|
||||
keychain *common.Keychain
|
||||
}
|
||||
|
||||
func newACLStateWithIdentity(
|
||||
func newACLState(
|
||||
identity string,
|
||||
encryptionKey encryptionkey.PrivKey,
|
||||
decoder keys.Decoder) *ACLState {
|
||||
signingPubKeyDecoder signingkey.PubKeyDecoder) *ACLState {
|
||||
return &ACLState{
|
||||
identity: identity,
|
||||
encryptionKey: encryptionKey,
|
||||
userReadKeys: make(map[uint64]*symmetric.Key),
|
||||
userStates: make(map[string]*aclpb.ACLChangeUserState),
|
||||
userInvites: make(map[string]*aclpb.ACLChangeUserInvite),
|
||||
signingPubKeyDecoder: decoder,
|
||||
permissionsAtRecord: make(map[string][]UserPermissionPair),
|
||||
keychain: common.NewKeychain(),
|
||||
userStates: make(map[string]*aclpb.ACLChange_UserState),
|
||||
userInvites: make(map[string]*aclpb.ACLChange_UserInvite),
|
||||
signingPubKeyDecoder: signingPubKeyDecoder,
|
||||
}
|
||||
}
|
||||
|
||||
func newACLState(decoder keys.Decoder) *ACLState {
|
||||
return &ACLState{
|
||||
signingPubKeyDecoder: decoder,
|
||||
func newACLStateFromSnapshotChange(
|
||||
snapshotChange *aclpb.ACLChange,
|
||||
identity string,
|
||||
encryptionKey encryptionkey.PrivKey,
|
||||
signingPubKeyDecoder signingkey.PubKeyDecoder) (*ACLState, error) {
|
||||
st := &ACLState{
|
||||
identity: identity,
|
||||
encryptionKey: encryptionKey,
|
||||
userReadKeys: make(map[uint64]*symmetric.Key),
|
||||
userStates: make(map[string]*aclpb.ACLChangeUserState),
|
||||
userInvites: make(map[string]*aclpb.ACLChangeUserInvite),
|
||||
permissionsAtRecord: make(map[string][]UserPermissionPair),
|
||||
keychain: common.NewKeychain(),
|
||||
userStates: make(map[string]*aclpb.ACLChange_UserState),
|
||||
userInvites: make(map[string]*aclpb.ACLChange_UserInvite),
|
||||
signingPubKeyDecoder: signingPubKeyDecoder,
|
||||
}
|
||||
err := st.recreateFromSnapshotChange(snapshotChange)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return st, nil
|
||||
}
|
||||
|
||||
func (st *ACLState) CurrentReadKeyHash() uint64 {
|
||||
return st.currentReadKeyHash
|
||||
func (st *ACLState) recreateFromSnapshotChange(snapshotChange *aclpb.ACLChange) error {
|
||||
snapshot := snapshotChange.GetAclData().GetAclSnapshot()
|
||||
if snapshot == nil {
|
||||
return fmt.Errorf("could not create state from snapshot, because it is nil")
|
||||
}
|
||||
state := snapshot.AclState
|
||||
for _, userState := range state.UserStates {
|
||||
st.userStates[userState.Identity] = userState
|
||||
}
|
||||
|
||||
func (st *ACLState) CurrentReadKey() (*symmetric.Key, error) {
|
||||
key, exists := st.userReadKeys[st.currentReadKeyHash]
|
||||
userState, exists := st.userStates[st.identity]
|
||||
if !exists {
|
||||
return nil, ErrNoReadKey
|
||||
return ErrNoSuchUser
|
||||
}
|
||||
return key, nil
|
||||
}
|
||||
|
||||
func (st *ACLState) UserReadKeys() map[uint64]*symmetric.Key {
|
||||
return st.userReadKeys
|
||||
}
|
||||
|
||||
func (st *ACLState) PermissionsAtRecord(id string, identity string) (UserPermissionPair, error) {
|
||||
permissions, ok := st.permissionsAtRecord[id]
|
||||
if !ok {
|
||||
log.Errorf("missing record at id %s", id)
|
||||
return UserPermissionPair{}, ErrNoSuchRecord
|
||||
}
|
||||
|
||||
for _, perm := range permissions {
|
||||
if perm.Identity == identity {
|
||||
return perm, nil
|
||||
}
|
||||
}
|
||||
return UserPermissionPair{}, ErrNoSuchUser
|
||||
}
|
||||
|
||||
func (st *ACLState) applyRecord(record *aclpb.Record) (err error) {
|
||||
aclData := &aclpb.ACLChangeACLData{}
|
||||
|
||||
err = proto.Unmarshal(record.Data, aclData)
|
||||
for _, key := range userState.EncryptedReadKeys {
|
||||
key, hash, err := st.decryptReadKeyAndHash(key)
|
||||
if err != nil {
|
||||
return
|
||||
return ErrFailedToDecrypt
|
||||
}
|
||||
|
||||
err = st.applyChangeData(aclData, record.CurrentReadKeyHash, record.Identity)
|
||||
if err != nil {
|
||||
return
|
||||
st.userReadKeys[hash] = key
|
||||
}
|
||||
|
||||
st.currentReadKeyHash = record.CurrentReadKeyHash
|
||||
return
|
||||
st.currentReadKeyHash = snapshotChange.CurrentReadKeyHash
|
||||
if snapshot.GetAclState().GetInvites() != nil {
|
||||
st.userInvites = snapshot.GetAclState().GetInvites()
|
||||
}
|
||||
|
||||
func (st *ACLState) applyChangeAndUpdate(recordWrapper *Record) (err error) {
|
||||
var (
|
||||
change = recordWrapper.Content
|
||||
aclData = &aclpb.ACLChangeACLData{}
|
||||
)
|
||||
|
||||
if recordWrapper.Model != nil {
|
||||
aclData = recordWrapper.Model.(*aclpb.ACLChangeACLData)
|
||||
} else {
|
||||
err = proto.Unmarshal(change.Data, aclData)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
recordWrapper.Model = aclData
|
||||
}
|
||||
|
||||
err = st.applyChangeData(aclData, recordWrapper.Content.CurrentReadKeyHash, recordWrapper.Content.Identity)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// getting all permissions for users at record
|
||||
var permissions []UserPermissionPair
|
||||
for _, state := range st.userStates {
|
||||
permission := UserPermissionPair{
|
||||
Identity: state.Identity,
|
||||
Permission: state.Permissions,
|
||||
}
|
||||
permissions = append(permissions, permission)
|
||||
}
|
||||
|
||||
st.permissionsAtRecord[recordWrapper.Id] = permissions
|
||||
return nil
|
||||
}
|
||||
|
||||
func (st *ACLState) applyChangeData(changeData *aclpb.ACLChangeACLData, hash uint64, identity string) (err error) {
|
||||
func (st *ACLState) makeSnapshot() *aclpb.ACLChange_ACLSnapshot {
|
||||
var userStates []*aclpb.ACLChange_UserState
|
||||
for _, st := range st.userStates {
|
||||
userStates = append(userStates, st)
|
||||
}
|
||||
|
||||
return &aclpb.ACLChange_ACLSnapshot{AclState: &aclpb.ACLChange_ACLState{
|
||||
ReadKeyHashes: nil,
|
||||
UserStates: userStates, // TODO: make states and invites in same format
|
||||
Invites: st.userInvites,
|
||||
}}
|
||||
}
|
||||
|
||||
func (st *ACLState) applyChange(change *aclpb.ACLChange) (err error) {
|
||||
defer func() {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
st.currentReadKeyHash = hash
|
||||
st.currentReadKeyHash = change.CurrentReadKeyHash
|
||||
}()
|
||||
|
||||
// we can't check this for the user which is joining, because it will not be in our list
|
||||
// the same is for the first change to be added
|
||||
skipIdentityCheck := st.isUserJoin(changeData) || (st.currentReadKeyHash == 0 && st.isUserAdd(changeData, identity))
|
||||
skipIdentityCheck := st.isUserJoin(change) || (st.currentReadKeyHash == 0 && st.isUserAdd(change))
|
||||
if !skipIdentityCheck {
|
||||
// we check signature when we add this to the Tree, so no need to do it here
|
||||
if _, exists := st.userStates[identity]; !exists {
|
||||
if _, exists := st.userStates[change.Identity]; !exists {
|
||||
err = ErrNoSuchUser
|
||||
return
|
||||
}
|
||||
|
||||
if !st.hasPermission(identity, aclpb.ACLChange_Admin) {
|
||||
err = fmt.Errorf("user %s must have admin permissions", identity)
|
||||
if !st.hasPermission(change.Identity, aclpb.ACLChange_Admin) {
|
||||
err = fmt.Errorf("user %s must have admin permissions", change.Identity)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
for _, ch := range changeData.GetAclContent() {
|
||||
for _, ch := range change.GetAclData().GetAclContent() {
|
||||
if err = st.applyChangeContent(ch); err != nil {
|
||||
log.Info("error while applying changes: %v; ignore", zap.Error(err))
|
||||
//log.Infof("error while applying changes: %v; ignore", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -191,7 +137,8 @@ func (st *ACLState) applyChangeData(changeData *aclpb.ACLChangeACLData, hash uin
|
||||
return nil
|
||||
}
|
||||
|
||||
func (st *ACLState) applyChangeContent(ch *aclpb.ACLChangeACLContentValue) error {
|
||||
// TODO: remove changeId, because it is not needed
|
||||
func (st *ACLState) applyChangeContent(ch *aclpb.ACLChange_ACLContentValue) error {
|
||||
switch {
|
||||
case ch.GetUserPermissionChange() != nil:
|
||||
return st.applyUserPermissionChange(ch.GetUserPermissionChange())
|
||||
@ -210,7 +157,7 @@ func (st *ACLState) applyChangeContent(ch *aclpb.ACLChangeACLContentValue) error
|
||||
}
|
||||
}
|
||||
|
||||
func (st *ACLState) applyUserPermissionChange(ch *aclpb.ACLChangeUserPermissionChange) error {
|
||||
func (st *ACLState) applyUserPermissionChange(ch *aclpb.ACLChange_UserPermissionChange) error {
|
||||
if _, exists := st.userStates[ch.Identity]; !exists {
|
||||
return ErrNoSuchUser
|
||||
}
|
||||
@ -219,12 +166,12 @@ func (st *ACLState) applyUserPermissionChange(ch *aclpb.ACLChangeUserPermissionC
|
||||
return nil
|
||||
}
|
||||
|
||||
func (st *ACLState) applyUserInvite(ch *aclpb.ACLChangeUserInvite) error {
|
||||
func (st *ACLState) applyUserInvite(ch *aclpb.ACLChange_UserInvite) error {
|
||||
st.userInvites[ch.InviteId] = ch
|
||||
return nil
|
||||
}
|
||||
|
||||
func (st *ACLState) applyUserJoin(ch *aclpb.ACLChangeUserJoin) error {
|
||||
func (st *ACLState) applyUserJoin(ch *aclpb.ACLChange_UserJoin) error {
|
||||
invite, exists := st.userInvites[ch.UserInviteId]
|
||||
if !exists {
|
||||
return fmt.Errorf("no such invite with id %s", ch.UserInviteId)
|
||||
@ -246,12 +193,12 @@ func (st *ACLState) applyUserJoin(ch *aclpb.ACLChangeUserJoin) error {
|
||||
return fmt.Errorf("failed to decode signing identity as bytes")
|
||||
}
|
||||
|
||||
res, err := verificationKey.(signingkey.PubKey).Verify(rawSignedId, signature)
|
||||
res, err := verificationKey.Verify(rawSignedId, signature)
|
||||
if err != nil {
|
||||
return fmt.Errorf("verification returned error: %w", err)
|
||||
}
|
||||
if !res {
|
||||
return ErrInvalidSignature
|
||||
return fmt.Errorf("signature is invalid")
|
||||
}
|
||||
|
||||
// if ourselves -> we need to decrypt the read keys
|
||||
@ -267,7 +214,7 @@ func (st *ACLState) applyUserJoin(ch *aclpb.ACLChangeUserJoin) error {
|
||||
}
|
||||
|
||||
// adding user to the list
|
||||
userState := &aclpb.ACLChangeUserState{
|
||||
userState := &aclpb.ACLChange_UserState{
|
||||
Identity: ch.Identity,
|
||||
EncryptionKey: ch.EncryptionKey,
|
||||
EncryptedReadKeys: ch.EncryptedReadKeys,
|
||||
@ -278,12 +225,12 @@ func (st *ACLState) applyUserJoin(ch *aclpb.ACLChangeUserJoin) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (st *ACLState) applyUserAdd(ch *aclpb.ACLChangeUserAdd) error {
|
||||
func (st *ACLState) applyUserAdd(ch *aclpb.ACLChange_UserAdd) error {
|
||||
if _, exists := st.userStates[ch.Identity]; exists {
|
||||
return ErrUserAlreadyExists
|
||||
}
|
||||
|
||||
st.userStates[ch.Identity] = &aclpb.ACLChangeUserState{
|
||||
st.userStates[ch.Identity] = &aclpb.ACLChange_UserState{
|
||||
Identity: ch.Identity,
|
||||
EncryptionKey: ch.EncryptionKey,
|
||||
Permissions: ch.Permissions,
|
||||
@ -304,7 +251,7 @@ func (st *ACLState) applyUserAdd(ch *aclpb.ACLChangeUserAdd) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (st *ACLState) applyUserRemove(ch *aclpb.ACLChangeUserRemove) error {
|
||||
func (st *ACLState) applyUserRemove(ch *aclpb.ACLChange_UserRemove) error {
|
||||
if ch.Identity == st.identity {
|
||||
return ErrDocumentForbidden
|
||||
}
|
||||
@ -336,7 +283,7 @@ func (st *ACLState) applyUserRemove(ch *aclpb.ACLChangeUserRemove) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (st *ACLState) applyUserConfirm(ch *aclpb.ACLChangeUserConfirm) error {
|
||||
func (st *ACLState) applyUserConfirm(ch *aclpb.ACLChange_UserConfirm) error {
|
||||
if _, exists := st.userStates[ch.Identity]; !exists {
|
||||
return ErrNoSuchUser
|
||||
}
|
||||
@ -362,7 +309,7 @@ func (st *ACLState) decryptReadKeyAndHash(msg []byte) (*symmetric.Key, uint64, e
|
||||
return key, hasher.Sum64(), nil
|
||||
}
|
||||
|
||||
func (st *ACLState) hasPermission(identity string, permission aclpb.ACLChangeUserPermissions) bool {
|
||||
func (st *ACLState) hasPermission(identity string, permission aclpb.ACLChange_UserPermissions) bool {
|
||||
state, exists := st.userStates[identity]
|
||||
if !exists {
|
||||
return false
|
||||
@ -371,17 +318,94 @@ func (st *ACLState) hasPermission(identity string, permission aclpb.ACLChangeUse
|
||||
return state.Permissions == permission
|
||||
}
|
||||
|
||||
func (st *ACLState) isUserJoin(data *aclpb.ACLChangeACLData) bool {
|
||||
func (st *ACLState) isUserJoin(ch *aclpb.ACLChange) bool {
|
||||
// if we have a UserJoin, then it should always be the first one applied
|
||||
return data.GetAclContent() != nil && data.GetAclContent()[0].GetUserJoin() != nil
|
||||
return ch.AclData.GetAclContent() != nil && ch.AclData.GetAclContent()[0].GetUserJoin() != nil
|
||||
}
|
||||
|
||||
func (st *ACLState) isUserAdd(data *aclpb.ACLChangeACLData, identity string) bool {
|
||||
func (st *ACLState) isUserAdd(ch *aclpb.ACLChange) bool {
|
||||
// if we have a UserAdd, then it should always be the first one applied
|
||||
userAdd := data.GetAclContent()[0].GetUserAdd()
|
||||
return data.GetAclContent() != nil && userAdd != nil && userAdd.GetIdentity() == identity
|
||||
userAdd := ch.AclData.GetAclContent()[0].GetUserAdd()
|
||||
return ch.AclData.GetAclContent() != nil && userAdd != nil && userAdd.GetIdentity() == ch.Identity
|
||||
}
|
||||
|
||||
func (st *ACLState) GetUserStates() map[string]*aclpb.ACLChangeUserState {
|
||||
func (st *ACLState) getPermissionDecreasedUsers(ch *aclpb.ACLChange) (identities []*aclpb.ACLChange_UserPermissionChange) {
|
||||
// this should be called after general checks are completed
|
||||
if ch.GetAclData().GetAclContent() == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
contents := ch.GetAclData().GetAclContent()
|
||||
for _, c := range contents {
|
||||
if c.GetUserPermissionChange() != nil {
|
||||
content := c.GetUserPermissionChange()
|
||||
|
||||
currentState := st.userStates[content.Identity]
|
||||
// the comparison works in different direction :-)
|
||||
if content.Permissions > currentState.Permissions {
|
||||
identities = append(identities, &aclpb.ACLChange_UserPermissionChange{
|
||||
Identity: content.Identity,
|
||||
Permissions: content.Permissions,
|
||||
})
|
||||
}
|
||||
}
|
||||
if c.GetUserRemove() != nil {
|
||||
content := c.GetUserRemove()
|
||||
identities = append(identities, &aclpb.ACLChange_UserPermissionChange{
|
||||
Identity: content.Identity,
|
||||
Permissions: aclpb.ACLChange_Removed,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return identities
|
||||
}
|
||||
|
||||
func (st *ACLState) equal(other *ACLState) bool {
|
||||
if st == nil && other == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
if st == nil || other == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
if st.currentReadKeyHash != other.currentReadKeyHash {
|
||||
return false
|
||||
}
|
||||
|
||||
if st.identity != other.identity {
|
||||
return false
|
||||
}
|
||||
|
||||
if len(st.userStates) != len(other.userStates) {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, st := range st.userStates {
|
||||
otherSt, exists := other.userStates[st.Identity]
|
||||
if !exists {
|
||||
return false
|
||||
}
|
||||
|
||||
if st.Permissions != otherSt.Permissions {
|
||||
return false
|
||||
}
|
||||
|
||||
if bytes.Compare(st.EncryptionKey, otherSt.EncryptionKey) != 0 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if len(st.userInvites) != len(other.userInvites) {
|
||||
return false
|
||||
}
|
||||
|
||||
// TODO: add detailed user invites comparison + compare other stuff
|
||||
return true
|
||||
}
|
||||
|
||||
func (st *ACLState) GetUserStates() map[string]*aclpb.ACLChange_UserState {
|
||||
// TODO: we should provide better API that would not allow to change this map from the outside
|
||||
return st.userStates
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package list
|
||||
package acltree
|
||||
|
||||
import (
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/account"
|
||||
@ -14,31 +14,39 @@ import (
|
||||
type MarshalledChange = []byte
|
||||
|
||||
type ACLChangeBuilder interface {
|
||||
UserAdd(identity string, encryptionKey encryptionkey.PubKey, permissions aclpb.ACLChangeUserPermissions) error
|
||||
UserAdd(identity string, encryptionKey encryptionkey.PubKey, permissions aclpb.ACLChange_UserPermissions) error
|
||||
AddId(id string) // TODO: this is only for testing
|
||||
SetMakeSnapshot(bool) // TODO: who should decide this? probably ACLTree so we can delete it
|
||||
}
|
||||
|
||||
type aclChangeBuilder struct {
|
||||
type ChangeBuilder interface {
|
||||
ACLChangeBuilder
|
||||
AddChangeContent(marshaler proto.Marshaler) // user code should be responsible for making regular snapshots
|
||||
}
|
||||
|
||||
type changeBuilder struct {
|
||||
aclState *ACLState
|
||||
list ACLList
|
||||
tree *Tree
|
||||
acc *account.AccountData
|
||||
|
||||
aclData *aclpb.ACLChangeACLData
|
||||
aclData *aclpb.ACLChange_ACLData
|
||||
changeContent proto.Marshaler
|
||||
id string
|
||||
makeSnapshot bool
|
||||
readKey *symmetric.Key
|
||||
readKeyHash uint64
|
||||
}
|
||||
|
||||
func newACLChangeBuilder() *aclChangeBuilder {
|
||||
return &aclChangeBuilder{}
|
||||
func newChangeBuilder() *changeBuilder {
|
||||
return &changeBuilder{}
|
||||
}
|
||||
|
||||
func (c *aclChangeBuilder) Init(state *ACLState, list ACLList, acc *account.AccountData) {
|
||||
func (c *changeBuilder) Init(state *ACLState, tree *Tree, acc *account.AccountData) {
|
||||
c.aclState = state
|
||||
c.list = list
|
||||
c.tree = tree
|
||||
c.acc = acc
|
||||
|
||||
c.aclData = &aclpb.ACLChangeACLData{}
|
||||
c.aclData = &aclpb.ACLChange_ACLData{}
|
||||
// setting read key for further encryption etc
|
||||
if state.currentReadKeyHash == 0 {
|
||||
c.readKey, _ = symmetric.NewRandom()
|
||||
@ -52,11 +60,15 @@ func (c *aclChangeBuilder) Init(state *ACLState, list ACLList, acc *account.Acco
|
||||
}
|
||||
}
|
||||
|
||||
func (c *aclChangeBuilder) AddId(id string) {
|
||||
func (c *changeBuilder) AddId(id string) {
|
||||
c.id = id
|
||||
}
|
||||
|
||||
func (c *aclChangeBuilder) UserAdd(identity string, encryptionKey encryptionkey.PubKey, permissions aclpb.ACLChangeUserPermissions) error {
|
||||
func (c *changeBuilder) SetMakeSnapshot(b bool) {
|
||||
c.makeSnapshot = b
|
||||
}
|
||||
|
||||
func (c *changeBuilder) UserAdd(identity string, encryptionKey encryptionkey.PubKey, permissions aclpb.ACLChange_UserPermissions) error {
|
||||
var allKeys []*symmetric.Key
|
||||
if c.aclState.currentReadKeyHash != 0 {
|
||||
for _, key := range c.aclState.userReadKeys {
|
||||
@ -79,9 +91,9 @@ func (c *aclChangeBuilder) UserAdd(identity string, encryptionKey encryptionkey.
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ch := &aclpb.ACLChangeACLContentValue{
|
||||
Value: &aclpb.ACLChangeACLContentValueValueOfUserAdd{
|
||||
UserAdd: &aclpb.ACLChangeUserAdd{
|
||||
ch := &aclpb.ACLChange_ACLContentValue{
|
||||
Value: &aclpb.ACLChange_ACLContent_Value_UserAdd{
|
||||
UserAdd: &aclpb.ACLChange_UserAdd{
|
||||
Identity: identity,
|
||||
EncryptionKey: rawKey,
|
||||
EncryptedReadKeys: encryptedKeys,
|
||||
@ -93,25 +105,41 @@ func (c *aclChangeBuilder) UserAdd(identity string, encryptionKey encryptionkey.
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *aclChangeBuilder) BuildAndApply() (*Record, []byte, error) {
|
||||
aclRecord := &aclpb.Record{
|
||||
PrevId: c.list.Head().Id,
|
||||
func (c *changeBuilder) BuildAndApply() (*Change, []byte, error) {
|
||||
aclChange := &aclpb.ACLChange{
|
||||
TreeHeadIds: c.tree.Heads(),
|
||||
AclHeadIds: c.tree.ACLHeads(),
|
||||
SnapshotBaseId: c.tree.RootId(),
|
||||
AclData: c.aclData,
|
||||
CurrentReadKeyHash: c.readKeyHash,
|
||||
Timestamp: int64(time.Now().Nanosecond()),
|
||||
Identity: c.acc.Identity,
|
||||
}
|
||||
|
||||
marshalledData, err := proto.Marshal(c.aclData)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
aclRecord.Data = marshalledData
|
||||
err = c.aclState.applyRecord(aclRecord)
|
||||
err := c.aclState.applyChange(aclChange)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
fullMarshalledChange, err := proto.Marshal(aclRecord)
|
||||
if c.makeSnapshot {
|
||||
c.aclData.AclSnapshot = c.aclState.makeSnapshot()
|
||||
}
|
||||
|
||||
var marshalled []byte
|
||||
if c.changeContent != nil {
|
||||
marshalled, err = c.changeContent.Marshal()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
encrypted, err := c.aclState.userReadKeys[c.aclState.currentReadKeyHash].
|
||||
Encrypt(marshalled)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
aclChange.ChangesData = encrypted
|
||||
}
|
||||
|
||||
fullMarshalledChange, err := proto.Marshal(aclChange)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@ -123,9 +151,13 @@ func (c *aclChangeBuilder) BuildAndApply() (*Record, []byte, error) {
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
ch := NewRecord(id, aclRecord)
|
||||
ch.Model = c.aclData
|
||||
ch := NewChange(id, aclChange)
|
||||
ch.DecryptedDocumentChange = marshalled
|
||||
ch.Sign = signature
|
||||
|
||||
return ch, fullMarshalledChange, nil
|
||||
}
|
||||
|
||||
func (c *changeBuilder) AddChangeContent(marshaler proto.Marshaler) {
|
||||
c.changeContent = marshaler
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: pkg/acl/testutils/testchanges/proto/test.proto
|
||||
// source: pkg/acl/testutils/testchanges/testchangepb/protos/testdocumentchanges.proto
|
||||
|
||||
package testchanges
|
||||
package testchangepb
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
@ -29,7 +29,7 @@ func (m *PlainTextChange) Reset() { *m = PlainTextChange{} }
|
||||
func (m *PlainTextChange) String() string { return proto.CompactTextString(m) }
|
||||
func (*PlainTextChange) ProtoMessage() {}
|
||||
func (*PlainTextChange) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_37f33c266ada4318, []int{0}
|
||||
return fileDescriptor_c07268f9f08f2beb, []int{0}
|
||||
}
|
||||
func (m *PlainTextChange) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
@ -58,24 +58,25 @@ func (m *PlainTextChange) XXX_DiscardUnknown() {
|
||||
|
||||
var xxx_messageInfo_PlainTextChange proto.InternalMessageInfo
|
||||
|
||||
type PlainTextChangeContent struct {
|
||||
type PlainTextChange_Content struct {
|
||||
// Types that are valid to be assigned to Value:
|
||||
// *PlainTextChangeContentValueOfTextAppend
|
||||
Value IsPlainTextChangeContentValue `protobuf_oneof:"value"`
|
||||
//
|
||||
// *PlainTextChange_Content_TextAppend
|
||||
Value isPlainTextChange_Content_Value `protobuf_oneof:"value"`
|
||||
}
|
||||
|
||||
func (m *PlainTextChangeContent) Reset() { *m = PlainTextChangeContent{} }
|
||||
func (m *PlainTextChangeContent) String() string { return proto.CompactTextString(m) }
|
||||
func (*PlainTextChangeContent) ProtoMessage() {}
|
||||
func (*PlainTextChangeContent) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_37f33c266ada4318, []int{0, 0}
|
||||
func (m *PlainTextChange_Content) Reset() { *m = PlainTextChange_Content{} }
|
||||
func (m *PlainTextChange_Content) String() string { return proto.CompactTextString(m) }
|
||||
func (*PlainTextChange_Content) ProtoMessage() {}
|
||||
func (*PlainTextChange_Content) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_c07268f9f08f2beb, []int{0, 0}
|
||||
}
|
||||
func (m *PlainTextChangeContent) XXX_Unmarshal(b []byte) error {
|
||||
func (m *PlainTextChange_Content) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *PlainTextChangeContent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
func (m *PlainTextChange_Content) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_PlainTextChangeContent.Marshal(b, m, deterministic)
|
||||
return xxx_messageInfo_PlainTextChange_Content.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
@ -85,67 +86,67 @@ func (m *PlainTextChangeContent) XXX_Marshal(b []byte, deterministic bool) ([]by
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *PlainTextChangeContent) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_PlainTextChangeContent.Merge(m, src)
|
||||
func (m *PlainTextChange_Content) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_PlainTextChange_Content.Merge(m, src)
|
||||
}
|
||||
func (m *PlainTextChangeContent) XXX_Size() int {
|
||||
func (m *PlainTextChange_Content) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *PlainTextChangeContent) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_PlainTextChangeContent.DiscardUnknown(m)
|
||||
func (m *PlainTextChange_Content) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_PlainTextChange_Content.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_PlainTextChangeContent proto.InternalMessageInfo
|
||||
var xxx_messageInfo_PlainTextChange_Content proto.InternalMessageInfo
|
||||
|
||||
type IsPlainTextChangeContentValue interface {
|
||||
IsPlainTextChangeContentValue()
|
||||
type isPlainTextChange_Content_Value interface {
|
||||
isPlainTextChange_Content_Value()
|
||||
MarshalTo([]byte) (int, error)
|
||||
Size() int
|
||||
}
|
||||
|
||||
type PlainTextChangeContentValueOfTextAppend struct {
|
||||
TextAppend *PlainTextChangeTextAppend `protobuf:"bytes,1,opt,name=textAppend,proto3,oneof" json:"textAppend,omitempty"`
|
||||
type PlainTextChange_Content_TextAppend struct {
|
||||
TextAppend *PlainTextChange_TextAppend `protobuf:"bytes,1,opt,name=textAppend,proto3,oneof" json:"textAppend,omitempty"`
|
||||
}
|
||||
|
||||
func (*PlainTextChangeContentValueOfTextAppend) IsPlainTextChangeContentValue() {}
|
||||
func (*PlainTextChange_Content_TextAppend) isPlainTextChange_Content_Value() {}
|
||||
|
||||
func (m *PlainTextChangeContent) GetValue() IsPlainTextChangeContentValue {
|
||||
func (m *PlainTextChange_Content) GetValue() isPlainTextChange_Content_Value {
|
||||
if m != nil {
|
||||
return m.Value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PlainTextChangeContent) GetTextAppend() *PlainTextChangeTextAppend {
|
||||
if x, ok := m.GetValue().(*PlainTextChangeContentValueOfTextAppend); ok {
|
||||
func (m *PlainTextChange_Content) GetTextAppend() *PlainTextChange_TextAppend {
|
||||
if x, ok := m.GetValue().(*PlainTextChange_Content_TextAppend); ok {
|
||||
return x.TextAppend
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// XXX_OneofWrappers is for the internal use of the proto package.
|
||||
func (*PlainTextChangeContent) XXX_OneofWrappers() []interface{} {
|
||||
func (*PlainTextChange_Content) XXX_OneofWrappers() []interface{} {
|
||||
return []interface{}{
|
||||
(*PlainTextChangeContentValueOfTextAppend)(nil),
|
||||
(*PlainTextChange_Content_TextAppend)(nil),
|
||||
}
|
||||
}
|
||||
|
||||
type PlainTextChangeTextAppend struct {
|
||||
type PlainTextChange_TextAppend struct {
|
||||
Text string `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"`
|
||||
}
|
||||
|
||||
func (m *PlainTextChangeTextAppend) Reset() { *m = PlainTextChangeTextAppend{} }
|
||||
func (m *PlainTextChangeTextAppend) String() string { return proto.CompactTextString(m) }
|
||||
func (*PlainTextChangeTextAppend) ProtoMessage() {}
|
||||
func (*PlainTextChangeTextAppend) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_37f33c266ada4318, []int{0, 1}
|
||||
func (m *PlainTextChange_TextAppend) Reset() { *m = PlainTextChange_TextAppend{} }
|
||||
func (m *PlainTextChange_TextAppend) String() string { return proto.CompactTextString(m) }
|
||||
func (*PlainTextChange_TextAppend) ProtoMessage() {}
|
||||
func (*PlainTextChange_TextAppend) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_c07268f9f08f2beb, []int{0, 1}
|
||||
}
|
||||
func (m *PlainTextChangeTextAppend) XXX_Unmarshal(b []byte) error {
|
||||
func (m *PlainTextChange_TextAppend) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *PlainTextChangeTextAppend) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
func (m *PlainTextChange_TextAppend) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_PlainTextChangeTextAppend.Marshal(b, m, deterministic)
|
||||
return xxx_messageInfo_PlainTextChange_TextAppend.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
@ -155,41 +156,41 @@ func (m *PlainTextChangeTextAppend) XXX_Marshal(b []byte, deterministic bool) ([
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *PlainTextChangeTextAppend) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_PlainTextChangeTextAppend.Merge(m, src)
|
||||
func (m *PlainTextChange_TextAppend) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_PlainTextChange_TextAppend.Merge(m, src)
|
||||
}
|
||||
func (m *PlainTextChangeTextAppend) XXX_Size() int {
|
||||
func (m *PlainTextChange_TextAppend) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *PlainTextChangeTextAppend) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_PlainTextChangeTextAppend.DiscardUnknown(m)
|
||||
func (m *PlainTextChange_TextAppend) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_PlainTextChange_TextAppend.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_PlainTextChangeTextAppend proto.InternalMessageInfo
|
||||
var xxx_messageInfo_PlainTextChange_TextAppend proto.InternalMessageInfo
|
||||
|
||||
func (m *PlainTextChangeTextAppend) GetText() string {
|
||||
func (m *PlainTextChange_TextAppend) GetText() string {
|
||||
if m != nil {
|
||||
return m.Text
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type PlainTextChangeSnapshot struct {
|
||||
type PlainTextChange_Snapshot struct {
|
||||
Text string `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"`
|
||||
}
|
||||
|
||||
func (m *PlainTextChangeSnapshot) Reset() { *m = PlainTextChangeSnapshot{} }
|
||||
func (m *PlainTextChangeSnapshot) String() string { return proto.CompactTextString(m) }
|
||||
func (*PlainTextChangeSnapshot) ProtoMessage() {}
|
||||
func (*PlainTextChangeSnapshot) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_37f33c266ada4318, []int{0, 2}
|
||||
func (m *PlainTextChange_Snapshot) Reset() { *m = PlainTextChange_Snapshot{} }
|
||||
func (m *PlainTextChange_Snapshot) String() string { return proto.CompactTextString(m) }
|
||||
func (*PlainTextChange_Snapshot) ProtoMessage() {}
|
||||
func (*PlainTextChange_Snapshot) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_c07268f9f08f2beb, []int{0, 2}
|
||||
}
|
||||
func (m *PlainTextChangeSnapshot) XXX_Unmarshal(b []byte) error {
|
||||
func (m *PlainTextChange_Snapshot) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *PlainTextChangeSnapshot) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
func (m *PlainTextChange_Snapshot) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_PlainTextChangeSnapshot.Marshal(b, m, deterministic)
|
||||
return xxx_messageInfo_PlainTextChange_Snapshot.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
@ -199,42 +200,42 @@ func (m *PlainTextChangeSnapshot) XXX_Marshal(b []byte, deterministic bool) ([]b
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *PlainTextChangeSnapshot) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_PlainTextChangeSnapshot.Merge(m, src)
|
||||
func (m *PlainTextChange_Snapshot) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_PlainTextChange_Snapshot.Merge(m, src)
|
||||
}
|
||||
func (m *PlainTextChangeSnapshot) XXX_Size() int {
|
||||
func (m *PlainTextChange_Snapshot) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *PlainTextChangeSnapshot) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_PlainTextChangeSnapshot.DiscardUnknown(m)
|
||||
func (m *PlainTextChange_Snapshot) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_PlainTextChange_Snapshot.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_PlainTextChangeSnapshot proto.InternalMessageInfo
|
||||
var xxx_messageInfo_PlainTextChange_Snapshot proto.InternalMessageInfo
|
||||
|
||||
func (m *PlainTextChangeSnapshot) GetText() string {
|
||||
func (m *PlainTextChange_Snapshot) GetText() string {
|
||||
if m != nil {
|
||||
return m.Text
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type PlainTextChangeData struct {
|
||||
Content []*PlainTextChangeContent `protobuf:"bytes,1,rep,name=content,proto3" json:"content,omitempty"`
|
||||
Snapshot *PlainTextChangeSnapshot `protobuf:"bytes,2,opt,name=snapshot,proto3" json:"snapshot,omitempty"`
|
||||
type PlainTextChange_Data struct {
|
||||
Content []*PlainTextChange_Content `protobuf:"bytes,1,rep,name=content,proto3" json:"content,omitempty"`
|
||||
Snapshot *PlainTextChange_Snapshot `protobuf:"bytes,2,opt,name=snapshot,proto3" json:"snapshot,omitempty"`
|
||||
}
|
||||
|
||||
func (m *PlainTextChangeData) Reset() { *m = PlainTextChangeData{} }
|
||||
func (m *PlainTextChangeData) String() string { return proto.CompactTextString(m) }
|
||||
func (*PlainTextChangeData) ProtoMessage() {}
|
||||
func (*PlainTextChangeData) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_37f33c266ada4318, []int{0, 3}
|
||||
func (m *PlainTextChange_Data) Reset() { *m = PlainTextChange_Data{} }
|
||||
func (m *PlainTextChange_Data) String() string { return proto.CompactTextString(m) }
|
||||
func (*PlainTextChange_Data) ProtoMessage() {}
|
||||
func (*PlainTextChange_Data) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_c07268f9f08f2beb, []int{0, 3}
|
||||
}
|
||||
func (m *PlainTextChangeData) XXX_Unmarshal(b []byte) error {
|
||||
func (m *PlainTextChange_Data) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *PlainTextChangeData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
func (m *PlainTextChange_Data) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_PlainTextChangeData.Marshal(b, m, deterministic)
|
||||
return xxx_messageInfo_PlainTextChange_Data.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
@ -244,26 +245,26 @@ func (m *PlainTextChangeData) XXX_Marshal(b []byte, deterministic bool) ([]byte,
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *PlainTextChangeData) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_PlainTextChangeData.Merge(m, src)
|
||||
func (m *PlainTextChange_Data) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_PlainTextChange_Data.Merge(m, src)
|
||||
}
|
||||
func (m *PlainTextChangeData) XXX_Size() int {
|
||||
func (m *PlainTextChange_Data) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *PlainTextChangeData) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_PlainTextChangeData.DiscardUnknown(m)
|
||||
func (m *PlainTextChange_Data) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_PlainTextChange_Data.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_PlainTextChangeData proto.InternalMessageInfo
|
||||
var xxx_messageInfo_PlainTextChange_Data proto.InternalMessageInfo
|
||||
|
||||
func (m *PlainTextChangeData) GetContent() []*PlainTextChangeContent {
|
||||
func (m *PlainTextChange_Data) GetContent() []*PlainTextChange_Content {
|
||||
if m != nil {
|
||||
return m.Content
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PlainTextChangeData) GetSnapshot() *PlainTextChangeSnapshot {
|
||||
func (m *PlainTextChange_Data) GetSnapshot() *PlainTextChange_Snapshot {
|
||||
if m != nil {
|
||||
return m.Snapshot
|
||||
}
|
||||
@ -272,35 +273,36 @@ func (m *PlainTextChangeData) GetSnapshot() *PlainTextChangeSnapshot {
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*PlainTextChange)(nil), "anytype.PlainTextChange")
|
||||
proto.RegisterType((*PlainTextChangeContent)(nil), "anytype.PlainTextChange.Content")
|
||||
proto.RegisterType((*PlainTextChangeTextAppend)(nil), "anytype.PlainTextChange.TextAppend")
|
||||
proto.RegisterType((*PlainTextChangeSnapshot)(nil), "anytype.PlainTextChange.Snapshot")
|
||||
proto.RegisterType((*PlainTextChangeData)(nil), "anytype.PlainTextChange.Data")
|
||||
proto.RegisterType((*PlainTextChange_Content)(nil), "anytype.PlainTextChange.Content")
|
||||
proto.RegisterType((*PlainTextChange_TextAppend)(nil), "anytype.PlainTextChange.TextAppend")
|
||||
proto.RegisterType((*PlainTextChange_Snapshot)(nil), "anytype.PlainTextChange.Snapshot")
|
||||
proto.RegisterType((*PlainTextChange_Data)(nil), "anytype.PlainTextChange.Data")
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterFile("pkg/acl/testutils/testchanges/proto/test.proto", fileDescriptor_37f33c266ada4318)
|
||||
proto.RegisterFile("pkg/acl/testutils/testchanges/testchangepb/protos/testdocumentchanges.proto", fileDescriptor_c07268f9f08f2beb)
|
||||
}
|
||||
|
||||
var fileDescriptor_37f33c266ada4318 = []byte{
|
||||
// 266 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x2b, 0xc8, 0x4e, 0xd7,
|
||||
var fileDescriptor_c07268f9f08f2beb = []byte{
|
||||
// 278 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xf2, 0x2e, 0xc8, 0x4e, 0xd7,
|
||||
0x4f, 0x4c, 0xce, 0xd1, 0x2f, 0x49, 0x2d, 0x2e, 0x29, 0x2d, 0xc9, 0xcc, 0x29, 0x06, 0xb3, 0x92,
|
||||
0x33, 0x12, 0xf3, 0xd2, 0x53, 0x8b, 0xf5, 0x0b, 0x8a, 0xf2, 0x4b, 0xf2, 0xc1, 0x22, 0x7a, 0x60,
|
||||
0xa6, 0x10, 0x7b, 0x62, 0x5e, 0x65, 0x49, 0x65, 0x41, 0xaa, 0xd2, 0x26, 0x26, 0x2e, 0xfe, 0x80,
|
||||
0x9c, 0xc4, 0xcc, 0xbc, 0x90, 0xd4, 0x8a, 0x12, 0x67, 0xb0, 0x72, 0xa9, 0x48, 0x2e, 0x76, 0xe7,
|
||||
0xfc, 0xbc, 0x92, 0xd4, 0xbc, 0x12, 0x21, 0x57, 0x2e, 0xae, 0x92, 0xd4, 0x8a, 0x12, 0xc7, 0x82,
|
||||
0x82, 0xd4, 0xbc, 0x14, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x65, 0x3d, 0xa8, 0x66, 0x3d,
|
||||
0x34, 0x8d, 0x7a, 0x21, 0x70, 0xa5, 0x1e, 0x0c, 0x41, 0x48, 0x1a, 0x9d, 0xd8, 0xb9, 0x58, 0xcb,
|
||||
0x12, 0x73, 0x4a, 0x53, 0xa5, 0x14, 0xb8, 0xb8, 0x10, 0x8a, 0x84, 0x84, 0xb8, 0x58, 0x40, 0x8a,
|
||||
0xc0, 0xe6, 0x72, 0x06, 0x81, 0xd9, 0x52, 0x72, 0x5c, 0x1c, 0xc1, 0x79, 0x89, 0x05, 0xc5, 0x19,
|
||||
0xf9, 0x25, 0x58, 0xe5, 0x1b, 0x19, 0xb9, 0x58, 0x5c, 0x12, 0x4b, 0x12, 0x85, 0xac, 0xb8, 0xd8,
|
||||
0x93, 0x21, 0xae, 0x94, 0x60, 0x54, 0x60, 0xd6, 0xe0, 0x36, 0x52, 0xc0, 0xe9, 0x2e, 0xa8, 0x6f,
|
||||
0x82, 0x60, 0x1a, 0x84, 0x6c, 0xb9, 0x38, 0x8a, 0xa1, 0x96, 0x48, 0x30, 0x81, 0x3d, 0xa5, 0x88,
|
||||
0x53, 0x33, 0xcc, 0x35, 0x41, 0x70, 0x2d, 0x4e, 0xaa, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24,
|
||||
0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78,
|
||||
0x2c, 0xc7, 0x10, 0xc5, 0x8d, 0x14, 0xea, 0x49, 0x6c, 0xe0, 0xb0, 0x36, 0x06, 0x04, 0x00, 0x00,
|
||||
0xff, 0xff, 0xf8, 0x8c, 0x6a, 0x1d, 0x9d, 0x01, 0x00, 0x00,
|
||||
0x33, 0x12, 0xf3, 0xd2, 0x53, 0x91, 0xd9, 0x05, 0x49, 0xfa, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x10,
|
||||
0xb1, 0x94, 0xfc, 0xe4, 0xd2, 0xdc, 0xd4, 0x3c, 0x98, 0x3a, 0x3d, 0xb0, 0x94, 0x10, 0x7b, 0x62,
|
||||
0x5e, 0x65, 0x49, 0x65, 0x41, 0xaa, 0xd2, 0x26, 0x26, 0x2e, 0xfe, 0x80, 0x9c, 0xc4, 0xcc, 0xbc,
|
||||
0x90, 0xd4, 0x8a, 0x12, 0x67, 0xb0, 0x1a, 0xa9, 0x48, 0x2e, 0x76, 0xe7, 0xfc, 0xbc, 0x92, 0xd4,
|
||||
0xbc, 0x12, 0x21, 0x57, 0x2e, 0xae, 0x92, 0xd4, 0x8a, 0x12, 0xc7, 0x82, 0x82, 0xd4, 0xbc, 0x14,
|
||||
0x09, 0x46, 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x65, 0x3d, 0xa8, 0x66, 0x3d, 0x34, 0x8d, 0x7a, 0x21,
|
||||
0x70, 0xa5, 0x1e, 0x0c, 0x41, 0x48, 0x1a, 0x9d, 0xd8, 0xb9, 0x58, 0xcb, 0x12, 0x73, 0x4a, 0x53,
|
||||
0xa5, 0x14, 0xb8, 0xb8, 0x10, 0x8a, 0x84, 0x84, 0xb8, 0x58, 0x40, 0x8a, 0xc0, 0xe6, 0x72, 0x06,
|
||||
0x81, 0xd9, 0x52, 0x72, 0x5c, 0x1c, 0xc1, 0x79, 0x89, 0x05, 0xc5, 0x19, 0xf9, 0x25, 0x58, 0xe5,
|
||||
0x1b, 0x19, 0xb9, 0x58, 0x5c, 0x12, 0x4b, 0x12, 0x85, 0xac, 0xb8, 0xd8, 0x93, 0x21, 0xae, 0x94,
|
||||
0x60, 0x54, 0x60, 0xd6, 0xe0, 0x36, 0x52, 0xc0, 0xe9, 0x2e, 0xa8, 0x6f, 0x82, 0x60, 0x1a, 0x84,
|
||||
0x6c, 0xb9, 0x38, 0x8a, 0xa1, 0x96, 0x48, 0x30, 0x81, 0x3d, 0xa5, 0x88, 0x53, 0x33, 0xcc, 0x35,
|
||||
0x41, 0x70, 0x2d, 0x4e, 0x6a, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91,
|
||||
0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0xc5,
|
||||
0x83, 0x1c, 0x0d, 0x49, 0x6c, 0xe0, 0xc0, 0x36, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xfd, 0x73,
|
||||
0xe1, 0xf2, 0xbb, 0x01, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *PlainTextChange) Marshal() (dAtA []byte, err error) {
|
||||
@ -326,7 +328,7 @@ func (m *PlainTextChange) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *PlainTextChangeContent) Marshal() (dAtA []byte, err error) {
|
||||
func (m *PlainTextChange_Content) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
@ -336,12 +338,12 @@ func (m *PlainTextChangeContent) Marshal() (dAtA []byte, err error) {
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *PlainTextChangeContent) MarshalTo(dAtA []byte) (int, error) {
|
||||
func (m *PlainTextChange_Content) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *PlainTextChangeContent) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
func (m *PlainTextChange_Content) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
@ -358,12 +360,12 @@ func (m *PlainTextChangeContent) MarshalToSizedBuffer(dAtA []byte) (int, error)
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *PlainTextChangeContentValueOfTextAppend) MarshalTo(dAtA []byte) (int, error) {
|
||||
func (m *PlainTextChange_Content_TextAppend) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *PlainTextChangeContentValueOfTextAppend) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
func (m *PlainTextChange_Content_TextAppend) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
if m.TextAppend != nil {
|
||||
{
|
||||
@ -372,14 +374,14 @@ func (m *PlainTextChangeContentValueOfTextAppend) MarshalToSizedBuffer(dAtA []by
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintTest(dAtA, i, uint64(size))
|
||||
i = encodeVarintTestdocumentchanges(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
func (m *PlainTextChangeTextAppend) Marshal() (dAtA []byte, err error) {
|
||||
func (m *PlainTextChange_TextAppend) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
@ -389,12 +391,12 @@ func (m *PlainTextChangeTextAppend) Marshal() (dAtA []byte, err error) {
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *PlainTextChangeTextAppend) MarshalTo(dAtA []byte) (int, error) {
|
||||
func (m *PlainTextChange_TextAppend) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *PlainTextChangeTextAppend) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
func (m *PlainTextChange_TextAppend) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
@ -402,14 +404,14 @@ func (m *PlainTextChangeTextAppend) MarshalToSizedBuffer(dAtA []byte) (int, erro
|
||||
if len(m.Text) > 0 {
|
||||
i -= len(m.Text)
|
||||
copy(dAtA[i:], m.Text)
|
||||
i = encodeVarintTest(dAtA, i, uint64(len(m.Text)))
|
||||
i = encodeVarintTestdocumentchanges(dAtA, i, uint64(len(m.Text)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *PlainTextChangeSnapshot) Marshal() (dAtA []byte, err error) {
|
||||
func (m *PlainTextChange_Snapshot) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
@ -419,12 +421,12 @@ func (m *PlainTextChangeSnapshot) Marshal() (dAtA []byte, err error) {
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *PlainTextChangeSnapshot) MarshalTo(dAtA []byte) (int, error) {
|
||||
func (m *PlainTextChange_Snapshot) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *PlainTextChangeSnapshot) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
func (m *PlainTextChange_Snapshot) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
@ -432,14 +434,14 @@ func (m *PlainTextChangeSnapshot) MarshalToSizedBuffer(dAtA []byte) (int, error)
|
||||
if len(m.Text) > 0 {
|
||||
i -= len(m.Text)
|
||||
copy(dAtA[i:], m.Text)
|
||||
i = encodeVarintTest(dAtA, i, uint64(len(m.Text)))
|
||||
i = encodeVarintTestdocumentchanges(dAtA, i, uint64(len(m.Text)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *PlainTextChangeData) Marshal() (dAtA []byte, err error) {
|
||||
func (m *PlainTextChange_Data) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
@ -449,12 +451,12 @@ func (m *PlainTextChangeData) Marshal() (dAtA []byte, err error) {
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *PlainTextChangeData) MarshalTo(dAtA []byte) (int, error) {
|
||||
func (m *PlainTextChange_Data) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *PlainTextChangeData) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
func (m *PlainTextChange_Data) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
@ -466,7 +468,7 @@ func (m *PlainTextChangeData) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintTest(dAtA, i, uint64(size))
|
||||
i = encodeVarintTestdocumentchanges(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
@ -479,7 +481,7 @@ func (m *PlainTextChangeData) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintTest(dAtA, i, uint64(size))
|
||||
i = encodeVarintTestdocumentchanges(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
@ -488,8 +490,8 @@ func (m *PlainTextChangeData) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintTest(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovTest(v)
|
||||
func encodeVarintTestdocumentchanges(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovTestdocumentchanges(v)
|
||||
base := offset
|
||||
for v >= 1<<7 {
|
||||
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||
@ -508,7 +510,7 @@ func (m *PlainTextChange) Size() (n int) {
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *PlainTextChangeContent) Size() (n int) {
|
||||
func (m *PlainTextChange_Content) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
@ -520,7 +522,7 @@ func (m *PlainTextChangeContent) Size() (n int) {
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *PlainTextChangeContentValueOfTextAppend) Size() (n int) {
|
||||
func (m *PlainTextChange_Content_TextAppend) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
@ -528,11 +530,11 @@ func (m *PlainTextChangeContentValueOfTextAppend) Size() (n int) {
|
||||
_ = l
|
||||
if m.TextAppend != nil {
|
||||
l = m.TextAppend.Size()
|
||||
n += 1 + l + sovTest(uint64(l))
|
||||
n += 1 + l + sovTestdocumentchanges(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
func (m *PlainTextChangeTextAppend) Size() (n int) {
|
||||
func (m *PlainTextChange_TextAppend) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
@ -540,12 +542,12 @@ func (m *PlainTextChangeTextAppend) Size() (n int) {
|
||||
_ = l
|
||||
l = len(m.Text)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovTest(uint64(l))
|
||||
n += 1 + l + sovTestdocumentchanges(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *PlainTextChangeSnapshot) Size() (n int) {
|
||||
func (m *PlainTextChange_Snapshot) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
@ -553,12 +555,12 @@ func (m *PlainTextChangeSnapshot) Size() (n int) {
|
||||
_ = l
|
||||
l = len(m.Text)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovTest(uint64(l))
|
||||
n += 1 + l + sovTestdocumentchanges(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *PlainTextChangeData) Size() (n int) {
|
||||
func (m *PlainTextChange_Data) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
@ -567,21 +569,21 @@ func (m *PlainTextChangeData) Size() (n int) {
|
||||
if len(m.Content) > 0 {
|
||||
for _, e := range m.Content {
|
||||
l = e.Size()
|
||||
n += 1 + l + sovTest(uint64(l))
|
||||
n += 1 + l + sovTestdocumentchanges(uint64(l))
|
||||
}
|
||||
}
|
||||
if m.Snapshot != nil {
|
||||
l = m.Snapshot.Size()
|
||||
n += 1 + l + sovTest(uint64(l))
|
||||
n += 1 + l + sovTestdocumentchanges(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func sovTest(x uint64) (n int) {
|
||||
func sovTestdocumentchanges(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
func sozTest(x uint64) (n int) {
|
||||
return sovTest(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||
func sozTestdocumentchanges(x uint64) (n int) {
|
||||
return sovTestdocumentchanges(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||
}
|
||||
func (m *PlainTextChange) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
@ -591,7 +593,7 @@ func (m *PlainTextChange) Unmarshal(dAtA []byte) error {
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTest
|
||||
return ErrIntOverflowTestdocumentchanges
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
@ -614,12 +616,12 @@ func (m *PlainTextChange) Unmarshal(dAtA []byte) error {
|
||||
switch fieldNum {
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipTest(dAtA[iNdEx:])
|
||||
skippy, err := skipTestdocumentchanges(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthTest
|
||||
return ErrInvalidLengthTestdocumentchanges
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
@ -633,7 +635,7 @@ func (m *PlainTextChange) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *PlainTextChangeContent) Unmarshal(dAtA []byte) error {
|
||||
func (m *PlainTextChange_Content) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
@ -641,7 +643,7 @@ func (m *PlainTextChangeContent) Unmarshal(dAtA []byte) error {
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTest
|
||||
return ErrIntOverflowTestdocumentchanges
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
@ -669,7 +671,7 @@ func (m *PlainTextChangeContent) Unmarshal(dAtA []byte) error {
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTest
|
||||
return ErrIntOverflowTestdocumentchanges
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
@ -682,29 +684,29 @@ func (m *PlainTextChangeContent) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthTest
|
||||
return ErrInvalidLengthTestdocumentchanges
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthTest
|
||||
return ErrInvalidLengthTestdocumentchanges
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
v := &PlainTextChangeTextAppend{}
|
||||
v := &PlainTextChange_TextAppend{}
|
||||
if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
m.Value = &PlainTextChangeContentValueOfTextAppend{v}
|
||||
m.Value = &PlainTextChange_Content_TextAppend{v}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipTest(dAtA[iNdEx:])
|
||||
skippy, err := skipTestdocumentchanges(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthTest
|
||||
return ErrInvalidLengthTestdocumentchanges
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
@ -718,7 +720,7 @@ func (m *PlainTextChangeContent) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *PlainTextChangeTextAppend) Unmarshal(dAtA []byte) error {
|
||||
func (m *PlainTextChange_TextAppend) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
@ -726,7 +728,7 @@ func (m *PlainTextChangeTextAppend) Unmarshal(dAtA []byte) error {
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTest
|
||||
return ErrIntOverflowTestdocumentchanges
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
@ -754,7 +756,7 @@ func (m *PlainTextChangeTextAppend) Unmarshal(dAtA []byte) error {
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTest
|
||||
return ErrIntOverflowTestdocumentchanges
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
@ -768,11 +770,11 @@ func (m *PlainTextChangeTextAppend) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthTest
|
||||
return ErrInvalidLengthTestdocumentchanges
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthTest
|
||||
return ErrInvalidLengthTestdocumentchanges
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
@ -781,12 +783,12 @@ func (m *PlainTextChangeTextAppend) Unmarshal(dAtA []byte) error {
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipTest(dAtA[iNdEx:])
|
||||
skippy, err := skipTestdocumentchanges(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthTest
|
||||
return ErrInvalidLengthTestdocumentchanges
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
@ -800,7 +802,7 @@ func (m *PlainTextChangeTextAppend) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *PlainTextChangeSnapshot) Unmarshal(dAtA []byte) error {
|
||||
func (m *PlainTextChange_Snapshot) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
@ -808,7 +810,7 @@ func (m *PlainTextChangeSnapshot) Unmarshal(dAtA []byte) error {
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTest
|
||||
return ErrIntOverflowTestdocumentchanges
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
@ -836,7 +838,7 @@ func (m *PlainTextChangeSnapshot) Unmarshal(dAtA []byte) error {
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTest
|
||||
return ErrIntOverflowTestdocumentchanges
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
@ -850,11 +852,11 @@ func (m *PlainTextChangeSnapshot) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthTest
|
||||
return ErrInvalidLengthTestdocumentchanges
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthTest
|
||||
return ErrInvalidLengthTestdocumentchanges
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
@ -863,12 +865,12 @@ func (m *PlainTextChangeSnapshot) Unmarshal(dAtA []byte) error {
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipTest(dAtA[iNdEx:])
|
||||
skippy, err := skipTestdocumentchanges(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthTest
|
||||
return ErrInvalidLengthTestdocumentchanges
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
@ -882,7 +884,7 @@ func (m *PlainTextChangeSnapshot) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *PlainTextChangeData) Unmarshal(dAtA []byte) error {
|
||||
func (m *PlainTextChange_Data) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
@ -890,7 +892,7 @@ func (m *PlainTextChangeData) Unmarshal(dAtA []byte) error {
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTest
|
||||
return ErrIntOverflowTestdocumentchanges
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
@ -918,7 +920,7 @@ func (m *PlainTextChangeData) Unmarshal(dAtA []byte) error {
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTest
|
||||
return ErrIntOverflowTestdocumentchanges
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
@ -931,16 +933,16 @@ func (m *PlainTextChangeData) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthTest
|
||||
return ErrInvalidLengthTestdocumentchanges
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthTest
|
||||
return ErrInvalidLengthTestdocumentchanges
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Content = append(m.Content, &PlainTextChangeContent{})
|
||||
m.Content = append(m.Content, &PlainTextChange_Content{})
|
||||
if err := m.Content[len(m.Content)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -952,7 +954,7 @@ func (m *PlainTextChangeData) Unmarshal(dAtA []byte) error {
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTest
|
||||
return ErrIntOverflowTestdocumentchanges
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
@ -965,17 +967,17 @@ func (m *PlainTextChangeData) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthTest
|
||||
return ErrInvalidLengthTestdocumentchanges
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthTest
|
||||
return ErrInvalidLengthTestdocumentchanges
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if m.Snapshot == nil {
|
||||
m.Snapshot = &PlainTextChangeSnapshot{}
|
||||
m.Snapshot = &PlainTextChange_Snapshot{}
|
||||
}
|
||||
if err := m.Snapshot.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
@ -983,12 +985,12 @@ func (m *PlainTextChangeData) Unmarshal(dAtA []byte) error {
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipTest(dAtA[iNdEx:])
|
||||
skippy, err := skipTestdocumentchanges(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthTest
|
||||
return ErrInvalidLengthTestdocumentchanges
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
@ -1002,7 +1004,7 @@ func (m *PlainTextChangeData) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipTest(dAtA []byte) (n int, err error) {
|
||||
func skipTestdocumentchanges(dAtA []byte) (n int, err error) {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
depth := 0
|
||||
@ -1010,7 +1012,7 @@ func skipTest(dAtA []byte) (n int, err error) {
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowTest
|
||||
return 0, ErrIntOverflowTestdocumentchanges
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
@ -1027,7 +1029,7 @@ func skipTest(dAtA []byte) (n int, err error) {
|
||||
case 0:
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowTest
|
||||
return 0, ErrIntOverflowTestdocumentchanges
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
@ -1043,7 +1045,7 @@ func skipTest(dAtA []byte) (n int, err error) {
|
||||
var length int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowTest
|
||||
return 0, ErrIntOverflowTestdocumentchanges
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
@ -1056,14 +1058,14 @@ func skipTest(dAtA []byte) (n int, err error) {
|
||||
}
|
||||
}
|
||||
if length < 0 {
|
||||
return 0, ErrInvalidLengthTest
|
||||
return 0, ErrInvalidLengthTestdocumentchanges
|
||||
}
|
||||
iNdEx += length
|
||||
case 3:
|
||||
depth++
|
||||
case 4:
|
||||
if depth == 0 {
|
||||
return 0, ErrUnexpectedEndOfGroupTest
|
||||
return 0, ErrUnexpectedEndOfGroupTestdocumentchanges
|
||||
}
|
||||
depth--
|
||||
case 5:
|
||||
@ -1072,7 +1074,7 @@ func skipTest(dAtA []byte) (n int, err error) {
|
||||
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
||||
}
|
||||
if iNdEx < 0 {
|
||||
return 0, ErrInvalidLengthTest
|
||||
return 0, ErrInvalidLengthTestdocumentchanges
|
||||
}
|
||||
if depth == 0 {
|
||||
return iNdEx, nil
|
||||
@ -1082,7 +1084,7 @@ func skipTest(dAtA []byte) (n int, err error) {
|
||||
}
|
||||
|
||||
var (
|
||||
ErrInvalidLengthTest = fmt.Errorf("proto: negative length found during unmarshaling")
|
||||
ErrIntOverflowTest = fmt.Errorf("proto: integer overflow")
|
||||
ErrUnexpectedEndOfGroupTest = fmt.Errorf("proto: unexpected end of group")
|
||||
ErrInvalidLengthTestdocumentchanges = fmt.Errorf("proto: negative length found during unmarshaling")
|
||||
ErrIntOverflowTestdocumentchanges = fmt.Errorf("proto: integer overflow")
|
||||
ErrUnexpectedEndOfGroupTestdocumentchanges = fmt.Errorf("proto: unexpected end of group")
|
||||
)
|
||||
|
||||
539
pkg/acl/testutils/treestoragebuilder/treestoragebuilder.go
Normal file
539
pkg/acl/testutils/treestoragebuilder/treestoragebuilder.go
Normal file
@ -0,0 +1,539 @@
|
||||
package treestoragebuilder
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb"
|
||||
testpb "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/testutils/testchanges/testchangepb"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/testutils/yamltests"
|
||||
storagepb "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treestorage/treepb"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/encryptionkey"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/slice"
|
||||
"io/ioutil"
|
||||
"path"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
const plainTextDocType uint16 = 1
|
||||
|
||||
type treeChange struct {
|
||||
*aclpb.ACLChange
|
||||
id string
|
||||
readKey *SymKey
|
||||
signKey signingkey.PrivKey
|
||||
|
||||
changesDataDecrypted []byte
|
||||
}
|
||||
|
||||
type updateUseCase struct {
|
||||
changes map[string]*treeChange
|
||||
}
|
||||
|
||||
type TreeStorageBuilder struct {
|
||||
treeId string
|
||||
allChanges map[string]*treeChange
|
||||
updates map[string]*updateUseCase
|
||||
heads []string
|
||||
orphans []string
|
||||
keychain *Keychain
|
||||
header *storagepb.TreeHeader
|
||||
}
|
||||
|
||||
func NewTreeStorageBuilder(keychain *Keychain) *TreeStorageBuilder {
|
||||
return &TreeStorageBuilder{
|
||||
allChanges: make(map[string]*treeChange),
|
||||
updates: make(map[string]*updateUseCase),
|
||||
keychain: keychain,
|
||||
}
|
||||
}
|
||||
|
||||
func NewTreeStorageBuilderWithTestName(name string) (*TreeStorageBuilder, error) {
|
||||
filePath := path.Join(yamltests.Path(), name)
|
||||
return NewTreeStorageBuilderFromFile(filePath)
|
||||
}
|
||||
|
||||
func NewTreeStorageBuilderFromFile(file string) (*TreeStorageBuilder, error) {
|
||||
content, err := ioutil.ReadFile(file)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ymlTree := YMLTree{}
|
||||
err = yaml.Unmarshal(content, &ymlTree)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tb := NewTreeStorageBuilder(NewKeychain())
|
||||
tb.Parse(&ymlTree)
|
||||
|
||||
return tb, nil
|
||||
}
|
||||
|
||||
func (t *TreeStorageBuilder) TreeID() (string, error) {
|
||||
return t.treeId, nil
|
||||
}
|
||||
|
||||
func (t *TreeStorageBuilder) GetKeychain() *Keychain {
|
||||
return t.keychain
|
||||
}
|
||||
|
||||
func (t *TreeStorageBuilder) Heads() ([]string, error) {
|
||||
return t.heads, nil
|
||||
}
|
||||
|
||||
func (t *TreeStorageBuilder) AddRawChange(change *aclpb.RawChange) error {
|
||||
aclChange := new(aclpb.ACLChange)
|
||||
var err error
|
||||
|
||||
if err = proto.Unmarshal(change.Payload, aclChange); err != nil {
|
||||
return fmt.Errorf("could not unmarshall changes")
|
||||
}
|
||||
var changesData []byte
|
||||
|
||||
// get correct readkey
|
||||
readKey := t.keychain.ReadKeysByHash[aclChange.CurrentReadKeyHash]
|
||||
if aclChange.ChangesData != nil {
|
||||
changesData, err = readKey.Key.Decrypt(aclChange.ChangesData)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to decrypt changes data: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
// get correct signing key
|
||||
signKey := t.keychain.SigningKeysByIdentity[aclChange.Identity]
|
||||
|
||||
t.allChanges[change.Id] = &treeChange{
|
||||
ACLChange: aclChange,
|
||||
id: change.Id,
|
||||
readKey: readKey,
|
||||
signKey: signKey,
|
||||
changesDataDecrypted: changesData,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *TreeStorageBuilder) AddOrphans(orphans ...string) error {
|
||||
t.orphans = append(t.orphans, orphans...)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *TreeStorageBuilder) AddChange(change aclchanges.Change) error {
|
||||
aclChange := change.ProtoChange()
|
||||
var err error
|
||||
var changesData []byte
|
||||
|
||||
// get correct readkey
|
||||
readKey := t.keychain.ReadKeysByHash[aclChange.CurrentReadKeyHash]
|
||||
if aclChange.ChangesData != nil {
|
||||
changesData, err = readKey.Key.Decrypt(aclChange.ChangesData)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to decrypt changes data: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
// get correct signing key
|
||||
signKey := t.keychain.SigningKeysByIdentity[aclChange.Identity]
|
||||
|
||||
t.allChanges[change.CID()] = &treeChange{
|
||||
ACLChange: aclChange,
|
||||
id: change.CID(),
|
||||
readKey: readKey,
|
||||
signKey: signKey,
|
||||
changesDataDecrypted: changesData,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *TreeStorageBuilder) Orphans() ([]string, error) {
|
||||
return t.orphans, nil
|
||||
}
|
||||
|
||||
func (t *TreeStorageBuilder) SetHeads(heads []string) error {
|
||||
// we should copy here instead of just setting the value
|
||||
t.heads = heads
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *TreeStorageBuilder) RemoveOrphans(orphans ...string) error {
|
||||
t.orphans = slice.Difference(t.orphans, orphans)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *TreeStorageBuilder) GetChange(ctx context.Context, recordID string) (*aclpb.RawChange, error) {
|
||||
return t.getChange(recordID, t.allChanges), nil
|
||||
}
|
||||
|
||||
func (t *TreeStorageBuilder) GetUpdates(useCase string) []*aclpb.RawChange {
|
||||
var res []*aclpb.RawChange
|
||||
update := t.updates[useCase]
|
||||
for _, ch := range update.changes {
|
||||
rawCh := t.getChange(ch.id, update.changes)
|
||||
res = append(res, rawCh)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func (t *TreeStorageBuilder) Header() (*storagepb.TreeHeader, error) {
|
||||
return t.header, nil
|
||||
}
|
||||
|
||||
func (t *TreeStorageBuilder) getChange(changeId string, m map[string]*treeChange) *aclpb.RawChange {
|
||||
rec := m[changeId]
|
||||
|
||||
if rec.changesDataDecrypted != nil {
|
||||
encrypted, err := rec.readKey.Key.Encrypt(rec.changesDataDecrypted)
|
||||
if err != nil {
|
||||
panic("should be able to encrypt data with read key!")
|
||||
}
|
||||
|
||||
rec.ChangesData = encrypted
|
||||
}
|
||||
|
||||
aclMarshaled, err := proto.Marshal(rec.ACLChange)
|
||||
if err != nil {
|
||||
panic("should be able to marshal final acl message!")
|
||||
}
|
||||
|
||||
signature, err := rec.signKey.Sign(aclMarshaled)
|
||||
if err != nil {
|
||||
panic("should be able to sign final acl message!")
|
||||
}
|
||||
|
||||
transformedRec := &aclpb.RawChange{
|
||||
Payload: aclMarshaled,
|
||||
Signature: signature,
|
||||
Id: changeId,
|
||||
}
|
||||
return transformedRec
|
||||
}
|
||||
|
||||
func (t *TreeStorageBuilder) Parse(tree *YMLTree) {
|
||||
// Just to clarify - we are generating new identities for the ones that
|
||||
// are specified in the yml file, because our identities should be Ed25519
|
||||
// the same thing is happening for the encryption keys
|
||||
t.keychain.ParseKeys(&tree.Keys)
|
||||
t.treeId = t.parseTreeId(tree.Description)
|
||||
for _, ch := range tree.Changes {
|
||||
newChange := t.parseChange(ch)
|
||||
t.allChanges[newChange.id] = newChange
|
||||
}
|
||||
|
||||
t.parseGraph(tree)
|
||||
t.parseOrphans(tree)
|
||||
t.parseHeader(tree)
|
||||
t.parseUpdates(tree.Updates)
|
||||
}
|
||||
|
||||
func (t *TreeStorageBuilder) parseChange(ch *Change) *treeChange {
|
||||
newChange := &treeChange{
|
||||
id: ch.Id,
|
||||
}
|
||||
k := t.keychain.GetKey(ch.ReadKey).(*SymKey)
|
||||
newChange.readKey = k
|
||||
newChange.signKey = t.keychain.SigningKeys[ch.Identity]
|
||||
aclChange := &aclpb.ACLChange{}
|
||||
aclChange.Identity = t.keychain.GetIdentity(ch.Identity)
|
||||
if len(ch.AclChanges) > 0 || ch.AclSnapshot != nil {
|
||||
aclChange.AclData = &aclpb.ACLChange_ACLData{}
|
||||
if ch.AclSnapshot != nil {
|
||||
aclChange.AclData.AclSnapshot = t.parseACLSnapshot(ch.AclSnapshot)
|
||||
}
|
||||
if ch.AclChanges != nil {
|
||||
var aclChangeContents []*aclpb.ACLChange_ACLContentValue
|
||||
for _, ch := range ch.AclChanges {
|
||||
aclChangeContent := t.parseACLChange(ch)
|
||||
aclChangeContents = append(aclChangeContents, aclChangeContent)
|
||||
}
|
||||
aclChange.AclData.AclContent = aclChangeContents
|
||||
}
|
||||
}
|
||||
if len(ch.Changes) > 0 || ch.Snapshot != nil {
|
||||
changesData := &testpb.PlainTextChange_Data{}
|
||||
if ch.Snapshot != nil {
|
||||
changesData.Snapshot = t.parseChangeSnapshot(ch.Snapshot)
|
||||
}
|
||||
if len(ch.Changes) > 0 {
|
||||
var changeContents []*testpb.PlainTextChange_Content
|
||||
for _, ch := range ch.Changes {
|
||||
aclChangeContent := t.parseDocumentChange(ch)
|
||||
changeContents = append(changeContents, aclChangeContent)
|
||||
}
|
||||
changesData.Content = changeContents
|
||||
}
|
||||
m, err := proto.Marshal(changesData)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
newChange.changesDataDecrypted = m
|
||||
}
|
||||
aclChange.CurrentReadKeyHash = k.Hash
|
||||
newChange.ACLChange = aclChange
|
||||
return newChange
|
||||
}
|
||||
|
||||
func (t *TreeStorageBuilder) parseTreeId(description *TreeDescription) string {
|
||||
if description == nil {
|
||||
panic("no author in tree")
|
||||
}
|
||||
return description.Author + ".tree.id"
|
||||
}
|
||||
|
||||
func (t *TreeStorageBuilder) parseChangeSnapshot(s *PlainTextSnapshot) *testpb.PlainTextChange_Snapshot {
|
||||
return &testpb.PlainTextChange_Snapshot{
|
||||
Text: s.Text,
|
||||
}
|
||||
}
|
||||
|
||||
func (t *TreeStorageBuilder) parseACLSnapshot(s *ACLSnapshot) *aclpb.ACLChange_ACLSnapshot {
|
||||
newState := &aclpb.ACLChange_ACLState{}
|
||||
for _, state := range s.UserStates {
|
||||
aclUserState := &aclpb.ACLChange_UserState{}
|
||||
aclUserState.Identity = t.keychain.GetIdentity(state.Identity)
|
||||
|
||||
encKey := t.keychain.
|
||||
GetKey(state.EncryptionKey).(encryptionkey.PrivKey)
|
||||
rawKey, _ := encKey.GetPublic().Raw()
|
||||
aclUserState.EncryptionKey = rawKey
|
||||
|
||||
aclUserState.EncryptedReadKeys = t.encryptReadKeys(state.EncryptedReadKeys, encKey)
|
||||
aclUserState.Permissions = t.convertPermission(state.Permissions)
|
||||
newState.UserStates = append(newState.UserStates, aclUserState)
|
||||
}
|
||||
return &aclpb.ACLChange_ACLSnapshot{
|
||||
AclState: newState,
|
||||
}
|
||||
}
|
||||
|
||||
func (t *TreeStorageBuilder) parseDocumentChange(ch *PlainTextChange) (convCh *testpb.PlainTextChange_Content) {
|
||||
switch {
|
||||
case ch.TextAppend != nil:
|
||||
convCh = &testpb.PlainTextChange_Content{
|
||||
Value: &testpb.PlainTextChange_Content_TextAppend{
|
||||
TextAppend: &testpb.PlainTextChange_TextAppend{
|
||||
Text: ch.TextAppend.Text,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
if convCh == nil {
|
||||
panic("cannot have empty document change")
|
||||
}
|
||||
|
||||
return convCh
|
||||
}
|
||||
|
||||
func (t *TreeStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACLChange_ACLContentValue) {
|
||||
switch {
|
||||
case ch.UserAdd != nil:
|
||||
add := ch.UserAdd
|
||||
|
||||
encKey := t.keychain.
|
||||
GetKey(add.EncryptionKey).(encryptionkey.PrivKey)
|
||||
rawKey, _ := encKey.GetPublic().Raw()
|
||||
|
||||
convCh = &aclpb.ACLChange_ACLContentValue{
|
||||
Value: &aclpb.ACLChange_ACLContent_Value_UserAdd{
|
||||
UserAdd: &aclpb.ACLChange_UserAdd{
|
||||
Identity: t.keychain.GetIdentity(add.Identity),
|
||||
EncryptionKey: rawKey,
|
||||
EncryptedReadKeys: t.encryptReadKeys(add.EncryptedReadKeys, encKey),
|
||||
Permissions: t.convertPermission(add.Permission),
|
||||
},
|
||||
},
|
||||
}
|
||||
case ch.UserJoin != nil:
|
||||
join := ch.UserJoin
|
||||
|
||||
encKey := t.keychain.
|
||||
GetKey(join.EncryptionKey).(encryptionkey.PrivKey)
|
||||
rawKey, _ := encKey.GetPublic().Raw()
|
||||
|
||||
idKey, _ := t.keychain.SigningKeys[join.Identity].GetPublic().Raw()
|
||||
signKey := t.keychain.GetKey(join.AcceptSignature).(signingkey.PrivKey)
|
||||
signature, err := signKey.Sign(idKey)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
convCh = &aclpb.ACLChange_ACLContentValue{
|
||||
Value: &aclpb.ACLChange_ACLContentValueValueOfUserJoin{
|
||||
UserJoin: &aclpb.ACLChange_UserJoin{
|
||||
Identity: t.keychain.GetIdentity(join.Identity),
|
||||
EncryptionKey: rawKey,
|
||||
AcceptSignature: signature,
|
||||
UserInviteId: join.InviteId,
|
||||
EncryptedReadKeys: t.encryptReadKeys(join.EncryptedReadKeys, encKey),
|
||||
},
|
||||
},
|
||||
}
|
||||
case ch.UserInvite != nil:
|
||||
invite := ch.UserInvite
|
||||
rawAcceptKey, _ := t.keychain.GetKey(invite.AcceptKey).(signingkey.PrivKey).GetPublic().Raw()
|
||||
encKey := t.keychain.
|
||||
GetKey(invite.EncryptionKey).(encryptionkey.PrivKey)
|
||||
rawEncKey, _ := encKey.GetPublic().Raw()
|
||||
|
||||
convCh = &aclpb.ACLChange_ACLContentValue{
|
||||
Value: &aclpb.ACLChange_ACLContentValueValueOfUserInvite{
|
||||
UserInvite: &aclpb.ACLChange_UserInvite{
|
||||
AcceptPublicKey: rawAcceptKey,
|
||||
EncryptPublicKey: rawEncKey,
|
||||
EncryptedReadKeys: t.encryptReadKeys(invite.EncryptedReadKeys, encKey),
|
||||
Permissions: t.convertPermission(invite.Permissions),
|
||||
InviteId: invite.InviteId,
|
||||
},
|
||||
},
|
||||
}
|
||||
case ch.UserConfirm != nil:
|
||||
confirm := ch.UserConfirm
|
||||
|
||||
convCh = &aclpb.ACLChange_ACLContentValue{
|
||||
Value: &aclpb.ACLChange_ACLContentValueValueOfUserConfirm{
|
||||
UserConfirm: &aclpb.ACLChange_UserConfirm{
|
||||
Identity: t.keychain.GetIdentity(confirm.Identity),
|
||||
UserAddId: confirm.UserAddId,
|
||||
},
|
||||
},
|
||||
}
|
||||
case ch.UserPermissionChange != nil:
|
||||
permissionChange := ch.UserPermissionChange
|
||||
|
||||
convCh = &aclpb.ACLChange_ACLContentValue{
|
||||
Value: &aclpb.ACLChange_ACLContentValueValueOfUserPermissionChange{
|
||||
UserPermissionChange: &aclpb.ACLChange_UserPermissionChange{
|
||||
Identity: t.keychain.GetIdentity(permissionChange.Identity),
|
||||
Permissions: t.convertPermission(permissionChange.Permission),
|
||||
},
|
||||
},
|
||||
}
|
||||
case ch.UserRemove != nil:
|
||||
remove := ch.UserRemove
|
||||
|
||||
newReadKey := t.keychain.GetKey(remove.NewReadKey).(*SymKey)
|
||||
|
||||
var replaces []*aclpb.ACLChangeReadKeyReplace
|
||||
for _, id := range remove.IdentitiesLeft {
|
||||
identity := t.keychain.GetIdentity(id)
|
||||
encKey := t.keychain.EncryptionKeys[id]
|
||||
rawEncKey, _ := encKey.GetPublic().Raw()
|
||||
encReadKey, err := encKey.GetPublic().Encrypt(newReadKey.Key.Bytes())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
replaces = append(replaces, &aclpb.ACLChangeReadKeyReplace{
|
||||
Identity: identity,
|
||||
EncryptionKey: rawEncKey,
|
||||
EncryptedReadKey: encReadKey,
|
||||
})
|
||||
}
|
||||
|
||||
convCh = &aclpb.ACLChange_ACLContentValue{
|
||||
Value: &aclpb.ACLChange_ACLContentValueValueOfUserRemove{
|
||||
UserRemove: &aclpb.ACLChange_UserRemove{
|
||||
Identity: t.keychain.GetIdentity(remove.RemovedIdentity),
|
||||
ReadKeyReplaces: replaces,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
if convCh == nil {
|
||||
panic("cannot have empty acl change")
|
||||
}
|
||||
|
||||
return convCh
|
||||
}
|
||||
|
||||
func (t *TreeStorageBuilder) encryptReadKeys(keys []string, encKey encryptionkey.PrivKey) (enc [][]byte) {
|
||||
for _, k := range keys {
|
||||
realKey := t.keychain.GetKey(k).(*SymKey).Key.Bytes()
|
||||
res, err := encKey.GetPublic().Encrypt(realKey)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
enc = append(enc, res)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (t *TreeStorageBuilder) convertPermission(perm string) aclpb.ACLChange_UserPermissions {
|
||||
switch perm {
|
||||
case "admin":
|
||||
return aclpb.ACLChange_Admin
|
||||
case "writer":
|
||||
return aclpb.ACLChange_Writer
|
||||
case "reader":
|
||||
return aclpb.ACLChange_Reader
|
||||
default:
|
||||
panic(fmt.Sprintf("incorrect permission: %s", perm))
|
||||
}
|
||||
}
|
||||
|
||||
func (t *TreeStorageBuilder) traverseFromHeads(f func(t *treeChange) error) error {
|
||||
uniqMap := map[string]struct{}{}
|
||||
stack := make([]string, len(t.orphans), 10)
|
||||
copy(stack, t.orphans)
|
||||
for len(stack) > 0 {
|
||||
id := stack[len(stack)-1]
|
||||
stack = stack[:len(stack)-1]
|
||||
if _, exists := uniqMap[id]; exists {
|
||||
continue
|
||||
}
|
||||
|
||||
ch := t.allChanges[id]
|
||||
uniqMap[id] = struct{}{}
|
||||
if err := f(ch); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, prev := range ch.ACLChange.TreeHeadIds {
|
||||
stack = append(stack, prev)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *TreeStorageBuilder) parseUpdates(updates []*Update) {
|
||||
for _, update := range updates {
|
||||
useCase := &updateUseCase{
|
||||
changes: map[string]*treeChange{},
|
||||
}
|
||||
for _, ch := range update.Changes {
|
||||
newChange := t.parseChange(ch)
|
||||
useCase.changes[newChange.id] = newChange
|
||||
}
|
||||
for _, node := range update.Graph {
|
||||
rec := useCase.changes[node.Id]
|
||||
rec.AclHeadIds = node.ACLHeads
|
||||
rec.TreeHeadIds = node.TreeHeads
|
||||
rec.SnapshotBaseId = node.BaseSnapshot
|
||||
}
|
||||
|
||||
t.updates[update.UseCase] = useCase
|
||||
}
|
||||
}
|
||||
|
||||
func (t *TreeStorageBuilder) parseGraph(tree *YMLTree) {
|
||||
for _, node := range tree.Graph {
|
||||
rec := t.allChanges[node.Id]
|
||||
rec.AclHeadIds = node.ACLHeads
|
||||
rec.TreeHeadIds = node.TreeHeads
|
||||
rec.SnapshotBaseId = node.BaseSnapshot
|
||||
}
|
||||
}
|
||||
|
||||
func (t *TreeStorageBuilder) parseOrphans(tree *YMLTree) {
|
||||
t.orphans = tree.Orphans
|
||||
}
|
||||
|
||||
func (t *TreeStorageBuilder) parseHeader(tree *YMLTree) {
|
||||
t.header = &storagepb.TreeHeader{
|
||||
FirstChangeId: tree.Header.FirstChangeId,
|
||||
IsWorkspace: tree.Header.IsWorkspace,
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,162 @@
|
||||
//go:build (linux || darwin) && !android && !ios && !nographviz && (amd64 || arm64)
|
||||
// +build linux darwin
|
||||
// +build !android
|
||||
// +build !ios
|
||||
// +build !nographviz
|
||||
// +build amd64 arm64
|
||||
|
||||
package treestoragebuilder
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
testpb "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/testutils/testchanges/testchangepb"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
"github.com/awalterschulze/gographviz"
|
||||
)
|
||||
|
||||
// To quickly look at visualized string you can use https://dreampuf.github.io/GraphvizOnline
|
||||
|
||||
type EdgeParameters struct {
|
||||
style string
|
||||
color string
|
||||
label string
|
||||
}
|
||||
|
||||
func (t *TreeStorageBuilder) Graph() (string, error) {
|
||||
// TODO: check updates on https://github.com/goccy/go-graphviz/issues/52 or make a fix yourself to use better library here
|
||||
graph := gographviz.NewGraph()
|
||||
graph.SetName("G")
|
||||
graph.SetDir(true)
|
||||
var nodes = make(map[string]struct{})
|
||||
|
||||
var addNodes = func(r *treeChange) error {
|
||||
// TODO: revisit function after checking
|
||||
|
||||
style := "solid"
|
||||
if r.GetAclData() != nil {
|
||||
style = "filled"
|
||||
} else if r.changesDataDecrypted != nil {
|
||||
style = "dashed"
|
||||
}
|
||||
|
||||
var chSymbs []string
|
||||
if r.changesDataDecrypted != nil {
|
||||
res := &testpb.PlainTextChange_Data{}
|
||||
err := proto.Unmarshal(r.changesDataDecrypted, res)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, chc := range res.Content {
|
||||
tp := fmt.Sprintf("%T", chc.Value)
|
||||
tp = strings.Replace(tp, "ChangeContent_Value_", "", 1)
|
||||
res := ""
|
||||
for _, ts := range tp {
|
||||
if unicode.IsUpper(ts) {
|
||||
res += string(ts)
|
||||
}
|
||||
}
|
||||
chSymbs = append(chSymbs, res)
|
||||
}
|
||||
}
|
||||
if r.GetAclData() != nil {
|
||||
for _, chc := range r.GetAclData().AclContent {
|
||||
tp := fmt.Sprintf("%T", chc.Value)
|
||||
tp = strings.Replace(tp, "ACLChange_ACLContentValueValueOf", "", 1)
|
||||
res := ""
|
||||
for _, ts := range tp {
|
||||
if unicode.IsUpper(ts) {
|
||||
res += string(ts)
|
||||
}
|
||||
}
|
||||
chSymbs = append(chSymbs, res)
|
||||
}
|
||||
}
|
||||
|
||||
shortId := r.id
|
||||
label := fmt.Sprintf("Id: %s\nChanges: %s\n",
|
||||
shortId,
|
||||
strings.Join(chSymbs, ","),
|
||||
)
|
||||
e := graph.AddNode("G", "\""+r.id+"\"", map[string]string{
|
||||
"label": "\"" + label + "\"",
|
||||
"style": "\"" + style + "\"",
|
||||
})
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
nodes[r.id] = struct{}{}
|
||||
return nil
|
||||
}
|
||||
|
||||
var createEdge = func(firstId, secondId string, params EdgeParameters) error {
|
||||
_, exists := nodes[firstId]
|
||||
if !exists {
|
||||
return fmt.Errorf("no such node")
|
||||
}
|
||||
_, exists = nodes[secondId]
|
||||
if !exists {
|
||||
return fmt.Errorf("no previous node")
|
||||
}
|
||||
|
||||
err := graph.AddEdge("\""+firstId+"\"", "\""+secondId+"\"", true, map[string]string{
|
||||
"color": params.color,
|
||||
"style": params.style,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var addLinks = func(t *treeChange) error {
|
||||
for _, prevId := range t.AclHeadIds {
|
||||
err := createEdge(t.id, prevId, EdgeParameters{
|
||||
style: "dashed",
|
||||
color: "red",
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
for _, prevId := range t.TreeHeadIds {
|
||||
err := createEdge(t.id, prevId, EdgeParameters{
|
||||
style: "dashed",
|
||||
color: "blue",
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if t.SnapshotBaseId != "" {
|
||||
err := createEdge(t.id, t.SnapshotBaseId, EdgeParameters{
|
||||
style: "bold",
|
||||
color: "blue",
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
err := t.traverseFromHeads(addNodes)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
err = t.traverseFromHeads(addLinks)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return graph.String(), nil
|
||||
}
|
||||
@ -5,18 +5,20 @@
|
||||
// +build !nographviz
|
||||
// +build amd64 arm64
|
||||
|
||||
package tree
|
||||
package acltree
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"github.com/goccy/go-graphviz"
|
||||
"github.com/goccy/go-graphviz/cgraph"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode"
|
||||
|
||||
"github.com/goccy/go-graphviz"
|
||||
"github.com/goccy/go-graphviz/cgraph"
|
||||
)
|
||||
|
||||
func (t *Tree) Graph(parser DescriptionParser) (data string, err error) {
|
||||
func (t *Tree) Graph() (data string, err error) {
|
||||
var order = make(map[string]string)
|
||||
var seq = 0
|
||||
t.Iterate(t.RootId(), func(c *Change) (isContinue bool) {
|
||||
@ -44,15 +46,44 @@ func (t *Tree) Graph(parser DescriptionParser) (data string, err error) {
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
if c.Content.GetAclData() != nil {
|
||||
n.SetStyle(cgraph.FilledNodeStyle)
|
||||
} else if c.IsSnapshot {
|
||||
n.SetStyle(cgraph.DashedNodeStyle)
|
||||
}
|
||||
nodes[c.Id] = n
|
||||
ord := order[c.Id]
|
||||
if ord == "" {
|
||||
ord = "miss"
|
||||
}
|
||||
chSymbs, err := parser.ParseChange(c)
|
||||
if err != nil {
|
||||
return err
|
||||
var chSymbs []string
|
||||
if c.Content.AclData != nil {
|
||||
for _, chc := range c.Content.AclData.AclContent {
|
||||
tp := fmt.Sprintf("%T", chc.Value)
|
||||
tp = strings.Replace(tp, "ACLChange_ACLContentValueValueOf", "", 1)
|
||||
res := ""
|
||||
for _, ts := range tp {
|
||||
if unicode.IsUpper(ts) {
|
||||
res += string(ts)
|
||||
}
|
||||
}
|
||||
chSymbs = append(chSymbs, res)
|
||||
}
|
||||
}
|
||||
if c.DecryptedDocumentChange != nil {
|
||||
// TODO: add some parser to provide custom unmarshalling for the document change
|
||||
//for _, chc := range c.DecryptedDocumentChange.Content {
|
||||
// tp := fmt.Sprintf("%T", chc.Value)
|
||||
// tp = strings.Replace(tp, "ChangeContent_Value_", "", 1)
|
||||
// res := ""
|
||||
// for _, ts := range tp {
|
||||
// if unicode.IsUpper(ts) {
|
||||
// res += string(ts)
|
||||
// }
|
||||
// }
|
||||
// chSymbs = append(chSymbs, res)
|
||||
//}
|
||||
chSymbs = append(chSymbs, "DEC")
|
||||
}
|
||||
|
||||
shortId := c.Id
|
||||
|
||||
@ -2,16 +2,14 @@ package document
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/app"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list"
|
||||
testchanges "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/testutils/testchanges/proto"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/acltree"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/testutils/testchanges/testchangepb"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treestorage/treepb"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/service/account"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/service/node"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/service/storage"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/service/sync/message"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/service/treecache"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/syncproto"
|
||||
@ -27,14 +25,13 @@ type service struct {
|
||||
messageService message.Service
|
||||
treeCache treecache.Service
|
||||
account account.Service
|
||||
storage storage.Service
|
||||
// to create new documents we need to know all nodes
|
||||
nodes []*node.Node
|
||||
}
|
||||
|
||||
type Service interface {
|
||||
UpdateDocumentTree(ctx context.Context, id, text string) error
|
||||
CreateDocumentTree(ctx context.Context, aclTreeId string, text string) (id string, err error)
|
||||
UpdateDocument(ctx context.Context, id, text string) error
|
||||
CreateDocument(ctx context.Context, text string) (string, error)
|
||||
}
|
||||
|
||||
func New() app.Component {
|
||||
@ -45,7 +42,6 @@ func (s *service) Init(ctx context.Context, a *app.App) (err error) {
|
||||
s.account = a.MustComponent(account.CName).(account.Service)
|
||||
s.messageService = a.MustComponent(message.CName).(message.Service)
|
||||
s.treeCache = a.MustComponent(treecache.CName).(treecache.Service)
|
||||
s.storage = a.MustComponent(storage.CName).(storage.Service)
|
||||
|
||||
nodesService := a.MustComponent(node.CName).(node.Service)
|
||||
s.nodes = nodesService.Nodes()
|
||||
@ -58,65 +54,41 @@ func (s *service) Name() (name string) {
|
||||
}
|
||||
|
||||
func (s *service) Run(ctx context.Context) (err error) {
|
||||
syncData := s.storage.ImportedACLSyncData()
|
||||
|
||||
// we could have added a timeout or some additional logic,
|
||||
// but let's just use the ACL id of the latest started node :-)
|
||||
return s.messageService.SendToSpaceAsync("", syncproto.WrapACLList(
|
||||
&syncproto.SyncACLList{Records: syncData.Records},
|
||||
syncData.Header,
|
||||
syncData.Id,
|
||||
))
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *service) Close(ctx context.Context) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *service) UpdateDocumentTree(ctx context.Context, id, text string) (err error) {
|
||||
func (s *service) UpdateDocument(ctx context.Context, id, text string) (err error) {
|
||||
var (
|
||||
ch *aclpb.RawChange
|
||||
header *aclpb.Header
|
||||
header *treepb.TreeHeader
|
||||
snapshotPath []string
|
||||
heads []string
|
||||
)
|
||||
log.With(zap.String("id", id), zap.String("text", text)).
|
||||
Debug("updating document")
|
||||
|
||||
err = s.treeCache.Do(ctx, id, func(obj interface{}) error {
|
||||
docTree, ok := obj.(tree.ObjectTree)
|
||||
if !ok {
|
||||
return fmt.Errorf("can't update acl trees with text")
|
||||
}
|
||||
|
||||
docTree.Lock()
|
||||
defer docTree.Unlock()
|
||||
err = s.treeCache.Do(ctx, docTree.Header().AclListId, func(obj interface{}) error {
|
||||
aclTree := obj.(list.ACLList)
|
||||
aclTree.RLock()
|
||||
defer aclTree.RUnlock()
|
||||
|
||||
content := createAppendTextChange(text)
|
||||
signable := tree.SignableChangeContent{
|
||||
Proto: content,
|
||||
Key: s.account.Account().SignKey,
|
||||
Identity: s.account.Account().Identity,
|
||||
IsSnapshot: false,
|
||||
}
|
||||
ch, err = docTree.AddContent(ctx, signable)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = s.treeCache.Do(ctx, id, func(tree acltree.ACLTree) error {
|
||||
ch, err = tree.AddContent(ctx, func(builder acltree.ChangeBuilder) error {
|
||||
builder.AddChangeContent(
|
||||
&testchangepb.PlainTextChange_Data{
|
||||
Content: []*testchangepb.PlainTextChange_Content{
|
||||
createAppendTextChangeContent(text),
|
||||
},
|
||||
})
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
id = docTree.ID()
|
||||
heads = docTree.Heads()
|
||||
header = docTree.Header()
|
||||
snapshotPath = docTree.SnapshotPath()
|
||||
id = tree.ID()
|
||||
heads = tree.Heads()
|
||||
header = tree.Header()
|
||||
snapshotPath = tree.SnapshotPath()
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
@ -128,90 +100,87 @@ func (s *service) UpdateDocumentTree(ctx context.Context, id, text string) (err
|
||||
zap.String("header", header.String())).
|
||||
Debug("document updated in the database")
|
||||
|
||||
return s.messageService.SendToSpaceAsync("", syncproto.WrapHeadUpdate(&syncproto.SyncHeadUpdate{
|
||||
return s.messageService.SendToSpaceAsync("", syncproto.WrapHeadUpdate(&syncproto.Sync_HeadUpdate{
|
||||
Heads: heads,
|
||||
Changes: []*aclpb.RawChange{ch},
|
||||
TreeId: id,
|
||||
SnapshotPath: snapshotPath,
|
||||
}, header, id))
|
||||
TreeHeader: header,
|
||||
}))
|
||||
}
|
||||
|
||||
func (s *service) CreateDocumentTree(ctx context.Context, aclListId string, text string) (id string, err error) {
|
||||
func (s *service) CreateDocument(ctx context.Context, text string) (id string, err error) {
|
||||
acc := s.account.Account()
|
||||
var (
|
||||
ch *aclpb.RawChange
|
||||
header *aclpb.Header
|
||||
header *treepb.TreeHeader
|
||||
snapshotPath []string
|
||||
heads []string
|
||||
)
|
||||
err = s.treeCache.Do(ctx, aclListId, func(obj interface{}) error {
|
||||
t := obj.(list.ACLList)
|
||||
t.RLock()
|
||||
defer t.RUnlock()
|
||||
|
||||
content := createInitialTextChange(text)
|
||||
doc, err := tree.CreateNewTreeStorage(acc, t, content, s.storage.CreateTreeStorage)
|
||||
err = s.treeCache.Create(ctx, func(builder acltree.ChangeBuilder) error {
|
||||
err := builder.UserAdd(acc.Identity, acc.EncKey.GetPublic(), aclpb.ACLChange_Admin)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
id, err = doc.ID()
|
||||
// adding all predefined nodes to the document as admins
|
||||
for _, n := range s.nodes {
|
||||
err = builder.UserAdd(n.SigningKeyString, n.EncryptionKey, aclpb.ACLChange_Admin)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
header, err = doc.Header()
|
||||
builder.AddChangeContent(createInitialChangeContent(text))
|
||||
return nil
|
||||
}, func(tree acltree.ACLTree) error {
|
||||
id = tree.ID()
|
||||
heads = tree.Heads()
|
||||
header = tree.Header()
|
||||
snapshotPath = tree.SnapshotPath()
|
||||
ch, err = tree.Storage().GetChange(ctx, heads[0])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
heads = []string{header.FirstId}
|
||||
snapshotPath = []string{header.FirstId}
|
||||
ch, err = doc.GetRawChange(ctx, header.FirstId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log.With(
|
||||
zap.String("id", id),
|
||||
zap.Strings("heads", heads),
|
||||
zap.String("header", header.String())).
|
||||
Debug("document created in the database")
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
log.With(zap.String("id", id), zap.String("text", text)).
|
||||
Debug("creating document")
|
||||
|
||||
err = s.messageService.SendToSpaceAsync("", syncproto.WrapHeadUpdate(&syncproto.SyncHeadUpdate{
|
||||
err = s.messageService.SendToSpaceAsync("", syncproto.WrapHeadUpdate(&syncproto.Sync_HeadUpdate{
|
||||
Heads: heads,
|
||||
Changes: []*aclpb.RawChange{ch},
|
||||
TreeId: id,
|
||||
SnapshotPath: snapshotPath,
|
||||
}, header, id))
|
||||
TreeHeader: header,
|
||||
}))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return id, err
|
||||
}
|
||||
|
||||
func createInitialTextChange(text string) proto.Marshaler {
|
||||
return &testchanges.PlainTextChangeData{
|
||||
Content: []*testchanges.PlainTextChangeContent{
|
||||
func createInitialChangeContent(text string) proto.Marshaler {
|
||||
return &testchangepb.PlainTextChange_Data{
|
||||
Content: []*testchangepb.PlainTextChange_Content{
|
||||
createAppendTextChangeContent(text),
|
||||
},
|
||||
Snapshot: &testchanges.PlainTextChangeSnapshot{Text: text},
|
||||
Snapshot: &testchangepb.PlainTextChange_Snapshot{Text: text},
|
||||
}
|
||||
}
|
||||
|
||||
func createAppendTextChange(text string) proto.Marshaler {
|
||||
return &testchanges.PlainTextChangeData{
|
||||
Content: []*testchanges.PlainTextChangeContent{
|
||||
createAppendTextChangeContent(text),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func createAppendTextChangeContent(text string) *testchanges.PlainTextChangeContent {
|
||||
return &testchanges.PlainTextChangeContent{
|
||||
Value: &testchanges.PlainTextChangeContentValueOfTextAppend{
|
||||
TextAppend: &testchanges.PlainTextChangeTextAppend{
|
||||
func createAppendTextChangeContent(text string) *testchangepb.PlainTextChange_Content {
|
||||
return &testchangepb.PlainTextChange_Content{
|
||||
Value: &testchangepb.PlainTextChange_Content_TextAppend{
|
||||
TextAppend: &testchangepb.PlainTextChange_TextAppend{
|
||||
Text: text,
|
||||
},
|
||||
},
|
||||
|
||||
@ -48,7 +48,7 @@ func (m *Message) ReplyType(tp syncproto.MessageType, data proto.Marshaler) (err
|
||||
|
||||
func (m *Message) Ack() (err error) {
|
||||
ack := &syncproto.System{
|
||||
Ack: &syncproto.SystemAck{},
|
||||
Ack: &syncproto.System_Ack{},
|
||||
}
|
||||
data, err := ack.Marshal()
|
||||
if err != nil {
|
||||
@ -78,10 +78,10 @@ func (m *Message) Ack() (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (m *Message) AckError(code syncproto.SystemErrorCode, description string) (err error) {
|
||||
func (m *Message) AckError(code syncproto.System_Error_Code, description string) (err error) {
|
||||
ack := &syncproto.System{
|
||||
Ack: &syncproto.SystemAck{
|
||||
Error: &syncproto.SystemError{
|
||||
Ack: &syncproto.System_Ack{
|
||||
Error: &syncproto.System_Error{
|
||||
Code: code,
|
||||
Description: description,
|
||||
},
|
||||
|
||||
@ -25,9 +25,9 @@ type remote struct {
|
||||
|
||||
func (r remote) Ranges(ctx context.Context, ranges []ldiff.Range, resBuf []ldiff.RangeResult) (results []ldiff.RangeResult, err error) {
|
||||
results = resBuf[:0]
|
||||
pbRanges := make([]*spacesync.DiffRangeRequestRange, 0, len(ranges))
|
||||
pbRanges := make([]*spacesync.DiffRange_Request_Range, 0, len(ranges))
|
||||
for _, rg := range ranges {
|
||||
pbRanges = append(pbRanges, &spacesync.DiffRangeRequestRange{
|
||||
pbRanges = append(pbRanges, &spacesync.DiffRange_Request_Range{
|
||||
From: rg.From,
|
||||
To: rg.To,
|
||||
Limit: uint32(rg.Limit),
|
||||
@ -35,10 +35,10 @@ func (r remote) Ranges(ctx context.Context, ranges []ldiff.Range, resBuf []ldiff
|
||||
}
|
||||
req := &spacesync.Space{
|
||||
SpaceId: r.spaceId,
|
||||
Message: &spacesync.SpaceContent{
|
||||
Value: &spacesync.SpaceContentValueOfDiffRange{
|
||||
Message: &spacesync.Space_Content{
|
||||
Value: &spacesync.Space_Content_DiffRange{
|
||||
DiffRange: &spacesync.DiffRange{
|
||||
Request: &spacesync.DiffRangeRequest{
|
||||
Request: &spacesync.DiffRange_Request{
|
||||
Ranges: pbRanges,
|
||||
},
|
||||
},
|
||||
@ -99,21 +99,21 @@ func HandlerRangeRequest(ctx context.Context, d ldiff.Diff, diffRange *spacesync
|
||||
return
|
||||
}
|
||||
|
||||
var rangeResp = &spacesync.DiffRangeResponse{
|
||||
Results: make([]*spacesync.DiffRangeResponseResult, len(res)),
|
||||
var rangeResp = &spacesync.DiffRange_Response{
|
||||
Results: make([]*spacesync.DiffRange_Response_Result, len(res)),
|
||||
}
|
||||
for _, rangeRes := range res {
|
||||
var elements []*spacesync.DiffRangeResponseResultElement
|
||||
var elements []*spacesync.DiffRange_Response_Result_Element
|
||||
if len(rangeRes.Elements) > 0 {
|
||||
elements = make([]*spacesync.DiffRangeResponseResultElement, 0, len(rangeRes.Elements))
|
||||
elements = make([]*spacesync.DiffRange_Response_Result_Element, 0, len(rangeRes.Elements))
|
||||
for _, el := range rangeRes.Elements {
|
||||
elements = append(elements, &spacesync.DiffRangeResponseResultElement{
|
||||
elements = append(elements, &spacesync.DiffRange_Response_Result_Element{
|
||||
Id: el.Id,
|
||||
Head: el.Head,
|
||||
})
|
||||
}
|
||||
}
|
||||
rangeResp.Results = append(rangeResp.Results, &spacesync.DiffRangeResponseResult{
|
||||
rangeResp.Results = append(rangeResp.Results, &spacesync.DiffRange_Response_Result{
|
||||
Hash: rangeRes.Hash,
|
||||
Elements: elements,
|
||||
Count: uint32(rangeRes.Count),
|
||||
|
||||
@ -78,10 +78,9 @@ func (s *service) Handle(ctx context.Context, data []byte) (resp proto.Marshaler
|
||||
return
|
||||
}
|
||||
if spaceReq.SpaceId != "" {
|
||||
var sp Space
|
||||
sp, err = s.get(ctx, spaceReq.SpaceId)
|
||||
if err != nil {
|
||||
return
|
||||
sp, e := s.get(ctx, spaceReq.SpaceId)
|
||||
if e != nil {
|
||||
return nil, e
|
||||
}
|
||||
return sp.Handle(ctx, spaceReq)
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ func (s *space) Handle(ctx context.Context, msg *spacesync.Space) (repl *spacesy
|
||||
return nil, er
|
||||
}
|
||||
return &spacesync.Space{SpaceId: s.id, Message: &spacesync.SpaceContent{
|
||||
Value: &spacesync.SpaceContentValueOfDiffRange{
|
||||
Value: &spacesync.SpaceContent_Value_DiffRange{
|
||||
DiffRange: resp,
|
||||
},
|
||||
}}, nil
|
||||
|
||||
@ -24,7 +24,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
type Space struct {
|
||||
SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"`
|
||||
Message *SpaceContent `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
|
||||
Message *Space_Content `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
|
||||
}
|
||||
|
||||
func (m *Space) Reset() { *m = Space{} }
|
||||
@ -67,31 +67,32 @@ func (m *Space) GetSpaceId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Space) GetMessage() *SpaceContent {
|
||||
func (m *Space) GetMessage() *Space_Content {
|
||||
if m != nil {
|
||||
return m.Message
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type SpaceContent struct {
|
||||
type Space_Content struct {
|
||||
// Types that are valid to be assigned to Value:
|
||||
// *SpaceContentValueOfDiffRange
|
||||
Value IsSpaceContentValue `protobuf_oneof:"value"`
|
||||
//
|
||||
// *Space_Content_DiffRange
|
||||
Value isSpace_Content_Value `protobuf_oneof:"value"`
|
||||
}
|
||||
|
||||
func (m *SpaceContent) Reset() { *m = SpaceContent{} }
|
||||
func (m *SpaceContent) String() string { return proto.CompactTextString(m) }
|
||||
func (*SpaceContent) ProtoMessage() {}
|
||||
func (*SpaceContent) Descriptor() ([]byte, []int) {
|
||||
func (m *Space_Content) Reset() { *m = Space_Content{} }
|
||||
func (m *Space_Content) String() string { return proto.CompactTextString(m) }
|
||||
func (*Space_Content) ProtoMessage() {}
|
||||
func (*Space_Content) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_11d78c2fb7c80384, []int{0, 0}
|
||||
}
|
||||
func (m *SpaceContent) XXX_Unmarshal(b []byte) error {
|
||||
func (m *Space_Content) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *SpaceContent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
func (m *Space_Content) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_SpaceContent.Marshal(b, m, deterministic)
|
||||
return xxx_messageInfo_Space_Content.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
@ -101,54 +102,54 @@ func (m *SpaceContent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *SpaceContent) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_SpaceContent.Merge(m, src)
|
||||
func (m *Space_Content) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Space_Content.Merge(m, src)
|
||||
}
|
||||
func (m *SpaceContent) XXX_Size() int {
|
||||
func (m *Space_Content) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *SpaceContent) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_SpaceContent.DiscardUnknown(m)
|
||||
func (m *Space_Content) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Space_Content.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_SpaceContent proto.InternalMessageInfo
|
||||
var xxx_messageInfo_Space_Content proto.InternalMessageInfo
|
||||
|
||||
type IsSpaceContentValue interface {
|
||||
IsSpaceContentValue()
|
||||
type isSpace_Content_Value interface {
|
||||
isSpace_Content_Value()
|
||||
MarshalTo([]byte) (int, error)
|
||||
Size() int
|
||||
}
|
||||
|
||||
type SpaceContentValueOfDiffRange struct {
|
||||
type Space_Content_DiffRange struct {
|
||||
DiffRange *DiffRange `protobuf:"bytes,1,opt,name=diffRange,proto3,oneof" json:"diffRange,omitempty"`
|
||||
}
|
||||
|
||||
func (*SpaceContentValueOfDiffRange) IsSpaceContentValue() {}
|
||||
func (*Space_Content_DiffRange) isSpace_Content_Value() {}
|
||||
|
||||
func (m *SpaceContent) GetValue() IsSpaceContentValue {
|
||||
func (m *Space_Content) GetValue() isSpace_Content_Value {
|
||||
if m != nil {
|
||||
return m.Value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *SpaceContent) GetDiffRange() *DiffRange {
|
||||
if x, ok := m.GetValue().(*SpaceContentValueOfDiffRange); ok {
|
||||
func (m *Space_Content) GetDiffRange() *DiffRange {
|
||||
if x, ok := m.GetValue().(*Space_Content_DiffRange); ok {
|
||||
return x.DiffRange
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// XXX_OneofWrappers is for the internal use of the proto package.
|
||||
func (*SpaceContent) XXX_OneofWrappers() []interface{} {
|
||||
func (*Space_Content) XXX_OneofWrappers() []interface{} {
|
||||
return []interface{}{
|
||||
(*SpaceContentValueOfDiffRange)(nil),
|
||||
(*Space_Content_DiffRange)(nil),
|
||||
}
|
||||
}
|
||||
|
||||
type DiffRange struct {
|
||||
Request *DiffRangeRequest `protobuf:"bytes,1,opt,name=request,proto3" json:"request,omitempty"`
|
||||
Response *DiffRangeResponse `protobuf:"bytes,2,opt,name=response,proto3" json:"response,omitempty"`
|
||||
Request *DiffRange_Request `protobuf:"bytes,1,opt,name=request,proto3" json:"request,omitempty"`
|
||||
Response *DiffRange_Response `protobuf:"bytes,2,opt,name=response,proto3" json:"response,omitempty"`
|
||||
}
|
||||
|
||||
func (m *DiffRange) Reset() { *m = DiffRange{} }
|
||||
@ -184,36 +185,36 @@ func (m *DiffRange) XXX_DiscardUnknown() {
|
||||
|
||||
var xxx_messageInfo_DiffRange proto.InternalMessageInfo
|
||||
|
||||
func (m *DiffRange) GetRequest() *DiffRangeRequest {
|
||||
func (m *DiffRange) GetRequest() *DiffRange_Request {
|
||||
if m != nil {
|
||||
return m.Request
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *DiffRange) GetResponse() *DiffRangeResponse {
|
||||
func (m *DiffRange) GetResponse() *DiffRange_Response {
|
||||
if m != nil {
|
||||
return m.Response
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type DiffRangeRequest struct {
|
||||
Ranges []*DiffRangeRequestRange `protobuf:"bytes,1,rep,name=ranges,proto3" json:"ranges,omitempty"`
|
||||
type DiffRange_Request struct {
|
||||
Ranges []*DiffRange_Request_Range `protobuf:"bytes,1,rep,name=ranges,proto3" json:"ranges,omitempty"`
|
||||
}
|
||||
|
||||
func (m *DiffRangeRequest) Reset() { *m = DiffRangeRequest{} }
|
||||
func (m *DiffRangeRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*DiffRangeRequest) ProtoMessage() {}
|
||||
func (*DiffRangeRequest) Descriptor() ([]byte, []int) {
|
||||
func (m *DiffRange_Request) Reset() { *m = DiffRange_Request{} }
|
||||
func (m *DiffRange_Request) String() string { return proto.CompactTextString(m) }
|
||||
func (*DiffRange_Request) ProtoMessage() {}
|
||||
func (*DiffRange_Request) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_11d78c2fb7c80384, []int{1, 0}
|
||||
}
|
||||
func (m *DiffRangeRequest) XXX_Unmarshal(b []byte) error {
|
||||
func (m *DiffRange_Request) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *DiffRangeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
func (m *DiffRange_Request) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_DiffRangeRequest.Marshal(b, m, deterministic)
|
||||
return xxx_messageInfo_DiffRange_Request.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
@ -223,43 +224,43 @@ func (m *DiffRangeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, er
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *DiffRangeRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_DiffRangeRequest.Merge(m, src)
|
||||
func (m *DiffRange_Request) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_DiffRange_Request.Merge(m, src)
|
||||
}
|
||||
func (m *DiffRangeRequest) XXX_Size() int {
|
||||
func (m *DiffRange_Request) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *DiffRangeRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_DiffRangeRequest.DiscardUnknown(m)
|
||||
func (m *DiffRange_Request) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_DiffRange_Request.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_DiffRangeRequest proto.InternalMessageInfo
|
||||
var xxx_messageInfo_DiffRange_Request proto.InternalMessageInfo
|
||||
|
||||
func (m *DiffRangeRequest) GetRanges() []*DiffRangeRequestRange {
|
||||
func (m *DiffRange_Request) GetRanges() []*DiffRange_Request_Range {
|
||||
if m != nil {
|
||||
return m.Ranges
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type DiffRangeRequestRange struct {
|
||||
type DiffRange_Request_Range struct {
|
||||
From uint64 `protobuf:"varint,1,opt,name=from,proto3" json:"from,omitempty"`
|
||||
To uint64 `protobuf:"varint,2,opt,name=to,proto3" json:"to,omitempty"`
|
||||
Limit uint32 `protobuf:"varint,3,opt,name=limit,proto3" json:"limit,omitempty"`
|
||||
}
|
||||
|
||||
func (m *DiffRangeRequestRange) Reset() { *m = DiffRangeRequestRange{} }
|
||||
func (m *DiffRangeRequestRange) String() string { return proto.CompactTextString(m) }
|
||||
func (*DiffRangeRequestRange) ProtoMessage() {}
|
||||
func (*DiffRangeRequestRange) Descriptor() ([]byte, []int) {
|
||||
func (m *DiffRange_Request_Range) Reset() { *m = DiffRange_Request_Range{} }
|
||||
func (m *DiffRange_Request_Range) String() string { return proto.CompactTextString(m) }
|
||||
func (*DiffRange_Request_Range) ProtoMessage() {}
|
||||
func (*DiffRange_Request_Range) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_11d78c2fb7c80384, []int{1, 0, 0}
|
||||
}
|
||||
func (m *DiffRangeRequestRange) XXX_Unmarshal(b []byte) error {
|
||||
func (m *DiffRange_Request_Range) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *DiffRangeRequestRange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
func (m *DiffRange_Request_Range) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_DiffRangeRequestRange.Marshal(b, m, deterministic)
|
||||
return xxx_messageInfo_DiffRange_Request_Range.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
@ -269,55 +270,55 @@ func (m *DiffRangeRequestRange) XXX_Marshal(b []byte, deterministic bool) ([]byt
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *DiffRangeRequestRange) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_DiffRangeRequestRange.Merge(m, src)
|
||||
func (m *DiffRange_Request_Range) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_DiffRange_Request_Range.Merge(m, src)
|
||||
}
|
||||
func (m *DiffRangeRequestRange) XXX_Size() int {
|
||||
func (m *DiffRange_Request_Range) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *DiffRangeRequestRange) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_DiffRangeRequestRange.DiscardUnknown(m)
|
||||
func (m *DiffRange_Request_Range) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_DiffRange_Request_Range.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_DiffRangeRequestRange proto.InternalMessageInfo
|
||||
var xxx_messageInfo_DiffRange_Request_Range proto.InternalMessageInfo
|
||||
|
||||
func (m *DiffRangeRequestRange) GetFrom() uint64 {
|
||||
func (m *DiffRange_Request_Range) GetFrom() uint64 {
|
||||
if m != nil {
|
||||
return m.From
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *DiffRangeRequestRange) GetTo() uint64 {
|
||||
func (m *DiffRange_Request_Range) GetTo() uint64 {
|
||||
if m != nil {
|
||||
return m.To
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *DiffRangeRequestRange) GetLimit() uint32 {
|
||||
func (m *DiffRange_Request_Range) GetLimit() uint32 {
|
||||
if m != nil {
|
||||
return m.Limit
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type DiffRangeResponse struct {
|
||||
Results []*DiffRangeResponseResult `protobuf:"bytes,1,rep,name=results,proto3" json:"results,omitempty"`
|
||||
type DiffRange_Response struct {
|
||||
Results []*DiffRange_Response_Result `protobuf:"bytes,1,rep,name=results,proto3" json:"results,omitempty"`
|
||||
}
|
||||
|
||||
func (m *DiffRangeResponse) Reset() { *m = DiffRangeResponse{} }
|
||||
func (m *DiffRangeResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*DiffRangeResponse) ProtoMessage() {}
|
||||
func (*DiffRangeResponse) Descriptor() ([]byte, []int) {
|
||||
func (m *DiffRange_Response) Reset() { *m = DiffRange_Response{} }
|
||||
func (m *DiffRange_Response) String() string { return proto.CompactTextString(m) }
|
||||
func (*DiffRange_Response) ProtoMessage() {}
|
||||
func (*DiffRange_Response) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_11d78c2fb7c80384, []int{1, 1}
|
||||
}
|
||||
func (m *DiffRangeResponse) XXX_Unmarshal(b []byte) error {
|
||||
func (m *DiffRange_Response) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *DiffRangeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
func (m *DiffRange_Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_DiffRangeResponse.Marshal(b, m, deterministic)
|
||||
return xxx_messageInfo_DiffRange_Response.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
@ -327,43 +328,43 @@ func (m *DiffRangeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, e
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *DiffRangeResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_DiffRangeResponse.Merge(m, src)
|
||||
func (m *DiffRange_Response) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_DiffRange_Response.Merge(m, src)
|
||||
}
|
||||
func (m *DiffRangeResponse) XXX_Size() int {
|
||||
func (m *DiffRange_Response) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *DiffRangeResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_DiffRangeResponse.DiscardUnknown(m)
|
||||
func (m *DiffRange_Response) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_DiffRange_Response.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_DiffRangeResponse proto.InternalMessageInfo
|
||||
var xxx_messageInfo_DiffRange_Response proto.InternalMessageInfo
|
||||
|
||||
func (m *DiffRangeResponse) GetResults() []*DiffRangeResponseResult {
|
||||
func (m *DiffRange_Response) GetResults() []*DiffRange_Response_Result {
|
||||
if m != nil {
|
||||
return m.Results
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type DiffRangeResponseResult struct {
|
||||
type DiffRange_Response_Result struct {
|
||||
Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"`
|
||||
Elements []*DiffRangeResponseResultElement `protobuf:"bytes,2,rep,name=elements,proto3" json:"elements,omitempty"`
|
||||
Elements []*DiffRange_Response_Result_Element `protobuf:"bytes,2,rep,name=elements,proto3" json:"elements,omitempty"`
|
||||
Count uint32 `protobuf:"varint,3,opt,name=count,proto3" json:"count,omitempty"`
|
||||
}
|
||||
|
||||
func (m *DiffRangeResponseResult) Reset() { *m = DiffRangeResponseResult{} }
|
||||
func (m *DiffRangeResponseResult) String() string { return proto.CompactTextString(m) }
|
||||
func (*DiffRangeResponseResult) ProtoMessage() {}
|
||||
func (*DiffRangeResponseResult) Descriptor() ([]byte, []int) {
|
||||
func (m *DiffRange_Response_Result) Reset() { *m = DiffRange_Response_Result{} }
|
||||
func (m *DiffRange_Response_Result) String() string { return proto.CompactTextString(m) }
|
||||
func (*DiffRange_Response_Result) ProtoMessage() {}
|
||||
func (*DiffRange_Response_Result) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_11d78c2fb7c80384, []int{1, 1, 0}
|
||||
}
|
||||
func (m *DiffRangeResponseResult) XXX_Unmarshal(b []byte) error {
|
||||
func (m *DiffRange_Response_Result) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *DiffRangeResponseResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
func (m *DiffRange_Response_Result) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_DiffRangeResponseResult.Marshal(b, m, deterministic)
|
||||
return xxx_messageInfo_DiffRange_Response_Result.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
@ -373,56 +374,56 @@ func (m *DiffRangeResponseResult) XXX_Marshal(b []byte, deterministic bool) ([]b
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *DiffRangeResponseResult) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_DiffRangeResponseResult.Merge(m, src)
|
||||
func (m *DiffRange_Response_Result) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_DiffRange_Response_Result.Merge(m, src)
|
||||
}
|
||||
func (m *DiffRangeResponseResult) XXX_Size() int {
|
||||
func (m *DiffRange_Response_Result) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *DiffRangeResponseResult) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_DiffRangeResponseResult.DiscardUnknown(m)
|
||||
func (m *DiffRange_Response_Result) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_DiffRange_Response_Result.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_DiffRangeResponseResult proto.InternalMessageInfo
|
||||
var xxx_messageInfo_DiffRange_Response_Result proto.InternalMessageInfo
|
||||
|
||||
func (m *DiffRangeResponseResult) GetHash() []byte {
|
||||
func (m *DiffRange_Response_Result) GetHash() []byte {
|
||||
if m != nil {
|
||||
return m.Hash
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *DiffRangeResponseResult) GetElements() []*DiffRangeResponseResultElement {
|
||||
func (m *DiffRange_Response_Result) GetElements() []*DiffRange_Response_Result_Element {
|
||||
if m != nil {
|
||||
return m.Elements
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *DiffRangeResponseResult) GetCount() uint32 {
|
||||
func (m *DiffRange_Response_Result) GetCount() uint32 {
|
||||
if m != nil {
|
||||
return m.Count
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type DiffRangeResponseResultElement struct {
|
||||
type DiffRange_Response_Result_Element struct {
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
Head string `protobuf:"bytes,2,opt,name=head,proto3" json:"head,omitempty"`
|
||||
}
|
||||
|
||||
func (m *DiffRangeResponseResultElement) Reset() { *m = DiffRangeResponseResultElement{} }
|
||||
func (m *DiffRangeResponseResultElement) String() string { return proto.CompactTextString(m) }
|
||||
func (*DiffRangeResponseResultElement) ProtoMessage() {}
|
||||
func (*DiffRangeResponseResultElement) Descriptor() ([]byte, []int) {
|
||||
func (m *DiffRange_Response_Result_Element) Reset() { *m = DiffRange_Response_Result_Element{} }
|
||||
func (m *DiffRange_Response_Result_Element) String() string { return proto.CompactTextString(m) }
|
||||
func (*DiffRange_Response_Result_Element) ProtoMessage() {}
|
||||
func (*DiffRange_Response_Result_Element) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_11d78c2fb7c80384, []int{1, 1, 0, 0}
|
||||
}
|
||||
func (m *DiffRangeResponseResultElement) XXX_Unmarshal(b []byte) error {
|
||||
func (m *DiffRange_Response_Result_Element) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *DiffRangeResponseResultElement) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
func (m *DiffRange_Response_Result_Element) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_DiffRangeResponseResultElement.Marshal(b, m, deterministic)
|
||||
return xxx_messageInfo_DiffRange_Response_Result_Element.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
@ -432,26 +433,26 @@ func (m *DiffRangeResponseResultElement) XXX_Marshal(b []byte, deterministic boo
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *DiffRangeResponseResultElement) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_DiffRangeResponseResultElement.Merge(m, src)
|
||||
func (m *DiffRange_Response_Result_Element) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_DiffRange_Response_Result_Element.Merge(m, src)
|
||||
}
|
||||
func (m *DiffRangeResponseResultElement) XXX_Size() int {
|
||||
func (m *DiffRange_Response_Result_Element) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *DiffRangeResponseResultElement) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_DiffRangeResponseResultElement.DiscardUnknown(m)
|
||||
func (m *DiffRange_Response_Result_Element) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_DiffRange_Response_Result_Element.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_DiffRangeResponseResultElement proto.InternalMessageInfo
|
||||
var xxx_messageInfo_DiffRange_Response_Result_Element proto.InternalMessageInfo
|
||||
|
||||
func (m *DiffRangeResponseResultElement) GetId() string {
|
||||
func (m *DiffRange_Response_Result_Element) GetId() string {
|
||||
if m != nil {
|
||||
return m.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *DiffRangeResponseResultElement) GetHead() string {
|
||||
func (m *DiffRange_Response_Result_Element) GetHead() string {
|
||||
if m != nil {
|
||||
return m.Head
|
||||
}
|
||||
@ -460,13 +461,13 @@ func (m *DiffRangeResponseResultElement) GetHead() string {
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*Space)(nil), "anytype.Space")
|
||||
proto.RegisterType((*SpaceContent)(nil), "anytype.Space.Content")
|
||||
proto.RegisterType((*Space_Content)(nil), "anytype.Space.Content")
|
||||
proto.RegisterType((*DiffRange)(nil), "anytype.DiffRange")
|
||||
proto.RegisterType((*DiffRangeRequest)(nil), "anytype.DiffRange.Request")
|
||||
proto.RegisterType((*DiffRangeRequestRange)(nil), "anytype.DiffRange.Request.Range")
|
||||
proto.RegisterType((*DiffRangeResponse)(nil), "anytype.DiffRange.Response")
|
||||
proto.RegisterType((*DiffRangeResponseResult)(nil), "anytype.DiffRange.Response.Result")
|
||||
proto.RegisterType((*DiffRangeResponseResultElement)(nil), "anytype.DiffRange.Response.Result.Element")
|
||||
proto.RegisterType((*DiffRange_Request)(nil), "anytype.DiffRange.Request")
|
||||
proto.RegisterType((*DiffRange_Request_Range)(nil), "anytype.DiffRange.Request.Range")
|
||||
proto.RegisterType((*DiffRange_Response)(nil), "anytype.DiffRange.Response")
|
||||
proto.RegisterType((*DiffRange_Response_Result)(nil), "anytype.DiffRange.Response.Result")
|
||||
proto.RegisterType((*DiffRange_Response_Result_Element)(nil), "anytype.DiffRange.Response.Result.Element")
|
||||
}
|
||||
|
||||
func init() {
|
||||
@ -546,7 +547,7 @@ func (m *Space) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *SpaceContent) Marshal() (dAtA []byte, err error) {
|
||||
func (m *Space_Content) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
@ -556,12 +557,12 @@ func (m *SpaceContent) Marshal() (dAtA []byte, err error) {
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *SpaceContent) MarshalTo(dAtA []byte) (int, error) {
|
||||
func (m *Space_Content) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *SpaceContent) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
func (m *Space_Content) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
@ -578,12 +579,12 @@ func (m *SpaceContent) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *SpaceContentValueOfDiffRange) MarshalTo(dAtA []byte) (int, error) {
|
||||
func (m *Space_Content_DiffRange) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *SpaceContentValueOfDiffRange) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
func (m *Space_Content_DiffRange) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
if m.DiffRange != nil {
|
||||
{
|
||||
@ -646,7 +647,7 @@ func (m *DiffRange) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *DiffRangeRequest) Marshal() (dAtA []byte, err error) {
|
||||
func (m *DiffRange_Request) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
@ -656,12 +657,12 @@ func (m *DiffRangeRequest) Marshal() (dAtA []byte, err error) {
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *DiffRangeRequest) MarshalTo(dAtA []byte) (int, error) {
|
||||
func (m *DiffRange_Request) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *DiffRangeRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
func (m *DiffRange_Request) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
@ -683,7 +684,7 @@ func (m *DiffRangeRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *DiffRangeRequestRange) Marshal() (dAtA []byte, err error) {
|
||||
func (m *DiffRange_Request_Range) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
@ -693,12 +694,12 @@ func (m *DiffRangeRequestRange) Marshal() (dAtA []byte, err error) {
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *DiffRangeRequestRange) MarshalTo(dAtA []byte) (int, error) {
|
||||
func (m *DiffRange_Request_Range) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *DiffRangeRequestRange) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
func (m *DiffRange_Request_Range) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
@ -721,7 +722,7 @@ func (m *DiffRangeRequestRange) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *DiffRangeResponse) Marshal() (dAtA []byte, err error) {
|
||||
func (m *DiffRange_Response) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
@ -731,12 +732,12 @@ func (m *DiffRangeResponse) Marshal() (dAtA []byte, err error) {
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *DiffRangeResponse) MarshalTo(dAtA []byte) (int, error) {
|
||||
func (m *DiffRange_Response) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *DiffRangeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
func (m *DiffRange_Response) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
@ -758,7 +759,7 @@ func (m *DiffRangeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *DiffRangeResponseResult) Marshal() (dAtA []byte, err error) {
|
||||
func (m *DiffRange_Response_Result) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
@ -768,12 +769,12 @@ func (m *DiffRangeResponseResult) Marshal() (dAtA []byte, err error) {
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *DiffRangeResponseResult) MarshalTo(dAtA []byte) (int, error) {
|
||||
func (m *DiffRange_Response_Result) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *DiffRangeResponseResult) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
func (m *DiffRange_Response_Result) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
@ -807,7 +808,7 @@ func (m *DiffRangeResponseResult) MarshalToSizedBuffer(dAtA []byte) (int, error)
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *DiffRangeResponseResultElement) Marshal() (dAtA []byte, err error) {
|
||||
func (m *DiffRange_Response_Result_Element) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
@ -817,12 +818,12 @@ func (m *DiffRangeResponseResultElement) Marshal() (dAtA []byte, err error) {
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *DiffRangeResponseResultElement) MarshalTo(dAtA []byte) (int, error) {
|
||||
func (m *DiffRange_Response_Result_Element) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *DiffRangeResponseResultElement) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
func (m *DiffRange_Response_Result_Element) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
@ -872,7 +873,7 @@ func (m *Space) Size() (n int) {
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *SpaceContent) Size() (n int) {
|
||||
func (m *Space_Content) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
@ -884,7 +885,7 @@ func (m *SpaceContent) Size() (n int) {
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *SpaceContentValueOfDiffRange) Size() (n int) {
|
||||
func (m *Space_Content_DiffRange) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
@ -913,7 +914,7 @@ func (m *DiffRange) Size() (n int) {
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *DiffRangeRequest) Size() (n int) {
|
||||
func (m *DiffRange_Request) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
@ -928,7 +929,7 @@ func (m *DiffRangeRequest) Size() (n int) {
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *DiffRangeRequestRange) Size() (n int) {
|
||||
func (m *DiffRange_Request_Range) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
@ -946,7 +947,7 @@ func (m *DiffRangeRequestRange) Size() (n int) {
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *DiffRangeResponse) Size() (n int) {
|
||||
func (m *DiffRange_Response) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
@ -961,7 +962,7 @@ func (m *DiffRangeResponse) Size() (n int) {
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *DiffRangeResponseResult) Size() (n int) {
|
||||
func (m *DiffRange_Response_Result) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
@ -983,7 +984,7 @@ func (m *DiffRangeResponseResult) Size() (n int) {
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *DiffRangeResponseResultElement) Size() (n int) {
|
||||
func (m *DiffRange_Response_Result_Element) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
@ -1097,7 +1098,7 @@ func (m *Space) Unmarshal(dAtA []byte) error {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if m.Message == nil {
|
||||
m.Message = &SpaceContent{}
|
||||
m.Message = &Space_Content{}
|
||||
}
|
||||
if err := m.Message.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
@ -1124,7 +1125,7 @@ func (m *Space) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *SpaceContent) Unmarshal(dAtA []byte) error {
|
||||
func (m *Space_Content) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
@ -1186,7 +1187,7 @@ func (m *SpaceContent) Unmarshal(dAtA []byte) error {
|
||||
if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
m.Value = &SpaceContentValueOfDiffRange{v}
|
||||
m.Value = &Space_Content_DiffRange{v}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
@ -1268,7 +1269,7 @@ func (m *DiffRange) Unmarshal(dAtA []byte) error {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if m.Request == nil {
|
||||
m.Request = &DiffRangeRequest{}
|
||||
m.Request = &DiffRange_Request{}
|
||||
}
|
||||
if err := m.Request.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
@ -1304,7 +1305,7 @@ func (m *DiffRange) Unmarshal(dAtA []byte) error {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if m.Response == nil {
|
||||
m.Response = &DiffRangeResponse{}
|
||||
m.Response = &DiffRange_Response{}
|
||||
}
|
||||
if err := m.Response.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
@ -1331,7 +1332,7 @@ func (m *DiffRange) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *DiffRangeRequest) Unmarshal(dAtA []byte) error {
|
||||
func (m *DiffRange_Request) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
@ -1389,7 +1390,7 @@ func (m *DiffRangeRequest) Unmarshal(dAtA []byte) error {
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Ranges = append(m.Ranges, &DiffRangeRequestRange{})
|
||||
m.Ranges = append(m.Ranges, &DiffRange_Request_Range{})
|
||||
if err := m.Ranges[len(m.Ranges)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1415,7 +1416,7 @@ func (m *DiffRangeRequest) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *DiffRangeRequestRange) Unmarshal(dAtA []byte) error {
|
||||
func (m *DiffRange_Request_Range) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
@ -1522,7 +1523,7 @@ func (m *DiffRangeRequestRange) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *DiffRangeResponse) Unmarshal(dAtA []byte) error {
|
||||
func (m *DiffRange_Response) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
@ -1580,7 +1581,7 @@ func (m *DiffRangeResponse) Unmarshal(dAtA []byte) error {
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Results = append(m.Results, &DiffRangeResponseResult{})
|
||||
m.Results = append(m.Results, &DiffRange_Response_Result{})
|
||||
if err := m.Results[len(m.Results)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1606,7 +1607,7 @@ func (m *DiffRangeResponse) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *DiffRangeResponseResult) Unmarshal(dAtA []byte) error {
|
||||
func (m *DiffRange_Response_Result) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
@ -1698,7 +1699,7 @@ func (m *DiffRangeResponseResult) Unmarshal(dAtA []byte) error {
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Elements = append(m.Elements, &DiffRangeResponseResultElement{})
|
||||
m.Elements = append(m.Elements, &DiffRange_Response_Result_Element{})
|
||||
if err := m.Elements[len(m.Elements)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1743,7 +1744,7 @@ func (m *DiffRangeResponseResult) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *DiffRangeResponseResultElement) Unmarshal(dAtA []byte) error {
|
||||
func (m *DiffRange_Response_Result_Element) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
|
||||
@ -57,7 +57,7 @@ func (s *service) Close(ctx context.Context) (err error) {
|
||||
func (s *service) HandleMessage(ctx context.Context, msg *pool.Message) (err error) {
|
||||
defer func() {
|
||||
if err != nil {
|
||||
msg.AckError(syncproto.SystemError_UNKNOWN, err.Error())
|
||||
msg.AckError(syncproto.System_Error_UNKNOWN, err.Error())
|
||||
} else {
|
||||
msg.Ack()
|
||||
}
|
||||
|
||||
@ -5,8 +5,9 @@ import (
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/app"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/acltree"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treestorage"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treestorage/treepb"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/service/account"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/service/treecache"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/syncproto"
|
||||
@ -60,234 +61,212 @@ func (r *requestHandler) HandleSyncMessage(ctx context.Context, senderId string,
|
||||
msg := content.GetMessage()
|
||||
switch {
|
||||
case msg.GetFullSyncRequest() != nil:
|
||||
return r.HandleFullSyncRequest(ctx, senderId, msg.GetFullSyncRequest(), content.GetTreeHeader(), content.GetTreeId())
|
||||
return r.HandleFullSyncRequest(ctx, senderId, msg.GetFullSyncRequest())
|
||||
case msg.GetFullSyncResponse() != nil:
|
||||
return r.HandleFullSyncResponse(ctx, senderId, msg.GetFullSyncResponse(), content.GetTreeHeader(), content.GetTreeId())
|
||||
return r.HandleFullSyncResponse(ctx, senderId, msg.GetFullSyncResponse())
|
||||
case msg.GetHeadUpdate() != nil:
|
||||
return r.HandleHeadUpdate(ctx, senderId, msg.GetHeadUpdate(), content.GetTreeHeader(), content.GetTreeId())
|
||||
case msg.GetAclList() != nil:
|
||||
return r.HandleACLList(ctx, senderId, msg.GetAclList(), content.GetTreeHeader(), content.GetTreeId())
|
||||
return r.HandleHeadUpdate(ctx, senderId, msg.GetHeadUpdate())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *requestHandler) HandleHeadUpdate(
|
||||
ctx context.Context,
|
||||
senderId string,
|
||||
update *syncproto.SyncHeadUpdate,
|
||||
header *aclpb.Header,
|
||||
treeId string) (err error) {
|
||||
|
||||
func (r *requestHandler) HandleHeadUpdate(ctx context.Context, senderId string, update *syncproto.Sync_HeadUpdate) (err error) {
|
||||
var (
|
||||
fullRequest *syncproto.SyncFullRequest
|
||||
fullRequest *syncproto.Sync_Full_Request
|
||||
snapshotPath []string
|
||||
result tree.AddResult
|
||||
result acltree.AddResult
|
||||
)
|
||||
log.With(zap.String("peerId", senderId), zap.String("treeId", treeId)).
|
||||
log.With(zap.String("peerId", senderId), zap.String("treeId", update.TreeId)).
|
||||
Debug("processing head update")
|
||||
|
||||
err = r.treeCache.Do(ctx, treeId, func(obj any) error {
|
||||
objTree := obj.(tree.ObjectTree)
|
||||
objTree.Lock()
|
||||
defer objTree.Unlock()
|
||||
|
||||
if slice.UnsortedEquals(update.Heads, objTree.Heads()) {
|
||||
return nil
|
||||
}
|
||||
|
||||
result, err = objTree.AddRawChanges(ctx, update.Changes...)
|
||||
err = r.treeCache.Do(ctx, update.TreeId, func(tree acltree.ACLTree) error {
|
||||
// TODO: check if we already have those changes
|
||||
result, err = tree.AddRawChanges(ctx, update.Changes...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// if we couldn't add all the changes
|
||||
shouldFullSync := len(update.Changes) != len(result.Added)
|
||||
snapshotPath = objTree.SnapshotPath()
|
||||
log.With(zap.Strings("update heads", update.Heads), zap.Strings("tree heads", tree.Heads())).
|
||||
Debug("comparing heads after head update")
|
||||
shouldFullSync := !slice.UnsortedEquals(update.Heads, tree.Heads())
|
||||
snapshotPath = tree.SnapshotPath()
|
||||
if shouldFullSync {
|
||||
fullRequest, err = r.prepareFullSyncRequest(objTree)
|
||||
fullRequest, err = r.prepareFullSyncRequest(update.TreeId, update.TreeHeader, update.SnapshotPath, tree)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
// if there are no such tree
|
||||
if err == storage.ErrUnknownTreeId {
|
||||
fullRequest = &syncproto.SyncFullRequest{}
|
||||
if err == treestorage.ErrUnknownTreeId {
|
||||
// TODO: maybe we can optimize this by sending the header and stuff right away, so when the tree is created we are able to add it on first request
|
||||
fullRequest = &syncproto.Sync_Full_Request{
|
||||
TreeId: update.TreeId,
|
||||
TreeHeader: update.TreeHeader,
|
||||
}
|
||||
}
|
||||
// if we have incompatible heads, or we haven't seen the tree at all
|
||||
if fullRequest != nil {
|
||||
return r.messageService.SendMessageAsync(senderId, syncproto.WrapFullRequest(fullRequest, header, treeId))
|
||||
return r.messageService.SendMessageAsync(senderId, syncproto.WrapFullRequest(fullRequest))
|
||||
}
|
||||
// if error or nothing has changed
|
||||
if err != nil || len(result.Added) == 0 {
|
||||
return err
|
||||
}
|
||||
// otherwise sending heads update message
|
||||
newUpdate := &syncproto.Sync_HeadUpdate{
|
||||
Heads: result.Heads,
|
||||
Changes: result.Added,
|
||||
SnapshotPath: snapshotPath,
|
||||
TreeId: update.TreeId,
|
||||
TreeHeader: update.TreeHeader,
|
||||
}
|
||||
return r.messageService.SendToSpaceAsync("", syncproto.WrapHeadUpdate(newUpdate))
|
||||
}
|
||||
|
||||
func (r *requestHandler) HandleFullSyncRequest(ctx context.Context, senderId string, request *syncproto.Sync_Full_Request) (err error) {
|
||||
var (
|
||||
fullResponse *syncproto.Sync_Full_Response
|
||||
snapshotPath []string
|
||||
result acltree.AddResult
|
||||
)
|
||||
log.With(zap.String("peerId", senderId), zap.String("treeId", request.TreeId)).
|
||||
Debug("processing full sync request")
|
||||
|
||||
err = r.treeCache.Do(ctx, request.TreeId, func(tree acltree.ACLTree) error {
|
||||
// TODO: check if we already have those changes
|
||||
// if we have non-empty request
|
||||
if len(request.Heads) != 0 {
|
||||
result, err = tree.AddRawChanges(ctx, request.Changes...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
snapshotPath = tree.SnapshotPath()
|
||||
fullResponse, err = r.prepareFullSyncResponse(request.TreeId, request.SnapshotPath, request.Changes, tree)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = r.messageService.SendMessageAsync(senderId, syncproto.WrapFullResponse(fullResponse))
|
||||
// if error or nothing has changed
|
||||
if err != nil || len(result.Added) == 0 {
|
||||
return err
|
||||
}
|
||||
|
||||
// otherwise sending heads update message
|
||||
newUpdate := &syncproto.SyncHeadUpdate{
|
||||
newUpdate := &syncproto.Sync_HeadUpdate{
|
||||
Heads: result.Heads,
|
||||
Changes: result.Added,
|
||||
SnapshotPath: snapshotPath,
|
||||
TreeId: request.TreeId,
|
||||
TreeHeader: request.TreeHeader,
|
||||
}
|
||||
return r.messageService.SendToSpaceAsync("", syncproto.WrapHeadUpdate(newUpdate, header, treeId))
|
||||
return r.messageService.SendToSpaceAsync("", syncproto.WrapHeadUpdate(newUpdate))
|
||||
}
|
||||
|
||||
func (r *requestHandler) HandleFullSyncRequest(
|
||||
ctx context.Context,
|
||||
senderId string,
|
||||
request *syncproto.SyncFullRequest,
|
||||
header *aclpb.Header,
|
||||
treeId string) (err error) {
|
||||
|
||||
var fullResponse *syncproto.SyncFullResponse
|
||||
err = r.treeCache.Do(ctx, treeId, func(obj any) error {
|
||||
objTree := obj.(tree.ObjectTree)
|
||||
objTree.Lock()
|
||||
defer objTree.Unlock()
|
||||
|
||||
fullResponse, err = r.prepareFullSyncResponse(treeId, request.SnapshotPath, request.Heads, objTree)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return r.messageService.SendMessageAsync(senderId, syncproto.WrapFullResponse(fullResponse, header, treeId))
|
||||
}
|
||||
|
||||
func (r *requestHandler) HandleFullSyncResponse(
|
||||
ctx context.Context,
|
||||
senderId string,
|
||||
response *syncproto.SyncFullResponse,
|
||||
header *aclpb.Header,
|
||||
treeId string) (err error) {
|
||||
|
||||
func (r *requestHandler) HandleFullSyncResponse(ctx context.Context, senderId string, response *syncproto.Sync_Full_Response) (err error) {
|
||||
var (
|
||||
snapshotPath []string
|
||||
result tree.AddResult
|
||||
result acltree.AddResult
|
||||
)
|
||||
log.With(zap.String("peerId", senderId), zap.String("treeId", response.TreeId)).
|
||||
Debug("processing full sync response")
|
||||
|
||||
err = r.treeCache.Do(ctx, treeId, func(obj interface{}) error {
|
||||
objTree := obj.(tree.ObjectTree)
|
||||
objTree.Lock()
|
||||
defer objTree.Unlock()
|
||||
|
||||
// if we already have the heads for whatever reason
|
||||
if slice.UnsortedEquals(response.Heads, objTree.Heads()) {
|
||||
return nil
|
||||
}
|
||||
|
||||
result, err = objTree.AddRawChanges(ctx, response.Changes...)
|
||||
err = r.treeCache.Do(ctx, response.TreeId, func(tree acltree.ACLTree) error {
|
||||
// TODO: check if we already have those changes
|
||||
result, err = tree.AddRawChanges(ctx, response.Changes...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
snapshotPath = objTree.SnapshotPath()
|
||||
snapshotPath = tree.SnapshotPath()
|
||||
return nil
|
||||
})
|
||||
|
||||
// if error or nothing has changed
|
||||
if (err != nil || len(result.Added) == 0) && err != storage.ErrUnknownTreeId {
|
||||
if (err != nil || len(result.Added) == 0) && err != treestorage.ErrUnknownTreeId {
|
||||
return err
|
||||
}
|
||||
// if we have a new tree
|
||||
if err == storage.ErrUnknownTreeId {
|
||||
err = r.createTree(ctx, response, header, treeId)
|
||||
if err == treestorage.ErrUnknownTreeId {
|
||||
err = r.createTree(ctx, response)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result = tree.AddResult{
|
||||
result = acltree.AddResult{
|
||||
OldHeads: []string{},
|
||||
Heads: response.Heads,
|
||||
Added: response.Changes,
|
||||
}
|
||||
}
|
||||
// sending heads update message
|
||||
newUpdate := &syncproto.SyncHeadUpdate{
|
||||
newUpdate := &syncproto.Sync_HeadUpdate{
|
||||
Heads: result.Heads,
|
||||
Changes: result.Added,
|
||||
SnapshotPath: snapshotPath,
|
||||
TreeId: response.TreeId,
|
||||
}
|
||||
return r.messageService.SendToSpaceAsync("", syncproto.WrapHeadUpdate(newUpdate, header, treeId))
|
||||
return r.messageService.SendToSpaceAsync("", syncproto.WrapHeadUpdate(newUpdate))
|
||||
}
|
||||
|
||||
func (r *requestHandler) HandleACLList(
|
||||
ctx context.Context,
|
||||
senderId string,
|
||||
req *syncproto.SyncACLList,
|
||||
header *aclpb.Header,
|
||||
id string) (err error) {
|
||||
|
||||
err = r.treeCache.Do(ctx, id, func(obj interface{}) error {
|
||||
return nil
|
||||
})
|
||||
// do nothing if already added
|
||||
if err == nil {
|
||||
return nil
|
||||
func (r *requestHandler) prepareFullSyncRequest(treeId string, header *treepb.TreeHeader, theirPath []string, tree acltree.ACLTree) (*syncproto.Sync_Full_Request, error) {
|
||||
ourChanges, err := tree.ChangesAfterCommonSnapshot(theirPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// if not found then add to storage
|
||||
if err == storage.ErrUnknownTreeId {
|
||||
return r.createACLList(ctx, req, header, id)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (r *requestHandler) prepareFullSyncRequest(t tree.ObjectTree) (*syncproto.SyncFullRequest, error) {
|
||||
return &syncproto.SyncFullRequest{
|
||||
Heads: t.Heads(),
|
||||
SnapshotPath: t.SnapshotPath(),
|
||||
return &syncproto.Sync_Full_Request{
|
||||
Heads: tree.Heads(),
|
||||
Changes: ourChanges,
|
||||
TreeId: treeId,
|
||||
SnapshotPath: tree.SnapshotPath(),
|
||||
TreeHeader: header,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (r *requestHandler) prepareFullSyncResponse(
|
||||
treeId string,
|
||||
theirPath, theirHeads []string,
|
||||
t tree.ObjectTree) (*syncproto.SyncFullResponse, error) {
|
||||
ourChanges, err := t.ChangesAfterCommonSnapshot(theirPath, theirHeads)
|
||||
theirPath []string,
|
||||
theirChanges []*aclpb.RawChange,
|
||||
tree acltree.ACLTree) (*syncproto.Sync_Full_Response, error) {
|
||||
// TODO: we can probably use the common snapshot calculated on the request step from previous peer
|
||||
ourChanges, err := tree.ChangesAfterCommonSnapshot(theirPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
theirMap := make(map[string]struct{})
|
||||
for _, ch := range theirChanges {
|
||||
theirMap[ch.Id] = struct{}{}
|
||||
}
|
||||
|
||||
return &syncproto.SyncFullResponse{
|
||||
Heads: t.Heads(),
|
||||
Changes: ourChanges,
|
||||
SnapshotPath: t.SnapshotPath(),
|
||||
// filtering our changes, so we will not send the same changes back
|
||||
var final []*aclpb.RawChange
|
||||
for _, ch := range ourChanges {
|
||||
if _, exists := theirMap[ch.Id]; !exists {
|
||||
final = append(final, ch)
|
||||
}
|
||||
}
|
||||
log.With(zap.Int("len(changes)", len(final)), zap.String("id", treeId)).
|
||||
Debug("preparing changes for tree")
|
||||
|
||||
return &syncproto.Sync_Full_Response{
|
||||
Heads: tree.Heads(),
|
||||
Changes: final,
|
||||
TreeId: treeId,
|
||||
SnapshotPath: tree.SnapshotPath(),
|
||||
TreeHeader: tree.Header(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (r *requestHandler) createTree(
|
||||
ctx context.Context,
|
||||
response *syncproto.SyncFullResponse,
|
||||
header *aclpb.Header,
|
||||
treeId string) error {
|
||||
|
||||
func (r *requestHandler) createTree(ctx context.Context, response *syncproto.Sync_Full_Response) error {
|
||||
return r.treeCache.Add(
|
||||
ctx,
|
||||
treeId,
|
||||
storage.TreeStorageCreatePayload{
|
||||
TreeId: treeId,
|
||||
Header: header,
|
||||
Changes: response.Changes,
|
||||
Heads: response.Heads,
|
||||
})
|
||||
}
|
||||
|
||||
func (r *requestHandler) createACLList(
|
||||
ctx context.Context,
|
||||
req *syncproto.SyncACLList,
|
||||
header *aclpb.Header,
|
||||
treeId string) error {
|
||||
|
||||
return r.treeCache.Add(
|
||||
ctx,
|
||||
treeId,
|
||||
storage.ACLListStorageCreatePayload{
|
||||
ListId: treeId,
|
||||
Header: header,
|
||||
Records: req.Records,
|
||||
response.TreeId,
|
||||
response.TreeHeader,
|
||||
response.Changes,
|
||||
func(tree acltree.ACLTree) error {
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
@ -1,45 +1,19 @@
|
||||
package syncproto
|
||||
|
||||
import (
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb"
|
||||
)
|
||||
|
||||
func WrapHeadUpdate(update *SyncHeadUpdate, header *aclpb.Header, treeId string) *Sync {
|
||||
return &Sync{
|
||||
Message: &SyncContentValue{
|
||||
Value: &SyncContentValueValueOfHeadUpdate{HeadUpdate: update},
|
||||
},
|
||||
TreeHeader: header,
|
||||
TreeId: treeId,
|
||||
}
|
||||
func WrapHeadUpdate(update *Sync_HeadUpdate) *Sync {
|
||||
return &Sync{Message: &Sync_ContentValue{
|
||||
Value: &Sync_Content_Value_HeadUpdate{HeadUpdate: update},
|
||||
}}
|
||||
}
|
||||
|
||||
func WrapFullRequest(request *SyncFullRequest, header *aclpb.Header, treeId string) *Sync {
|
||||
return &Sync{
|
||||
Message: &SyncContentValue{
|
||||
Value: &SyncContentValueValueOfFullSyncRequest{FullSyncRequest: request},
|
||||
},
|
||||
TreeHeader: header,
|
||||
TreeId: treeId,
|
||||
}
|
||||
func WrapFullRequest(request *Sync_Full_Request) *Sync {
|
||||
return &Sync{Message: &Sync_ContentValue{
|
||||
Value: &Sync_Content_Value_FullSyncRequest{FullSyncRequest: request},
|
||||
}}
|
||||
}
|
||||
|
||||
func WrapFullResponse(response *SyncFullResponse, header *aclpb.Header, treeId string) *Sync {
|
||||
return &Sync{
|
||||
Message: &SyncContentValue{
|
||||
Value: &SyncContentValueValueOfFullSyncResponse{FullSyncResponse: response},
|
||||
},
|
||||
TreeHeader: header,
|
||||
TreeId: treeId,
|
||||
}
|
||||
}
|
||||
|
||||
func WrapACLList(aclList *SyncACLList, header *aclpb.Header, id string) *Sync {
|
||||
return &Sync{
|
||||
Message: &SyncContentValue{
|
||||
Value: &SyncContentValueValueOfAclList{AclList: aclList},
|
||||
},
|
||||
TreeHeader: header,
|
||||
TreeId: id,
|
||||
}
|
||||
func WrapFullResponse(response *Sync_Full_Response) *Sync {
|
||||
return &Sync{Message: &Sync_ContentValue{
|
||||
Value: &Sync_Content_Value_FullSyncResponse{FullSyncResponse: response},
|
||||
}}
|
||||
}
|
||||
|
||||
1962
syncproto/sync.pb.go
1962
syncproto/sync.pb.go
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user