Add comments [skip ci]

This commit is contained in:
kdeme 2020-07-08 14:56:56 +02:00
parent 4f3df3c9b2
commit eeb958e834
No known key found for this signature in database
GPG Key ID: 4E8DD21420AF43F5
1 changed files with 18 additions and 1 deletions

View File

@ -165,7 +165,7 @@ proc init*(T: type Record, seqNum: uint64,
extraFields: openarray[FieldPair] = []): extraFields: openarray[FieldPair] = []):
EnrResult[T] = EnrResult[T] =
## Initialize a `Record` with given sequence number, private key, optional ## Initialize a `Record` with given sequence number, private key, optional
## ip-address, tcp port, udp port, and optional custom k:v pairs. ## ip address, tcp port, udp port, and optional custom k:v pairs.
## ##
## Can fail in case the record exceeds the `maxEnrSize`. ## Can fail in case the record exceeds the `maxEnrSize`.
var fields = newSeq[FieldPair]() var fields = newSeq[FieldPair]()
@ -235,6 +235,14 @@ proc find(r: Record, key: string): Option[int] =
proc update*(record: var Record, pk: PrivateKey, proc update*(record: var Record, pk: PrivateKey,
fieldPairs: openarray[FieldPair]): EnrResult[void] = fieldPairs: openarray[FieldPair]): EnrResult[void] =
## Update a `Record` k:v pairs.
##
## In case any of the k:v pairs is updated or added (new), the sequence number
## of the `Record` will be incremented and a new signature will be applied.
##
## Can fail in case of wrong `PrivateKey`, if the size of the resulting record
## exceeds `maxEnrSize` or if maximum sequence number is reached. The `Record`
## will not be altered in these cases.
var r = record var r = record
let pubkey = r.get(PublicKey) let pubkey = r.get(PublicKey)
@ -271,6 +279,15 @@ proc update*(r: var Record, pk: PrivateKey,
tcpPort, udpPort: Port, tcpPort, udpPort: Port,
extraFields: openarray[FieldPair] = []): extraFields: openarray[FieldPair] = []):
EnrResult[void] = EnrResult[void] =
## Update a `Record` with given ip address, tcp port, udp port and optional
## custom k:v pairs.
##
## In case any of the k:v pairs is updated or added (new), the sequence number
## of the `Record` will be incremented and a new signature will be applied.
##
## Can fail in case of wrong `PrivateKey`, if the size of the resulting record
## exceeds `maxEnrSize` or if maximum sequence number is reached. The `Record`
## will not be altered in these cases.
var fields = newSeq[FieldPair]() var fields = newSeq[FieldPair]()
fields.addAddress(ip, tcpPort, udpPort) fields.addAddress(ip, tcpPort, udpPort)