new_ static method

Future<Host> new_(
  1. List<Option> options
)

Creates a new libp2p node with the given options.

This is a convenience method that creates a new Config, applies the options, and calls newNode() on the Config.

Implementation

static Future<Host> new_(List<Option> options) async {
  final config = newConfig();
  await config.apply(options);

  // Apply defaults for any options that weren't specified
  await applyDefaults(config);

  // Register core record types
  RecordRegistry.register<pb.PeerRecord>(
    String.fromCharCodes(PeerRecordEnvelopePayloadType),
    pb.PeerRecord.fromBuffer
  );

  return await config.newNode();
}