Skip to content
This repository has been archived by the owner on Mar 5, 2020. It is now read-only.

Commit

Permalink
First draft of the delegatebw address. B1's account should
Browse files Browse the repository at this point in the history
be b1 for the `undelegatebw` vesting algo.
  • Loading branch information
abourget committed May 15, 2018
1 parent 1153b0e commit d26e173
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,13 @@ TODO

* Implement `eos-bios boot --reset` or something.. through eosio.disco::delgenesis

* create the "RAM" currency, issue an initial base ? is it with `setram` ?
* call `setram`, agree on it.. start with 32GB ?

* delegatebw, from/to eosio, do the transfer with it ?

* undelegatebw never removes my "voters" entry.. sunk forever ?



Role Seed Account Target Acct Weight Contents Launch block (local time)
Expand Down
12 changes: 12 additions & 0 deletions bios/disco/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ type PeerLink struct {
Weight uint8 `json:"weight"`
}

type peerLinkEdge struct {
SourceAccount *Discovery
DestAccount *Discovery
PeerLink *PeerLink
}

func (e peerLinkEdge) From() int64 {
id, _ := eos.StringToName(string(d.SeedNetworkAccountName))
return int64(id)
}

type ContentRef struct {
Name string `json:"name"`
Ref string `json:"ref"`
Expand Down Expand Up @@ -41,6 +52,7 @@ type Discovery struct {
UpdatedAt eos.JSONTime `json:"-"` // injected in `UpdatedGraph`
}

// ID serves as a `graph.Node` implementation.
func (d Discovery) ID() int64 {
id, _ := eos.StringToName(string(d.SeedNetworkAccountName))
return int64(id)
Expand Down
12 changes: 6 additions & 6 deletions bios/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ func (net *Network) fetchGraphFromSeedNetwork() error {
}

var rows []struct {
ID eos.AccountName `json:"id"`
DiscoveryFile *disco.Discovery `json:"content"`
UpdatedAt eos.JSONTime `json:"updated_at"`
ID eos.AccountName `json:"id"`
Discovery *disco.Discovery `json:"content"`
UpdatedAt eos.JSONTime `json:"updated_at"`
}
if err := rowsJSON.JSONToStructs(&rows); err != nil {
return fmt.Errorf("reading discovery from table: %s", err)
Expand All @@ -105,9 +105,9 @@ func (net *Network) fetchGraphFromSeedNetwork() error {
for _, cand := range rows {
// TODO: verify their discovery file.. the values in there.. do we simply skip those with invalid weights for example ?? They're excluded from the graph?

cand.DiscoveryFile.UpdatedAt = cand.UpdatedAt
cand.DiscoveryFile.SeedNetworkAccountName = cand.ID // we override what they think, we use what they *signed* for..
net.candidates[string(cand.ID)] = cand.DiscoveryFile
cand.Discovery.UpdatedAt = cand.UpdatedAt
cand.Discovery.SeedNetworkAccountName = cand.ID // we override what they think, we use what they *signed* for..
net.candidates[string(cand.ID)] = cand.Discovery
}

return nil
Expand Down
16 changes: 16 additions & 0 deletions bios/ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,12 @@ func (op *OpInjectSnapshot) Actions(b *BIOS) (out []*eos.Action, err error) {
for idx, hodler := range snapshotData {
flipped := flipEndianness(uint64(idx + 1))
destAccount := AN("genesis." + eos.NameToString(flipped))

if hodler.EthereumAddress == "0x00000000000000000000000000000000000000b1" {
// the undelegatebw action does special unvesting for the b1 account
destAccount = "b1"
}

fmt.Println("Transfer", hodler, destAccount)

out = append(out, system.NewNewAccount(AN("eosio"), destAccount, hodler.EOSPublicKey))
Expand All @@ -257,6 +263,16 @@ func (op *OpInjectSnapshot) Actions(b *BIOS) (out []*eos.Action, err error) {

out = append(out, token.NewTransfer(AN("eosio"), destAccount, hodler.Balance, memo))

firstHalf := hodler.Balance
secondHalf := hodler.Balance

firstHalf.Amount = firstHalf.Amount / 2
secondHalf.Amount = hodler.Balance.Amount - firstHalf.Amount

delBW := system.NewDelegateBW(destAccount, AN("eosio"), firstHalf, secondHalf, false)
delBW.Authorization[0].Actor = eos.AN("eosio")
out = append(out, delBW)

if trunc := op.TestnetTruncateSnapshot; trunc != 0 {
if idx == trunc {
fmt.Printf("- DEBUG: truncated snapshot at %d rows\n", trunc)
Expand Down

0 comments on commit d26e173

Please sign in to comment.