Skip to content

Commit

Permalink
lightnode, store: comments and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jazg committed Feb 7, 2020
1 parent 32931dd commit cc0be25
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
12 changes: 6 additions & 6 deletions lightnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,34 +114,34 @@ type Lightnode struct {
// New constructs a new `Lightnode`.
func New(ctx context.Context, options Options, logger logrus.FieldLogger, sqlDB *sql.DB, client *redis.Client) Lightnode {
options.SetZeroToDefault()
// All tasks have the same capacity, and no scaling
// Define the options used for all Phi tasks.
opts := phi.Options{Cap: options.Cap}

// Initialize the databae
// Initialise the database.
db := db.New(sqlDB)
if err := db.Init(); err != nil {
logger.Panicf("fail to initialize db, err = %v", err)
}

// Server options
// Define the options used for the server.
serverOptions := http.Options{
Port: options.Port,
MaxBatchSize: options.MaxBatchSize,
Timeout: options.ServerTimeout,
}

// TODO: This is currently not configurable from the ENV variables
// TODO: These are currently not configurable from environment variables.
confirmerOptions := confirmer.Options{
MinConfirmations: darknode.DefaultMinConfirmations(options.Network),
PollInterval: options.ConfirmerPollRate,
Expiry: options.Expiry,
}

// Init the multiAddress store
// Initialise the multi-address store.
table := kv.NewTable(kv.NewMemDB(kv.JSONCodec), "addresses")
multiStore := store.New(table, options.BootstrapAddrs)

// Initialize the blockchain adapter
// Initialise the blockchain adapter.
protocolAddr := common.HexToAddress(options.ProtocolAddr)
connPool := blockchain.New(logger, options.Network, protocolAddr)

Expand Down
9 changes: 5 additions & 4 deletions store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (multiStore *MultiAddrStore) Size() (int, error) {
return multiStore.store.Size()
}

// AddrsAll returns all of the multi addresses that are currently in the store.
// AddrsAll returns all of the multi-addresses in the store.
func (multiStore *MultiAddrStore) AddrsAll() (addr.MultiAddresses, error) {
addrs := addr.MultiAddresses{}
iter := multiStore.store.Iterator()
Expand All @@ -73,12 +73,13 @@ func (multiStore *MultiAddrStore) AddrsAll() (addr.MultiAddresses, error) {
return addrs, nil
}

// BootstrapAll returns all of the multi addresses of bootstrap nodes.
// BootstrapAll returns the multi-addresses of all of the Bootstrap nodes.
func (multiStore *MultiAddrStore) BootstrapAll() (addr.MultiAddresses, error) {
return multiStore.RandomBootstrapAddrs(len(multiStore.bootstrapIDs))
}

// RandomAddrs returns a random number of bootstrap nodes from the store.
// RandomBootstrapAddrs returns a random number of Bootstrap multi-addresses in
// the store.
func (multiStore *MultiAddrStore) RandomBootstrapAddrs(n int) (addr.MultiAddresses, error) {
if n < len(multiStore.bootstrapIDs) {
rand.Shuffle(len(multiStore.bootstrapIDs), func(i, j int) {
Expand All @@ -98,7 +99,7 @@ func (multiStore *MultiAddrStore) RandomBootstrapAddrs(n int) (addr.MultiAddress
return addrs, nil
}

// RandomAddrs returns a random number of addresses from the store.
// RandomAddrs returns a random number of multi-addresses in the store.
func (multiStore *MultiAddrStore) RandomAddrs(n int) (addr.MultiAddresses, error) {
addrs, err := multiStore.AddrsAll()
if err != nil {
Expand Down

0 comments on commit cc0be25

Please sign in to comment.