Class: Node

Node

Extends Kademlia with Storj protocol rules

new Node(options)

Parameters:
Name Type Description
options object
Properties
Name Type Argument Default Description
privateExtendedKey string HD extended private key
logger object <optional>
Bunyan compatible logger
transport object <optional>
Storj transport adapter
contracts object Levelup compatible contract store
shards object KFS compatible shard database
claims boolean <optional>
false Enable direct capacity claims
keyDerivationIndex number <optional>
HD derivation index
License:
  • AGPL-3.0
Source:

Methods


auditRemoteShards(peer, audits, callback)

Sends the series of hash/challenge pairs to the remote node to request proof-of-storage
Parameters:
Name Type Description
peer array
Properties
Name Type Description
0 string Identity key string
1 string | object Address data for contact
audits Array.<object>
Properties
Name Type Description
hash string Hash of the shard to prove
challenge string Challenge string to prepend to shard
callback Node~auditRemoteShardsCallback
Source:

authorizeConsignment(peer, hashes, callback)

Requests authorization tokens to push file shard(s) to another node
Parameters:
Name Type Description
peer array
Properties
Name Type Description
0 string Identity key string
1 string | object Address data for contact
hashes Array.<string> Hashes of the shards to push
callback Node~authorizeConsignmentCallback
Source:

authorizeRetrieval(peer, hashes, callback)

Requests authorization tokens to pull file shard(s) from another node
Parameters:
Name Type Description
peer array
Properties
Name Type Description
0 string Identity key string
1 string | object Address data for contact
hashes Array.<string> Hashes of the shards to pull
callback Node~authorizeRetrievalCallback
Source:

claimFarmerCapacity(peer, descriptor, callback)

Claims capacity from a farming node, given a valid contract
Parameters:
Name Type Description
peer array
Properties
Name Type Description
0 string Identity key string
1 string | object Address data for contact
descriptor object Contract descriptor
callback Node~claimFarmerCapacityCallback
Source:

createShardMirror(source, target, callback)

Requests the source node to MIRROR a shard to the supplied destination
Parameters:
Name Type Description
source array
Properties
Name Type Description
0 string Identity key string
1 string | object Address data for contact
target object
Properties
Name Type Description
destination array -
Properties
Name Type Description
0 string Identity key string
1 string | object Address data for contact
hash string Hash of the shard to mirror
token string Authorization token to PUSH shard
callback Node~createShardMirrorCallback
Source:

listen()

Adds the kademlia rule handlers before calling super#listen()
Source:

offerShardAllocation(peer, contract, callback)

Offers a peer an allocation for the storage of a given shard descriptor-turned-contract, see storage-contracts for details
Parameters:
Name Type Description
peer array
Properties
Name Type Description
0 string Identity key string
1 string | object Address data for contact
contract object The completed shard descriptor contract
callback Node~offerShardAllocationCallback
Source:

publishCapacityAnnouncement(descriptorCode, bytesAvailable, callback)

Announces to interested renter nodes that this node has capacity available for renting.
Parameters:
Name Type Description
descriptorCode Array.<string> See Protocol Specification
bytesAvailable number Total bytes capacity available
callback Node~publishCapacityAnnouncementCallback
Source:

publishShardDescriptor(contract [, offerStreamOptions], callback)

Publishes a storage contract proposal to the network and exposes a stream of received OFFER messages
Parameters:
Name Type Argument Description
contract object See storage-contracts for format
offerStreamOptions object <optional>
See OfferStream
callback Node~publishShardDescriptorCallback
Source:

requestContractRenewal(peer, contract, callback)

Requests that the target peer update their local version of the given contract. Used to extend storage time or terminate storage. Peer will respond with an error or their updated, signed record of the renewal.
Parameters:
Name Type Description
peer array
Properties
Name Type Description
0 string Identity key string
1 object Address data for contact
contract object The completed shard descriptor contract
callback Node~requestContractRenewalCallback
Source:

resolveContractOffer(hash, offer, error, contract, callback)

Resolves the offer for the given shard hash and offer identifier
Parameters:
Name Type Description
hash string Shard hash for the contract
offer string Unique offer identifier
error error | null If applicable an error object
contract object | null The resolved and signed contract
callback Node~resolveContractOfferCallback
Source:

subscribeCapacityAnnouncement(descriptorCodes, callback)

Subscribes to capacity announcements for the given topic codes and exposes announcements as a stream.
Parameters:
Name Type Description
descriptorCodes Array.<string> See Protocol Specification
callback Node~subscribeCapacityAnnouncementCallback
Source:

subscribeShardDescriptor(descriptorCodes, callback)

Subscribes to the supplied shard descriptor topics and executes the user and exposes a stream of incoming shard descriptor messages
Parameters:
Name Type Description
descriptorCodes Array.<string> See Protocol Specification
callback Node~subscribeShardDescriptorCallback
Source:

Type Definitions


auditRemoteShardsCallback(error, proofs)

Parameters:
Name Type Description
error object | null
proofs Array.<object>
Properties
Name Type Description
hash string Hash of the shard for corresponding proof
proof string compact-merkle-proof
Source:

authorizeConsignmentCallback(error, consignmentTokens)

Parameters:
Name Type Description
error error | null
consignmentTokens Array.<string>
Source:

authorizeRetrievalCallback(error, retrievalTokens)

Parameters:
Name Type Description
error error | null
retrievalTokens Array.<string>
Source:

claimFarmerCapacityCallback(error, result)

Parameters:
Name Type Description
error error | null
result array
Properties
Name Type Description
0 object Completed contract result
1 string Consignment token
Source:

createShardMirrorCallback(error)

Parameters:
Name Type Description
error object | null
Source:

offerShardAllocationCallback(error, contract)

Parameters:
Name Type Description
error error | null
contract object See storage-contracts
Source:

publishCapacityAnnouncementCallback(error)

Parameters:
Name Type Description
error error | null
Source:

publishShardDescriptorCallback(error, offerStream)

Parameters:
Name Type Description
error error | null
offerStream Offers Readable stream of OFFER messages
Source:

requestContractRenewalCallback(error, contract)

Parameters:
Name Type Description
error error | null
contract object See storage-contracts
Source:

resolveContractOfferCallback(error)

Parameters:
Name Type Description
error error | null
Source:

subscribeCapacityAnnouncementCallback(error, capacityStream)

Parameters:
Name Type Description
error error | null
capacityStream ReadableStream
Source:

subscribeShardDescriptorCallback(error, descriptorStream)

Parameters:
Name Type Description
error error | null
descriptorStream ReadableStream Readable stream of incoming shard descriptors
Source: