Skip to content

Commit

Permalink
docs: Correcting typos (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
orpheuslummis authored Mar 1, 2022
1 parent a98e826 commit 42a3b8b
Show file tree
Hide file tree
Showing 39 changed files with 96 additions and 98 deletions.
4 changes: 2 additions & 2 deletions api/http/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ func (s *Server) getBlock(w http.ResponseWriter, r *http.Request) {
// try to parse CID
c, err := cid.Decode(cidStr)
if err != nil {
// if we cant try to parse DSKeyToCID
// return error if we still cant
// If we can't try to parse DSKeyToCID
// return error if we still can't
key := ds.NewKey(cidStr)
var hash multihash.Multihash
hash, err = dshelp.DsKeyToMultihash(key)
Expand Down
10 changes: 5 additions & 5 deletions bench/bench_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var (

func init() {
// create a consistent seed value for the random package
// so we dont have random fluctuations between runs
// so we don't have random fluctuations between runs
// (specifically thinking about the fixture generation stuff)
seed := hashToInt64("https://xkcd.com/221/")
rand.Seed(seed)
Expand Down Expand Up @@ -114,7 +114,7 @@ func SetupDBAndCollections(b *testing.B, ctx context.Context, fixture fixtures.G
}

// Loads the given test database using the provided fixture context.
// It loads docCount number of documents asyncronously in batches of *upto*
// It loads docCount number of documents asynchronously in batches of *up to*
// writeBatchGroup.
func BackfillBenchmarkDB(b *testing.B, ctx context.Context, cols []client.Collection, fixture fixtures.Generator, docCount, opCount int, doSync bool) ([][]key.DocKey, error) {
numTypes := len(fixture.Types())
Expand All @@ -127,8 +127,8 @@ func BackfillBenchmarkDB(b *testing.B, ctx context.Context, cols []client.Collec
dockeys := make([][]key.DocKey, docCount)

go func() {
// cut up the job from into writeBatchGroup size grouped jobs.
// Note weird math cus the last batch will likely be smaller then
// Cut up the job from into writeBatchGroup size grouped jobs.
// Note weird math because the last batch will likely be smaller then
// writeBatchGroup ~cus math~.
for bid := 0; float64(bid) < math.Ceil(float64(docCount)/writeBatchGroup); bid++ {
currentBatchSize := int(math.Min(float64((docCount - (bid * writeBatchGroup))), writeBatchGroup))
Expand Down Expand Up @@ -158,7 +158,7 @@ func BackfillBenchmarkDB(b *testing.B, ctx context.Context, cols []client.Collec
return
}

// loop forever untill commited.
// loop forever until committed.
// This was necessary when debugging and was left
// in place. The error check could prob use a wrap system
// but its fine :).
Expand Down
2 changes: 1 addition & 1 deletion cli/defradb/cmd/addreplicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ for the p2p data sync system.
if err != nil {
log.FatalE(ctx, "Request failed", err)
}
log.Info(ctx, "Succesfully added replicator", logging.NewKV("PID", pid))
log.Info(ctx, "Successfully added replicator", logging.NewKV("PID", pid))
},
}

Expand Down
2 changes: 1 addition & 1 deletion cli/defradb/cmd/blocks_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var getCmd = &cobra.Command{

dbaddr := viper.GetString("database.address")
if dbaddr == "" {
log.Error(ctx, "No database url provided")
log.Error(ctx, "No database URL provided")
}
if !strings.HasPrefix(dbaddr, "http") {
dbaddr = "http://" + dbaddr
Expand Down
2 changes: 1 addition & 1 deletion cli/defradb/cmd/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var dumpCmd = &cobra.Command{

dbaddr := viper.GetString("database.address")
if dbaddr == "" {
log.Error(ctx, "No database url provided")
log.Error(ctx, "No database URL provided")
}
if !strings.HasPrefix(dbaddr, "http") {
dbaddr = "http://" + dbaddr
Expand Down
2 changes: 1 addition & 1 deletion cli/defradb/cmd/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var pingCmd = &cobra.Command{

dbaddr := viper.GetString("database.address")
if dbaddr == "" {
log.Error(ctx, "No database url provided")
log.Error(ctx, "No database URL provided")
}
if !strings.HasPrefix(dbaddr, "http") {
dbaddr = "http://" + dbaddr
Expand Down
2 changes: 1 addition & 1 deletion cli/defradb/cmd/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ the additional documentation found at: https://hackmd.io/@source/BksQY6Qfw.

dbaddr := viper.GetString("database.address")
if dbaddr == "" {
log.Error(ctx, "No database url provided")
log.Error(ctx, "No database URL provided")
}
if !strings.HasPrefix(dbaddr, "http") {
dbaddr = "http://" + dbaddr
Expand Down
2 changes: 1 addition & 1 deletion cli/defradb/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func init() {
// Cobra supports persistent flags, which, if defined here,
// will be global for your application.
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.defradb/config.yaml)")
rootCmd.PersistentFlags().StringVar(&dbURL, "url", "http://localhost:9181", "url of the target database")
rootCmd.PersistentFlags().StringVar(&dbURL, "url", "http://localhost:9181", "URL of the target database")
// Cobra also supports local flags, which will only run
// when this action is called directly.
// rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
Expand Down
2 changes: 1 addition & 1 deletion cli/defradb/cmd/schema_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var addCmd = &cobra.Command{

dbaddr := viper.GetString("database.address")
if dbaddr == "" {
log.Error(ctx, "No database url provided")
log.Error(ctx, "No database URL provided")
}
if !strings.HasPrefix(dbaddr, "http") {
dbaddr = "http://" + dbaddr
Expand Down
10 changes: 5 additions & 5 deletions cli/defradb/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ var startCmd = &cobra.Command{

// parse peers and bootstrap
if len(peers) != 0 {
log.Debug(ctx, "Parsing boostrap peers", logging.NewKV("Peers", peers))
log.Debug(ctx, "Parsing bootstrap peers", logging.NewKV("Peers", peers))
addrs, err := netutils.ParsePeers(strings.Split(peers, ","))
if err != nil {
log.ErrorE(ctx, "Failed to parse boostrap peers", err)
log.ErrorE(ctx, "Failed to parse bootstrap peers", err)
}
log.Debug(ctx, "Bootstraping with peers", logging.NewKV("Addresses", addrs))
n.Boostrap(addrs)
Expand Down Expand Up @@ -153,7 +153,7 @@ var startCmd = &cobra.Command{
}()
}

// run the server listener in a seperate goroutine
// run the server listener in a separate goroutine
go func() {
if err := db.Listen(ctx, config.Database.Address); err != nil {
log.ErrorE(ctx, "Failed to start API listener", err)
Expand All @@ -167,7 +167,7 @@ var startCmd = &cobra.Command{

// wait for shutdown signal
<-signalCh
log.Info(ctx, "Recieved interrupt; closing db")
log.Info(ctx, "Received interrupt; closing db")
if n != nil {
n.Close() //nolint
}
Expand All @@ -192,5 +192,5 @@ func init() {
startCmd.Flags().StringVar(&p2pAddr, "p2paddr", "/ip4/0.0.0.0/tcp/9171", "listener address for the p2p network (formatted as a libp2p MultiAddr)")
startCmd.Flags().StringVar(&tcpAddr, "tcpaddr", "/ip4/0.0.0.0/tcp/9161", "listener address for the tcp gRPC server (formatted as a libp2p MultiAddr)")
startCmd.Flags().StringVar(&dataPath, "data", "$HOME/.defradb/data", "Data path to save DB data and other related meta-data")
startCmd.Flags().Bool("no-p2p", false, "Turn off the peer-to-peer network synchroniation system")
startCmd.Flags().Bool("no-p2p", false, "Turn off the peer-to-peer network synchronization system")
}
2 changes: 1 addition & 1 deletion core/crdt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CRDTs are Conflict-Free Replicated Data Types, which is a type of data structure
Additionally, there are many different classes of CRDTs. DefraDB uses delta-state CRDTs, and is intended to be used with MerkleClocks to create a Merkle CRDT. Check [this](https://arxiv.org/abs/1603.01529) for an overview of delta-state CRDTs. Check [this](https://hector.link/presentations/merkle-crdts/merkle-crdts.pdf) for an overview of Merkle CRDTs.

## State
Each CRDT implemented in this /core/crdt package is a `stateless` CRDT. Meaning, all of the state is internal to the provided Datastore object, almost nothing resides in memory in the ```stuct```.
Each CRDT implemented in this /core/crdt package is a `stateless` CRDT. Meaning, all of the state is internal to the provided Datastore object, almost nothing resides in memory in the ```struct```.

All CRDTs need some indication of when some event (update) happened relative to other events. In Distributed Systems this is called a `Clock`. There are various types, including Vector, Logical, or Wall Clocks. The notable difference of Merkle CRDTs, is they use a Merkle Clock to track events.Merkle Clocks keep track of a ```priority``` value each event occurred at.

Expand Down
2 changes: 1 addition & 1 deletion core/crdt/composite.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (delta *CompositeDAGDelta) GetSchemaID() string {
}

// CompositeDAG is a CRDT structure that is used
// to track a collcetion of sub MerkleCRDTs.
// to track a collection of sub MerkleCRDTs.
type CompositeDAG struct {
key string
schemaID string
Expand Down
8 changes: 4 additions & 4 deletions core/crdt/lwwreg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func TestLWWRegisterDeltaInit(t *testing.T) {
var _ core.Delta = delta // checks if LWWRegDelta implements core.Delta (also checked in the implementation code, but w.e)
}

func TestLWWRegosterDeltaGetPriority(t *testing.T) {
func TestLWWRegisterDeltaGetPriority(t *testing.T) {
delta := &LWWRegDelta{
Data: []byte("test"),
Priority: uint64(10),
Expand Down Expand Up @@ -153,7 +153,7 @@ func TestLWWRegisterDeltaMarshal(t *testing.T) {
return
}
if len(bytes) == 0 {
t.Error("Expected Marhsal to return serialized bytes, but output is empty")
t.Error("Expected Marshal to return serialized bytes, but output is empty")
return
}

Expand All @@ -167,7 +167,7 @@ func TestLWWRegisterDeltaMarshal(t *testing.T) {
}

if !reflect.DeepEqual(delta.Data, unmarshaledDelta.Data) {
t.Errorf("Unmarhsalled data value doesn't match expected. Want %v, have %v", []byte("test"), unmarshaledDelta.Data)
t.Errorf("Unmarshalled data value doesn't match expected. Want %v, have %v", []byte("test"), unmarshaledDelta.Data)
return
}

Expand Down Expand Up @@ -220,7 +220,7 @@ func TestLWWRegisterDeltaDecode(t *testing.T) {
reg := LWWRegister{}
extractedDelta, err := reg.DeltaDecode(node)
if err != nil {
t.Errorf("Recieved error while extracing node: %v", err)
t.Errorf("Received error while extracing node: %v", err)
return
}

Expand Down
2 changes: 1 addition & 1 deletion core/net/broadcaster.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ type Broadcaster interface {
// Send broadcasts a message without blocking
Send(v interface{}) error

// SendWithTimeout broadcasts a message, blocks upto timeout duration
// SendWithTimeout broadcasts a message, blocks up to timeout duration
SendWithTimeout(v interface{}, d time.Duration) error
}
4 changes: 2 additions & 2 deletions db/base/descriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (c CollectionDescription) GetPrimaryIndexDocKeyForCRDT(ctype core.CType, ke
}

// IndexDescription describes an Index on a Collection
// and its assocatied metadata.
// and its associated metadata.
type IndexDescription struct {
Name string
ID uint32
Expand Down Expand Up @@ -161,7 +161,7 @@ const (
FieldKind_INT_ARRAY FieldKind = 5
FieldKind_FLOAT FieldKind = 6
FieldKind_FLOAT_ARRAY FieldKind = 7
FieldKind_DECIMNAL FieldKind = 8
FieldKind_DECIMAL FieldKind = 8
FieldKind_DATE FieldKind = 9
FieldKind_TIMESTAMP FieldKind = 10
FieldKind_STRING FieldKind = 11
Expand Down
8 changes: 4 additions & 4 deletions db/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func (db *DB) CreateCollection(ctx context.Context, desc base.CollectionDescript

key = base.MakeCollectionSystemKey(col.desc.Name)

//write the collection metadata to the system store
// write the collection metadata to the system store
err = db.Systemstore().Put(ctx, key.ToDS(), buf)
if err != nil {
return nil, err
Expand Down Expand Up @@ -581,11 +581,11 @@ func (c *Collection) save(ctx context.Context, txn core.Txn, doc *document.Docum
merge[k] = val.Value()
}

// NOTE: We delay the final Clean() call till we know
// the commit on the transaction is successfull. If we didn't
// NOTE: We delay the final Clean() call until we know
// the commit on the transaction is successful. If we didn't
// wait, and just did it here, then *if* the commit fails down
// the line, then we have no way to roll back the state
// side-effect on the documnet func called here.
// side-effect on the document func called here.
txn.OnSuccess(func() {
doc.Clean()
})
Expand Down
4 changes: 2 additions & 2 deletions db/collection_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ func (c *Collection) deleteWithFilter(
return nil, err
}

// Delete the document that is assosiated with this key we got from the filter.
// Delete the document that is associated with this key we got from the filter.
err = c.applyFullDelete(ctx, txn, key)
if err != nil {
return nil, err
Expand Down Expand Up @@ -375,7 +375,7 @@ func (d dagDeleter) run(ctx context.Context, targetCid cid.Cid) error {
block, err := d.bstore.Get(ctx, targetCid)
if err == blockstore.ErrNotFound {
// If we have multiple heads corresponding to a dockey, one of the heads
// could have already deleted the parantal dag chain.
// could have already deleted the parental dag chain.
// Example: in the diagram below, HEAD#1 with cid1 deleted (represented by `:x`)
// all the parental nodes. Currently HEAD#2 goes to delete
// itself (represented by `:d`) and it's parental nodes, but as we see
Expand Down
2 changes: 1 addition & 1 deletion db/collection_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
)

func (c *Collection) Get(ctx context.Context, key key.DocKey) (*document.Document, error) {
//create txn
// create txn
txn, err := c.getTxn(ctx, true)
if err != nil {
return nil, err
Expand Down
13 changes: 6 additions & 7 deletions db/collection_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func (c *Collection) applyPatch(txn core.Txn, doc map[string]interface{}, patch
}
}

// comleted patch update
// completed patch update
return nil
}

Expand Down Expand Up @@ -347,8 +347,7 @@ func (c *Collection) applyMerge(ctx context.Context, txn core.Txn, doc map[strin
// even for fields defined as Ints, which causes issues
// when we serialize that in CBOR. To generate the delta
// payload.
// So lets just make sure ints are ints
// ref: https://play.golang.org/p/djThEqGXtvR
// So let's just make sure ints are ints ref: https://play.golang.org/p/djThEqGXtvR
if fd.Kind == base.FieldKind_INT {
merge[mfield] = int64(mval.(float64))
}
Expand Down Expand Up @@ -379,14 +378,14 @@ func (c *Collection) applyMerge(ctx context.Context, txn core.Txn, doc map[strin
return err
}

// if this a a Batch masked as a Transaction
// If this a a Batch masked as a Transaction
// commit our writes so we can see them.
// Batches don't maintain serializability, or
// linearization, or any other transaction
// semantics, which the user already knows
// otherwise they wouldn't use a datastore
// that doesn't support proper transactions.
// So lets just commit, and keep going.
// So let's just commit, and keep going.
// @todo: Change this on the Txn.BatchShim
// structure
if txn.IsBatch() {
Expand Down Expand Up @@ -447,7 +446,7 @@ func validateFieldSchema(val interface{}, field base.FieldDescription) (interfac
}
ok = true
cval = boolArray
case base.FieldKind_FLOAT, base.FieldKind_DECIMNAL:
case base.FieldKind_FLOAT, base.FieldKind_DECIMAL:
cval, ok = val.(float64)
case base.FieldKind_FLOAT_ARRAY:
if val == nil {
Expand Down Expand Up @@ -573,7 +572,7 @@ func (c *Collection) makeSelectLocal(filter *parser.Filter) (*parser.Select, err

// getTypeAndCollectionForPatch parses the Patch op path values
// and compares it against the collection schema.
// If its within the schema, then patchIsSubType is false
// If it's within the schema, then patchIsSubType is false
// subTypeName is empty.
// If the target type is an array, isArray is true.
// May need to query the database for other schema types
Expand Down
15 changes: 7 additions & 8 deletions db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var (
log = logging.MustNewLogger("defra.db")
// ErrDocVerification occurs when a documents contents fail the verification during a Create()
// call against the supplied Document Key
ErrDocVerification = errors.New("The document verificatioin failed")
ErrDocVerification = errors.New("The document verification failed")

ErrOptionsEmpty = errors.New("Empty options configuration provided")
)
Expand All @@ -47,7 +47,6 @@ var (

// DB is the main interface for interacting with the
// DefraDB storage system.
//
type DB struct {
glock sync.RWMutex

Expand Down Expand Up @@ -133,12 +132,12 @@ func (db *DB) Rootstore() core.DSReaderWriter {
return db.multistore.Rootstore()
}

// Headstore returns the interal index store for DAG Heads
// Headstore returns the internal index store for DAG Heads
func (db *DB) Headstore() core.DSReaderWriter {
return db.multistore.Headstore()
}

// Datastore returns the interal index store for DAG Heads
// Datastore returns the internal index store for DAG Heads
func (db *DB) Datastore() core.DSReaderWriter {
return db.multistore.Datastore()
}
Expand All @@ -164,13 +163,13 @@ func (db *DB) initialize(ctx context.Context) error {
return err
}
// if we're loading an existing database, just load the schema
// and finish intialization
// and finish initialization
if exists {
log.Debug(ctx, "db has already been initalized, conitnuing.")
log.Debug(ctx, "DB has already been initialized, continuing.")
return db.loadSchema(ctx)
}

log.Debug(ctx, "opened a new db, needs full intialization")
log.Debug(ctx, "Opened a new DB, needs full initialization")
// init meta data
// collection sequence
_, err = db.getSequence(ctx, "collection")
Expand Down Expand Up @@ -207,7 +206,7 @@ func (db *DB) Close(ctx context.Context) {
if err != nil {
log.ErrorE(ctx, "Failure closing running process", err)
}
log.Info(ctx, "Succesfully closed running process")
log.Info(ctx, "Successfully closed running process")
}

func printStore(ctx context.Context, store core.DSReaderWriter) {
Expand Down
Loading

0 comments on commit 42a3b8b

Please sign in to comment.