Giter VIP home page Giter VIP logo

3box-api's Introduction

3Box Logo

Welcome to 3Box Labs!

Twitter Follow Discord

3Box Labs is a Web3 product studio that creates software to advance a more open, safe, and collaborative web. We are the inventors and a core maintainer of Ceramic, a decentralized network for composable data. Permissionless data composability will inevitably network all of the information on the web, transform the way we build applications, and connect users to their data, and each other, in new and exciting ways. To learn more about 3Box Labs, visit https://3boxlabs.com/.

Getting Started

๐Ÿ‘ค Visit Ceramic Network to build applications with composable data.

๐Ÿ’ฌ Join Ceramic Community Discord to chat with the core team and developer community

๐Ÿ‘ฉโ€๐Ÿ’ป Explore our blog to learn more about Ceramic, comopsable data and Web3 - and sign up for our newsletter.

3box-api's People

Contributors

msterle avatar oed avatar simonovic86 avatar zachferland avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

adjath

3box-api's Issues

README v1

Create readme of stand form. Intro, usage, API Docs, build/run/dev, contributions.

IDX Profile Cache Logic

Continue to hit cache for 3box profile (and write to cache once resolve).

When we resolve a ceramic profile dont write it to cache following the request, and delete 3box profile from cache. Currently the cache is keyed by orbit db address.

Actually believe this is not needed now. Caching at different level than i remembered (orbitdbaddress). But keeping story to just double check and make sure that current logic will still make sense. Should still be part of test ideally.

Improve thread/access db name string match in readDB

Currently readDB has differing configs to load/read if db is a thread db. But it just checks if db address includes threads. This breaks if someone included threads in space name.

Generally we need to be more careful with user inputs and better define name constraints and assumptions.

Improve cache invalidation (too aggressive right now)

Depending on path forward this work maybe more in the pinning node. Right now cache is invalidated when there is any write to the orbitcache (heads for db), orbit writes this every time on db open, even if they are the same. We should only invalidate cache if they change.

If implemented similar to now, a set if not equal function in orbitcache wrapper may work. But since not an atomic operation (not available from redis) may cause other concurrency issues. Can ask/ref mike and his recent story for more info on possible issues with multi read/write to orbitcache, may help here.

Improve Caching Strategy

Current implement is nice that is doesn't require any cache invalidation on the pinning node, just a redis event stream. But right now caches values are being invalidated more frequently than necessary, caches values are invalidated on remoteHeads writes. But orbitdb will write to remoteHeads on every open, not just when they change. An improved strategy would only invalidate cache when a log changes (as intended). One implementation is to only write when value changes, but this is not an op in redis, only can be a client implementation. This is the simplest, but could cause some race conditions as this isnt an atomic op. (but maybe no additional than the unlikely cases that can exist now). Similarly may work to not write heads on log load but on receiving an update instead (maybe improve other race conditions as well)

Determine if Ceramic Link Exist and resolve IDX profile it does

env var CERAMIC_API for ceramic client, on develop branch will be set to https://ceramic-dev.3boxlabs.com

For getProfile and getProfiles, for given eth address or did determine if exist in ceramic

By eth address:

  1. Load the caip10-link doc for the given eth address
  async linkExistInNetwork(accountId: AccountID):Promise<LinkProof | undefined> {
    const doc = await this.ceramic.createDocument(
      'caip10-link',
      { metadata: { controllers: [accountId] } },
      { anchor: false, publish: false }
    )
    const linkDoc = await this.ceramic.loadDocument(doc.id)
    return linkDoc.content as LinkProof | undefined
  }
  • Pin it if not already pinned (will speed things up on subsequent loads)
  1. If does not exist
  • continue for 3box profile
  1. if does exist
    • Get the DID from the content/LinkProof
    • Load the BasicProfile doc (should be possible knowing only: definition, schema, DID in ceramic or can just use IDX)

By DID:
skip to step 3, try to resolve BasicProfile if exist

Add Tests:
Reference existing tests and ideally just mock ceramic functions, returning LinkProof and a BasicProfile

Optimizations
this is going to slow up all requests, but hopefully within reasonable bounds
ideally will still fetch/load 3box profile in parallel while making ceramic requests, so that can instantly be returned if not links in ceramic

The "profileList" endpoint is not working.

Edit oed, 2020-02-20

It seems like this error comes from the profileList endopint in 3box-api not working properly. Even calling this endpoint with only one address that has a proper profile this call stalls and eventually causes an error.


Single missing profile when fetching multiple profiles through graphql causes the whole query to fail

@msterle commented on Mon Feb 10 2020

If one or more addresses aren't registered with the address server, the graphql endpoint correctly returns only those with existing profiles. However, if the address is registered with the server, but the profile doesn't exist, the graphql endpoint returns a 500 error.

Test query:

{"operationName":"Profiles","variables":{"accounts":["<address 1>", "<address 2>"]},"query":"query Profiles($accounts: [String]!) {\n  profiles(ids: $accounts) {\n eth_address\n    image\n   }\n}\n"}

Is it possible this issue is linked to profiles that have been corrupted, and the error on those isn't being handled gracefully?


For example addresses, ping @msterle directly

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.