Difference between revisions of "MIP-0003"
Mochimowiki (talk | contribs) (→Hard Fork Required) |
Mochimowiki (talk | contribs) (→Technical Details) |
||
Line 47: | Line 47: | ||
if(Fountain) register(np); | if(Fountain) register(np); | ||
return 0; | return 0; | ||
+ | <br> | ||
+ | Add a function to init.c to read in data from fountain1.addr and fountain2.addr: | ||
+ | check_ng() {} | ||
+ | ... | ||
+ | int read_fountain() | ||
+ | { | ||
+ | ... /* read fountain addresses into global ftnaddr1, ftnaddr2, ftnaddr1key, ftnaddr2key */ | ||
+ | <br> | ||
+ | Add a call to "read_fountain() in function init() if Fountain feature is enabled: | ||
+ | read_localipl(Lpfname); | ||
+ | ... | ||
+ | if(read_fountain(!= VEOK) error("init(): read_fountain() could not load fountain address files"); | ||
− | The file "fountain.c" is added to the source directory with the processing logic for the new OP_CODE. | + | The file "fountain.c" is added to the source directory with the processing logic for the new OP_CODE, as follows. |
+ | # Received passed in node pointer, and extract the source address and tag. | ||
+ | # Confirm the tag does not exist in the ledger. | ||
+ | # Collect the node pointer registrant IP. | ||
+ | # Read fountain-whitelist for any privileged IP. | ||
+ | # Add registrant IP to file "register-list" |
Revision as of 08:32, 22 November 2020
Contents
MIP-0003 - Add Fountain Functionality As Native Feature
Presented to the Core Contributor Team on November 21, 2020 by user sputnik
Sponsor(s)
The following Core Contributors have "sponsored" this MIP.
- Stackoverflo (talk · contribs) I think it's long overdue. I'll code it as an optional module at first and if the community agrees we'll add it to the mainline code.
NOTE: Sponsorship for these purposes means that these Core Contributors have committed to developing the code on behalf of the community if this MIP is adopted. Note: Core Contributor sponsorship is not required for a MIP to be implemented. It just makes things easier on the community.
Problem Definition
Fountain services are presently operated by the Mochimo project, and while documentation exists for how to run a Fountain Service, it would be beneficial for this to simply be a built-in optional module for the full node code.
Solution Summary
Users will add a "fountain.addr" address file to the Mochimo Full Node startup directory, and then enable an additional command-line switch on node startup, to allow it to receive and process requests as a fountain node.
Hard Fork Required ?
No.
Technical Details
A global byte var "Fountain" is added to data.c to signal when the feature is enabled:
byte Fountain; /* enable fountain service if true */
A new capability bit "C_FOUNTAIN" is added to types.h to signal the node has fountain service enabled:
#define C_FOUNTAIN 32
NOTE: At time of proposal CBIT 32 is the first available.
A command-line switch "r" is added to mochimo.c, and function usage() updated to reflect new switch "r":
void usage(void) { ... printf("usage: mochimo [-option...]\n" " -r enable Fountain / Tag Registration Service\n"
Function main() switch(argv[j][1]) updated to reflect new switch "r", set global var Fountain to true, and set node capability bit for C_FOUNTAIN:
case 'r': Fountain = 1; Cbits |= C_FOUNTAIN; break;
A new OP_CODE is added to types.h to identify when an inbound transaction is a Tag registration request to the fountain service.
#define OP_REGISTER 20
An handler entry is added to "execute.c" to call the registration function, when a registration request is received:
int execute(NODE *np) { ... switch(np->opcode) { ... case OP_REGISTER: /* Process a tag registration request if Fountain service is enabled. */ if(Fountain) register(np); return 0;
Add a function to init.c to read in data from fountain1.addr and fountain2.addr:
check_ng() {} ... int read_fountain() { ... /* read fountain addresses into global ftnaddr1, ftnaddr2, ftnaddr1key, ftnaddr2key */
Add a call to "read_fountain() in function init() if Fountain feature is enabled:
read_localipl(Lpfname); ... if(read_fountain(!= VEOK) error("init(): read_fountain() could not load fountain address files");
The file "fountain.c" is added to the source directory with the processing logic for the new OP_CODE, as follows.
- Received passed in node pointer, and extract the source address and tag.
- Confirm the tag does not exist in the ledger.
- Collect the node pointer registrant IP.
- Read fountain-whitelist for any privileged IP.
- Add registrant IP to file "register-list"